1 line
79 KiB
Plaintext
1 line
79 KiB
Plaintext
{"version":3,"sources":["mustache.min.js","underscore-min.js","mapfun.js","map-phantom.js"],"names":[],"mappings":"AAAA;AACA;ACDA;AACA;AACA;AACA;AACA;AACA;ACLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;ACtuCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"map-p.js","sourcesContent":["(function defineMustache(global,factory){if(typeof exports===\"object\"&&exports&&typeof exports.nodeName!==\"string\"){factory(exports)}else if(typeof define===\"function\"&&define.amd){define([\"exports\"],factory)}else{global.Mustache={};factory(global.Mustache)}})(this,function mustacheFactory(mustache){var objectToString=Object.prototype.toString;var isArray=Array.isArray||function isArrayPolyfill(object){return objectToString.call(object)===\"[object Array]\"};function isFunction(object){return typeof object===\"function\"}function typeStr(obj){return isArray(obj)?\"array\":typeof obj}function escapeRegExp(string){return string.replace(/[\\-\\[\\]{}()*+?.,\\\\\\^$|#\\s]/g,\"\\\\$&\")}function hasProperty(obj,propName){return obj!=null&&typeof obj===\"object\"&&propName in obj}var regExpTest=RegExp.prototype.test;function testRegExp(re,string){return regExpTest.call(re,string)}var nonSpaceRe=/\\S/;function isWhitespace(string){return!testRegExp(nonSpaceRe,string)}var entityMap={\"&\":\"&\",\"<\":\"<\",\">\":\">\",'\"':\""\",\"'\":\"'\",\"/\":\"/\",\"`\":\"`\",\"=\":\"=\"};function escapeHtml(string){return String(string).replace(/[&<>\"'`=\\/]/g,function fromEntityMap(s){return entityMap[s]})}var whiteRe=/\\s*/;var spaceRe=/\\s+/;var equalsRe=/\\s*=/;var curlyRe=/\\s*\\}/;var tagRe=/#|\\^|\\/|>|\\{|&|=|!/;function parseTemplate(template,tags){if(!template)return[];var sections=[];var tokens=[];var spaces=[];var hasTag=false;var nonSpace=false;function stripSpace(){if(hasTag&&!nonSpace){while(spaces.length)delete tokens[spaces.pop()]}else{spaces=[]}hasTag=false;nonSpace=false}var openingTagRe,closingTagRe,closingCurlyRe;function compileTags(tagsToCompile){if(typeof tagsToCompile===\"string\")tagsToCompile=tagsToCompile.split(spaceRe,2);if(!isArray(tagsToCompile)||tagsToCompile.length!==2)throw new Error(\"Invalid tags: \"+tagsToCompile);openingTagRe=new RegExp(escapeRegExp(tagsToCompile[0])+\"\\\\s*\");closingTagRe=new RegExp(\"\\\\s*\"+escapeRegExp(tagsToCompile[1]));closingCurlyRe=new RegExp(\"\\\\s*\"+escapeRegExp(\"}\"+tagsToCompile[1]))}compileTags(tags||mustache.tags);var scanner=new Scanner(template);var start,type,value,chr,token,openSection;while(!scanner.eos()){start=scanner.pos;value=scanner.scanUntil(openingTagRe);if(value){for(var i=0,valueLength=value.length;i<valueLength;++i){chr=value.charAt(i);if(isWhitespace(chr)){spaces.push(tokens.length)}else{nonSpace=true}tokens.push([\"text\",chr,start,start+1]);start+=1;if(chr===\"\\n\")stripSpace()}}if(!scanner.scan(openingTagRe))break;hasTag=true;type=scanner.scan(tagRe)||\"name\";scanner.scan(whiteRe);if(type===\"=\"){value=scanner.scanUntil(equalsRe);scanner.scan(equalsRe);scanner.scanUntil(closingTagRe)}else if(type===\"{\"){value=scanner.scanUntil(closingCurlyRe);scanner.scan(curlyRe);scanner.scanUntil(closingTagRe);type=\"&\"}else{value=scanner.scanUntil(closingTagRe)}if(!scanner.scan(closingTagRe))throw new Error(\"Unclosed tag at \"+scanner.pos);token=[type,value,start,scanner.pos];tokens.push(token);if(type===\"#\"||type===\"^\"){sections.push(token)}else if(type===\"/\"){openSection=sections.pop();if(!openSection)throw new Error('Unopened section \"'+value+'\" at '+start);if(openSection[1]!==value)throw new Error('Unclosed section \"'+openSection[1]+'\" at '+start)}else if(type===\"name\"||type===\"{\"||type===\"&\"){nonSpace=true}else if(type===\"=\"){compileTags(value)}}openSection=sections.pop();if(openSection)throw new Error('Unclosed section \"'+openSection[1]+'\" at '+scanner.pos);return nestTokens(squashTokens(tokens))}function squashTokens(tokens){var squashedTokens=[];var token,lastToken;for(var i=0,numTokens=tokens.length;i<numTokens;++i){token=tokens[i];if(token){if(token[0]===\"text\"&&lastToken&&lastToken[0]===\"text\"){lastToken[1]+=token[1];lastToken[3]=token[3]}else{squashedTokens.push(token);lastToken=token}}}return squashedTokens}function nestTokens(tokens){var nestedTokens=[];var collector=nestedTokens;var sections=[];var token,section;for(var i=0,numTokens=tokens.length;i<numTokens;++i){token=tokens[i];switch(token[0]){case\"#\":case\"^\":collector.push(token);sections.push(token);collector=token[4]=[];break;case\"/\":section=sections.pop();section[5]=token[2];collector=sections.length>0?sections[sections.length-1][4]:nestedTokens;break;default:collector.push(token)}}return nestedTokens}function Scanner(string){this.string=string;this.tail=string;this.pos=0}Scanner.prototype.eos=function eos(){return this.tail===\"\"};Scanner.prototype.scan=function scan(re){var match=this.tail.match(re);if(!match||match.index!==0)return\"\";var string=match[0];this.tail=this.tail.substring(string.length);this.pos+=string.length;return string};Scanner.prototype.scanUntil=function scanUntil(re){var index=this.tail.search(re),match;switch(index){case-1:match=this.tail;this.tail=\"\";break;case 0:match=\"\";break;default:match=this.tail.substring(0,index);this.tail=this.tail.substring(index)}this.pos+=match.length;return match};function Context(view,parentContext){this.view=view;this.cache={\".\":this.view};this.parent=parentContext}Context.prototype.push=function push(view){return new Context(view,this)};Context.prototype.lookup=function lookup(name){var cache=this.cache;var value;if(cache.hasOwnProperty(name)){value=cache[name]}else{var context=this,names,index,lookupHit=false;while(context){if(name.indexOf(\".\")>0){value=context.view;names=name.split(\".\");index=0;while(value!=null&&index<names.length){if(index===names.length-1)lookupHit=hasProperty(value,names[index]);value=value[names[index++]]}}else{value=context.view[name];lookupHit=hasProperty(context.view,name)}if(lookupHit)break;context=context.parent}cache[name]=value}if(isFunction(value))value=value.call(this.view);return value};function Writer(){this.cache={}}Writer.prototype.clearCache=function clearCache(){this.cache={}};Writer.prototype.parse=function parse(template,tags){var cache=this.cache;var tokens=cache[template];if(tokens==null)tokens=cache[template]=parseTemplate(template,tags);return tokens};Writer.prototype.render=function render(template,view,partials){var tokens=this.parse(template);var context=view instanceof Context?view:new Context(view);return this.renderTokens(tokens,context,partials,template)};Writer.prototype.renderTokens=function renderTokens(tokens,context,partials,originalTemplate){var buffer=\"\";var token,symbol,value;for(var i=0,numTokens=tokens.length;i<numTokens;++i){value=undefined;token=tokens[i];symbol=token[0];if(symbol===\"#\")value=this.renderSection(token,context,partials,originalTemplate);else if(symbol===\"^\")value=this.renderInverted(token,context,partials,originalTemplate);else if(symbol===\">\")value=this.renderPartial(token,context,partials,originalTemplate);else if(symbol===\"&\")value=this.unescapedValue(token,context);else if(symbol===\"name\")value=this.escapedValue(token,context);else if(symbol===\"text\")value=this.rawValue(token);if(value!==undefined)buffer+=value}return buffer};Writer.prototype.renderSection=function renderSection(token,context,partials,originalTemplate){var self=this;var buffer=\"\";var value=context.lookup(token[1]);function subRender(template){return self.render(template,context,partials)}if(!value)return;if(isArray(value)){for(var j=0,valueLength=value.length;j<valueLength;++j){buffer+=this.renderTokens(token[4],context.push(value[j]),partials,originalTemplate)}}else if(typeof value===\"object\"||typeof value===\"string\"||typeof value===\"number\"){buffer+=this.renderTokens(token[4],context.push(value),partials,originalTemplate)}else if(isFunction(value)){if(typeof originalTemplate!==\"string\")throw new Error(\"Cannot use higher-order sections without the original template\");value=value.call(context.view,originalTemplate.slice(token[3],token[5]),subRender);if(value!=null)buffer+=value}else{buffer+=this.renderTokens(token[4],context,partials,originalTemplate)}return buffer};Writer.prototype.renderInverted=function renderInverted(token,context,partials,originalTemplate){var value=context.lookup(token[1]);if(!value||isArray(value)&&value.length===0)return this.renderTokens(token[4],context,partials,originalTemplate)};Writer.prototype.renderPartial=function renderPartial(token,context,partials){if(!partials)return;var value=isFunction(partials)?partials(token[1]):partials[token[1]];if(value!=null)return this.renderTokens(this.parse(value),context,partials,value)};Writer.prototype.unescapedValue=function unescapedValue(token,context){var value=context.lookup(token[1]);if(value!=null)return value};Writer.prototype.escapedValue=function escapedValue(token,context){var value=context.lookup(token[1]);if(value!=null)return mustache.escape(value)};Writer.prototype.rawValue=function rawValue(token){return token[1]};mustache.name=\"mustache.js\";mustache.version=\"2.2.1\";mustache.tags=[\"{{\",\"}}\"];var defaultWriter=new Writer;mustache.clearCache=function clearCache(){return defaultWriter.clearCache()};mustache.parse=function parse(template,tags){return defaultWriter.parse(template,tags)};mustache.render=function render(template,view,partials){if(typeof template!==\"string\"){throw new TypeError('Invalid template! Template should be a \"string\" '+'but \"'+typeStr(template)+'\" was given as the first '+\"argument for mustache#render(template, view, partials)\")}return defaultWriter.render(template,view,partials)};mustache.to_html=function to_html(template,view,partials,send){var result=mustache.render(template,view,partials);if(isFunction(send)){send(result)}else{return result}};mustache.escape=escapeHtml;mustache.Scanner=Scanner;mustache.Context=Context;mustache.Writer=Writer});\n","// Underscore.js 1.8.3\n// http://underscorejs.org\n// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors\n// Underscore may be freely distributed under the MIT license.\n(function(){function n(n){function t(t,r,e,u,i,o){for(;i>=0&&o>i;i+=n){var a=u?u[i]:i;e=r(e,t[a],a,t)}return e}return function(r,e,u,i){e=b(e,i,4);var o=!k(r)&&m.keys(r),a=(o||r).length,c=n>0?0:a-1;return arguments.length<3&&(u=r[o?o[c]:c],c+=n),t(r,e,u,o,c,a)}}function t(n){return function(t,r,e){r=x(r,e);for(var u=O(t),i=n>0?0:u-1;i>=0&&u>i;i+=n)if(r(t[i],i,t))return i;return-1}}function r(n,t,r){return function(e,u,i){var o=0,a=O(e);if(\"number\"==typeof i)n>0?o=i>=0?i:Math.max(i+a,o):a=i>=0?Math.min(i+1,a):i+a+1;else if(r&&i&&a)return i=r(e,u),e[i]===u?i:-1;if(u!==u)return i=t(l.call(e,o,a),m.isNaN),i>=0?i+o:-1;for(i=n>0?o:a-1;i>=0&&a>i;i+=n)if(e[i]===u)return i;return-1}}function e(n,t){var r=I.length,e=n.constructor,u=m.isFunction(e)&&e.prototype||a,i=\"constructor\";for(m.has(n,i)&&!m.contains(t,i)&&t.push(i);r--;)i=I[r],i in n&&n[i]!==u[i]&&!m.contains(t,i)&&t.push(i)}var u=this,i=u._,o=Array.prototype,a=Object.prototype,c=Function.prototype,f=o.push,l=o.slice,s=a.toString,p=a.hasOwnProperty,h=Array.isArray,v=Object.keys,g=c.bind,y=Object.create,d=function(){},m=function(n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)};\"undefined\"!=typeof exports?(\"undefined\"!=typeof module&&module.exports&&(exports=module.exports=m),exports._=m):u._=m,m.VERSION=\"1.8.3\";var b=function(n,t,r){if(t===void 0)return n;switch(null==r?3:r){case 1:return function(r){return n.call(t,r)};case 2:return function(r,e){return n.call(t,r,e)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,i){return n.call(t,r,e,u,i)}}return function(){return n.apply(t,arguments)}},x=function(n,t,r){return null==n?m.identity:m.isFunction(n)?b(n,t,r):m.isObject(n)?m.matcher(n):m.property(n)};m.iteratee=function(n,t){return x(n,t,1/0)};var _=function(n,t){return function(r){var e=arguments.length;if(2>e||null==r)return r;for(var u=1;e>u;u++)for(var i=arguments[u],o=n(i),a=o.length,c=0;a>c;c++){var f=o[c];t&&r[f]!==void 0||(r[f]=i[f])}return r}},j=function(n){if(!m.isObject(n))return{};if(y)return y(n);d.prototype=n;var t=new d;return d.prototype=null,t},w=function(n){return function(t){return null==t?void 0:t[n]}},A=Math.pow(2,53)-1,O=w(\"length\"),k=function(n){var t=O(n);return\"number\"==typeof t&&t>=0&&A>=t};m.each=m.forEach=function(n,t,r){t=b(t,r);var e,u;if(k(n))for(e=0,u=n.length;u>e;e++)t(n[e],e,n);else{var i=m.keys(n);for(e=0,u=i.length;u>e;e++)t(n[i[e]],i[e],n)}return n},m.map=m.collect=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=Array(u),o=0;u>o;o++){var a=e?e[o]:o;i[o]=t(n[a],a,n)}return i},m.reduce=m.foldl=m.inject=n(1),m.reduceRight=m.foldr=n(-1),m.find=m.detect=function(n,t,r){var e;return e=k(n)?m.findIndex(n,t,r):m.findKey(n,t,r),e!==void 0&&e!==-1?n[e]:void 0},m.filter=m.select=function(n,t,r){var e=[];return t=x(t,r),m.each(n,function(n,r,u){t(n,r,u)&&e.push(n)}),e},m.reject=function(n,t,r){return m.filter(n,m.negate(x(t)),r)},m.every=m.all=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(!t(n[o],o,n))return!1}return!0},m.some=m.any=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(t(n[o],o,n))return!0}return!1},m.contains=m.includes=m.include=function(n,t,r,e){return k(n)||(n=m.values(n)),(\"number\"!=typeof r||e)&&(r=0),m.indexOf(n,t,r)>=0},m.invoke=function(n,t){var r=l.call(arguments,2),e=m.isFunction(t);return m.map(n,function(n){var u=e?t:n[t];return null==u?u:u.apply(n,r)})},m.pluck=function(n,t){return m.map(n,m.property(t))},m.where=function(n,t){return m.filter(n,m.matcher(t))},m.findWhere=function(n,t){return m.find(n,m.matcher(t))},m.max=function(n,t,r){var e,u,i=-1/0,o=-1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],e>i&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(u>o||u===-1/0&&i===-1/0)&&(i=n,o=u)});return i},m.min=function(n,t,r){var e,u,i=1/0,o=1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],i>e&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(o>u||1/0===u&&1/0===i)&&(i=n,o=u)});return i},m.shuffle=function(n){for(var t,r=k(n)?n:m.values(n),e=r.length,u=Array(e),i=0;e>i;i++)t=m.random(0,i),t!==i&&(u[i]=u[t]),u[t]=r[i];return u},m.sample=function(n,t,r){return null==t||r?(k(n)||(n=m.values(n)),n[m.random(n.length-1)]):m.shuffle(n).slice(0,Math.max(0,t))},m.sortBy=function(n,t,r){return t=x(t,r),m.pluck(m.map(n,function(n,r,e){return{value:n,index:r,criteria:t(n,r,e)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),\"value\")};var F=function(n){return function(t,r,e){var u={};return r=x(r,e),m.each(t,function(e,i){var o=r(e,i,t);n(u,e,o)}),u}};m.groupBy=F(function(n,t,r){m.has(n,r)?n[r].push(t):n[r]=[t]}),m.indexBy=F(function(n,t,r){n[r]=t}),m.countBy=F(function(n,t,r){m.has(n,r)?n[r]++:n[r]=1}),m.toArray=function(n){return n?m.isArray(n)?l.call(n):k(n)?m.map(n,m.identity):m.values(n):[]},m.size=function(n){return null==n?0:k(n)?n.length:m.keys(n).length},m.partition=function(n,t,r){t=x(t,r);var e=[],u=[];return m.each(n,function(n,r,i){(t(n,r,i)?e:u).push(n)}),[e,u]},m.first=m.head=m.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:m.initial(n,n.length-t)},m.initial=function(n,t,r){return l.call(n,0,Math.max(0,n.length-(null==t||r?1:t)))},m.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:m.rest(n,Math.max(0,n.length-t))},m.rest=m.tail=m.drop=function(n,t,r){return l.call(n,null==t||r?1:t)},m.compact=function(n){return m.filter(n,m.identity)};var S=function(n,t,r,e){for(var u=[],i=0,o=e||0,a=O(n);a>o;o++){var c=n[o];if(k(c)&&(m.isArray(c)||m.isArguments(c))){t||(c=S(c,t,r));var f=0,l=c.length;for(u.length+=l;l>f;)u[i++]=c[f++]}else r||(u[i++]=c)}return u};m.flatten=function(n,t){return S(n,t,!1)},m.without=function(n){return m.difference(n,l.call(arguments,1))},m.uniq=m.unique=function(n,t,r,e){m.isBoolean(t)||(e=r,r=t,t=!1),null!=r&&(r=x(r,e));for(var u=[],i=[],o=0,a=O(n);a>o;o++){var c=n[o],f=r?r(c,o,n):c;t?(o&&i===f||u.push(c),i=f):r?m.contains(i,f)||(i.push(f),u.push(c)):m.contains(u,c)||u.push(c)}return u},m.union=function(){return m.uniq(S(arguments,!0,!0))},m.intersection=function(n){for(var t=[],r=arguments.length,e=0,u=O(n);u>e;e++){var i=n[e];if(!m.contains(t,i)){for(var o=1;r>o&&m.contains(arguments[o],i);o++);o===r&&t.push(i)}}return t},m.difference=function(n){var t=S(arguments,!0,!0,1);return m.filter(n,function(n){return!m.contains(t,n)})},m.zip=function(){return m.unzip(arguments)},m.unzip=function(n){for(var t=n&&m.max(n,O).length||0,r=Array(t),e=0;t>e;e++)r[e]=m.pluck(n,e);return r},m.object=function(n,t){for(var r={},e=0,u=O(n);u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},m.findIndex=t(1),m.findLastIndex=t(-1),m.sortedIndex=function(n,t,r,e){r=x(r,e,1);for(var u=r(t),i=0,o=O(n);o>i;){var a=Math.floor((i+o)/2);r(n[a])<u?i=a+1:o=a}return i},m.indexOf=r(1,m.findIndex,m.sortedIndex),m.lastIndexOf=r(-1,m.findLastIndex),m.range=function(n,t,r){null==t&&(t=n||0,n=0),r=r||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=Array(e),i=0;e>i;i++,n+=r)u[i]=n;return u};var E=function(n,t,r,e,u){if(!(e instanceof t))return n.apply(r,u);var i=j(n.prototype),o=n.apply(i,u);return m.isObject(o)?o:i};m.bind=function(n,t){if(g&&n.bind===g)return g.apply(n,l.call(arguments,1));if(!m.isFunction(n))throw new TypeError(\"Bind must be called on a function\");var r=l.call(arguments,2),e=function(){return E(n,e,t,this,r.concat(l.call(arguments)))};return e},m.partial=function(n){var t=l.call(arguments,1),r=function(){for(var e=0,u=t.length,i=Array(u),o=0;u>o;o++)i[o]=t[o]===m?arguments[e++]:t[o];for(;e<arguments.length;)i.push(arguments[e++]);return E(n,r,this,this,i)};return r},m.bindAll=function(n){var t,r,e=arguments.length;if(1>=e)throw new Error(\"bindAll must be passed function names\");for(t=1;e>t;t++)r=arguments[t],n[r]=m.bind(n[r],n);return n},m.memoize=function(n,t){var r=function(e){var u=r.cache,i=\"\"+(t?t.apply(this,arguments):e);return m.has(u,i)||(u[i]=n.apply(this,arguments)),u[i]};return r.cache={},r},m.delay=function(n,t){var r=l.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},m.defer=m.partial(m.delay,m,1),m.throttle=function(n,t,r){var e,u,i,o=null,a=0;r||(r={});var c=function(){a=r.leading===!1?0:m.now(),o=null,i=n.apply(e,u),o||(e=u=null)};return function(){var f=m.now();a||r.leading!==!1||(a=f);var l=t-(f-a);return e=this,u=arguments,0>=l||l>t?(o&&(clearTimeout(o),o=null),a=f,i=n.apply(e,u),o||(e=u=null)):o||r.trailing===!1||(o=setTimeout(c,l)),i}},m.debounce=function(n,t,r){var e,u,i,o,a,c=function(){var f=m.now()-o;t>f&&f>=0?e=setTimeout(c,t-f):(e=null,r||(a=n.apply(i,u),e||(i=u=null)))};return function(){i=this,u=arguments,o=m.now();var f=r&&!e;return e||(e=setTimeout(c,t)),f&&(a=n.apply(i,u),i=u=null),a}},m.wrap=function(n,t){return m.partial(t,n)},m.negate=function(n){return function(){return!n.apply(this,arguments)}},m.compose=function(){var n=arguments,t=n.length-1;return function(){for(var r=t,e=n[t].apply(this,arguments);r--;)e=n[r].call(this,e);return e}},m.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},m.before=function(n,t){var r;return function(){return--n>0&&(r=t.apply(this,arguments)),1>=n&&(t=null),r}},m.once=m.partial(m.before,2);var M=!{toString:null}.propertyIsEnumerable(\"toString\"),I=[\"valueOf\",\"isPrototypeOf\",\"toString\",\"propertyIsEnumerable\",\"hasOwnProperty\",\"toLocaleString\"];m.keys=function(n){if(!m.isObject(n))return[];if(v)return v(n);var t=[];for(var r in n)m.has(n,r)&&t.push(r);return M&&e(n,t),t},m.allKeys=function(n){if(!m.isObject(n))return[];var t=[];for(var r in n)t.push(r);return M&&e(n,t),t},m.values=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},m.mapObject=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=u.length,o={},a=0;i>a;a++)e=u[a],o[e]=t(n[e],e,n);return o},m.pairs=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},m.invert=function(n){for(var t={},r=m.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},m.functions=m.methods=function(n){var t=[];for(var r in n)m.isFunction(n[r])&&t.push(r);return t.sort()},m.extend=_(m.allKeys),m.extendOwn=m.assign=_(m.keys),m.findKey=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=0,o=u.length;o>i;i++)if(e=u[i],t(n[e],e,n))return e},m.pick=function(n,t,r){var e,u,i={},o=n;if(null==o)return i;m.isFunction(t)?(u=m.allKeys(o),e=b(t,r)):(u=S(arguments,!1,!1,1),e=function(n,t,r){return t in r},o=Object(o));for(var a=0,c=u.length;c>a;a++){var f=u[a],l=o[f];e(l,f,o)&&(i[f]=l)}return i},m.omit=function(n,t,r){if(m.isFunction(t))t=m.negate(t);else{var e=m.map(S(arguments,!1,!1,1),String);t=function(n,t){return!m.contains(e,t)}}return m.pick(n,t,r)},m.defaults=_(m.allKeys,!0),m.create=function(n,t){var r=j(n);return t&&m.extendOwn(r,t),r},m.clone=function(n){return m.isObject(n)?m.isArray(n)?n.slice():m.extend({},n):n},m.tap=function(n,t){return t(n),n},m.isMatch=function(n,t){var r=m.keys(t),e=r.length;if(null==n)return!e;for(var u=Object(n),i=0;e>i;i++){var o=r[i];if(t[o]!==u[o]||!(o in u))return!1}return!0};var N=function(n,t,r,e){if(n===t)return 0!==n||1/n===1/t;if(null==n||null==t)return n===t;n instanceof m&&(n=n._wrapped),t instanceof m&&(t=t._wrapped);var u=s.call(n);if(u!==s.call(t))return!1;switch(u){case\"[object RegExp]\":case\"[object String]\":return\"\"+n==\"\"+t;case\"[object Number]\":return+n!==+n?+t!==+t:0===+n?1/+n===1/t:+n===+t;case\"[object Date]\":case\"[object Boolean]\":return+n===+t}var i=\"[object Array]\"===u;if(!i){if(\"object\"!=typeof n||\"object\"!=typeof t)return!1;var o=n.constructor,a=t.constructor;if(o!==a&&!(m.isFunction(o)&&o instanceof o&&m.isFunction(a)&&a instanceof a)&&\"constructor\"in n&&\"constructor\"in t)return!1}r=r||[],e=e||[];for(var c=r.length;c--;)if(r[c]===n)return e[c]===t;if(r.push(n),e.push(t),i){if(c=n.length,c!==t.length)return!1;for(;c--;)if(!N(n[c],t[c],r,e))return!1}else{var f,l=m.keys(n);if(c=l.length,m.keys(t).length!==c)return!1;for(;c--;)if(f=l[c],!m.has(t,f)||!N(n[f],t[f],r,e))return!1}return r.pop(),e.pop(),!0};m.isEqual=function(n,t){return N(n,t)},m.isEmpty=function(n){return null==n?!0:k(n)&&(m.isArray(n)||m.isString(n)||m.isArguments(n))?0===n.length:0===m.keys(n).length},m.isElement=function(n){return!(!n||1!==n.nodeType)},m.isArray=h||function(n){return\"[object Array]\"===s.call(n)},m.isObject=function(n){var t=typeof n;return\"function\"===t||\"object\"===t&&!!n},m.each([\"Arguments\",\"Function\",\"String\",\"Number\",\"Date\",\"RegExp\",\"Error\"],function(n){m[\"is\"+n]=function(t){return s.call(t)===\"[object \"+n+\"]\"}}),m.isArguments(arguments)||(m.isArguments=function(n){return m.has(n,\"callee\")}),\"function\"!=typeof/./&&\"object\"!=typeof Int8Array&&(m.isFunction=function(n){return\"function\"==typeof n||!1}),m.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},m.isNaN=function(n){return m.isNumber(n)&&n!==+n},m.isBoolean=function(n){return n===!0||n===!1||\"[object Boolean]\"===s.call(n)},m.isNull=function(n){return null===n},m.isUndefined=function(n){return n===void 0},m.has=function(n,t){return null!=n&&p.call(n,t)},m.noConflict=function(){return u._=i,this},m.identity=function(n){return n},m.constant=function(n){return function(){return n}},m.noop=function(){},m.property=w,m.propertyOf=function(n){return null==n?function(){}:function(t){return n[t]}},m.matcher=m.matches=function(n){return n=m.extendOwn({},n),function(t){return m.isMatch(t,n)}},m.times=function(n,t,r){var e=Array(Math.max(0,n));t=b(t,r,1);for(var u=0;n>u;u++)e[u]=t(u);return e},m.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},m.now=Date.now||function(){return(new Date).getTime()};var B={\"&\":\"&\",\"<\":\"<\",\">\":\">\",'\"':\""\",\"'\":\"'\",\"`\":\"`\"},T=m.invert(B),R=function(n){var t=function(t){return n[t]},r=\"(?:\"+m.keys(n).join(\"|\")+\")\",e=RegExp(r),u=RegExp(r,\"g\");return function(n){return n=null==n?\"\":\"\"+n,e.test(n)?n.replace(u,t):n}};m.escape=R(B),m.unescape=R(T),m.result=function(n,t,r){var e=null==n?void 0:n[t];return e===void 0&&(e=r),m.isFunction(e)?e.call(n):e};var q=0;m.uniqueId=function(n){var t=++q+\"\";return n?n+t:t},m.templateSettings={evaluate:/<%([\\s\\S]+?)%>/g,interpolate:/<%=([\\s\\S]+?)%>/g,escape:/<%-([\\s\\S]+?)%>/g};var K=/(.)^/,z={\"'\":\"'\",\"\\\\\":\"\\\\\",\"\\r\":\"r\",\"\\n\":\"n\",\"\\u2028\":\"u2028\",\"\\u2029\":\"u2029\"},D=/\\\\|'|\\r|\\n|\\u2028|\\u2029/g,L=function(n){return\"\\\\\"+z[n]};m.template=function(n,t,r){!t&&r&&(t=r),t=m.defaults({},t,m.templateSettings);var e=RegExp([(t.escape||K).source,(t.interpolate||K).source,(t.evaluate||K).source].join(\"|\")+\"|$\",\"g\"),u=0,i=\"__p+='\";n.replace(e,function(t,r,e,o,a){return i+=n.slice(u,a).replace(D,L),u=a+t.length,r?i+=\"'+\\n((__t=(\"+r+\"))==null?'':_.escape(__t))+\\n'\":e?i+=\"'+\\n((__t=(\"+e+\"))==null?'':__t)+\\n'\":o&&(i+=\"';\\n\"+o+\"\\n__p+='\"),t}),i+=\"';\\n\",t.variable||(i=\"with(obj||{}){\\n\"+i+\"}\\n\"),i=\"var __t,__p='',__j=Array.prototype.join,\"+\"print=function(){__p+=__j.call(arguments,'');};\\n\"+i+\"return __p;\\n\";try{var o=new Function(t.variable||\"obj\",\"_\",i)}catch(a){throw a.source=i,a}var c=function(n){return o.call(this,n,m)},f=t.variable||\"obj\";return c.source=\"function(\"+f+\"){\\n\"+i+\"}\",c},m.chain=function(n){var t=m(n);return t._chain=!0,t};var P=function(n,t){return n._chain?m(t).chain():t};m.mixin=function(n){m.each(m.functions(n),function(t){var r=m[t]=n[t];m.prototype[t]=function(){var n=[this._wrapped];return f.apply(n,arguments),P(this,r.apply(m,n))}})},m.mixin(m),m.each([\"pop\",\"push\",\"reverse\",\"shift\",\"sort\",\"splice\",\"unshift\"],function(n){var t=o[n];m.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),\"shift\"!==n&&\"splice\"!==n||0!==r.length||delete r[0],P(this,r)}}),m.each([\"concat\",\"join\",\"slice\"],function(n){var t=o[n];m.prototype[n]=function(){return P(this,t.apply(this._wrapped,arguments))}}),m.prototype.value=function(){return this._wrapped},m.prototype.valueOf=m.prototype.toJSON=m.prototype.value,m.prototype.toString=function(){return\"\"+this._wrapped},\"function\"==typeof define&&define.amd&&define(\"underscore\",[],function(){return m})}).call(this);\n//# sourceMappingURL=underscore-min.map","var legend = new Array();\nvar activeLayers = new Array();\nvar show_active_layers_flag = true;\nfunction toWKT(layer) {\n var lng, lat, coords = [];\n if (layer instanceof L.Polygon || layer instanceof L.Polyline) {\n var latlngs = layer.getLatLngs();\n for (var i = 0; i < latlngs.length; i++) {\n latlngs[i]\n coords.push(latlngs[i].lng + \" \" + latlngs[i].lat);\n if (i === 0) {\n lng = latlngs[i].lng;\n lat = latlngs[i].lat;\n }\n }\n ;\n if (layer instanceof L.Polygon) {\n return \"POLYGON((\" + coords.join(\",\") + \",\" + lng + \" \" + lat + \"))\";\n } else if (layer instanceof L.Polyline) {\n return \"LINESTRING(\" + coords.join(\",\") + \")\";\n }\n } else if (layer instanceof L.Marker) {\n return \"POINT(\" + layer.getLatLng().lng + \" \" + layer.getLatLng().lat + \")\";\n }\n}\n\njQuery(document).ready(function () {\n L.TileLayer.BetterWMS = L.TileLayer.WMS.extend({\n\n onAdd: function (map) {\n // Triggered when the layer is added to a map.\n // Register a click listener, then do all the upstream WMS things\n L.TileLayer.WMS.prototype.onAdd.call(this, map);\n map.on('click', this.getFeatureInfo, this);\n },\n\n onRemove: function (map) {\n // Triggered when the layer is removed from a map.\n // Unregister a click listener, then do all the upstream WMS things\n L.TileLayer.WMS.prototype.onRemove.call(this, map);\n map.off('click', this.getFeatureInfo, this);\n },\n\n getFeatureInfo: function (evt) {\n\n // Make an AJAX request to the server and hope for the best\n var url = this.getFeatureInfoUrl(evt.latlng),\n showResults = L.Util.bind(this.showGetFeatureInfo, this);\n $.ajax({\n url: url,\n success: function (data, status, xhr) {\n var err = typeof data === 'string' ? null : data;\n showResults(err, evt.latlng, data);\n },\n error: function (xhr, status, error) {\n showResults(error);\n }\n });\n },\n\n getFeatureInfoUrl: function (latlng) {\n //console.log(this.wmsParams.srs1);\n // Construct a GetFeatureInfo request URL given a point\n var point = this._map.latLngToContainerPoint(latlng, this._map.getZoom()),\n size = this._map.getSize();\n var ltype = this.wmsParams.layer_type;\n\n var format = \"application/json\";\n if (ltype == 4) {\n format = \"text/html\";\n }\n var params = {\n request: 'GetFeatureInfo',\n service: 'WMS',\n //srs: this.wmsParams.srs1,\n srs: 'EPSG:4326',\n styles: this.wmsParams.styles,\n transparent: this.wmsParams.transparent,\n version: this.wmsParams.version,\n format: this.wmsParams.format,\n // bbox: this._map.getBounds().toBBoxString(),\n height: size.y,\n width: size.x,\n layers: this.wmsParams.layers,\n query_layers: this.wmsParams.layers,\n info_format: format\n };\n\n params[params.version === '1.3.0' ? 'i' : 'x'] = point.x;\n params[params.version === '1.3.0' ? 'j' : 'y'] = point.y;\n\n return this._url + L.Util.getParamString(params, this._url, true);\n },\n\n showGetFeatureInfo: function (err, latlng, content) {\n // console.log(err);\n // console.log(this.wmsParams.keyname);\n // don't open again....\n// if (err) {\n// console.log(err);\n// return;\n// } // do nothing if there's an error\n // console.log(content);\n\n console.log(content);\n\n var index = getIndex(selectedLayers, 'unique_id', this.wmsParams.unique_id);\n var popupContent = \"\";\n\n if (selectedLayers[index].type == 1) {\n if (!content.features || content.features.length == 0) {\n return;\n }\n\n popupContent = getPopupContent(content, selectedLayers[index].pc);\n\n } else {\n\n if (jQuery(content).find(\"tr\").length < 2) {\n return;\n }\n popupContent = content;\n }\n // Otherwise show the content in a popup, or something.\n L.popup({maxWidth: 'auto'})\n .setLatLng(latlng)\n .setContent(popupContent)\n .openOn(this._map);\n\n// if (selectedLayers[index].type == 4) { \n// $('.leaflet-popup-content-wrapper').find('table').addClass(\"table\"); \n// }\n }\n });\n\n L.tileLayer.betterWms = function (url, options) {\n return new L.TileLayer.BetterWMS(url, options);\n };\n\n L.Icon.Default.imagePath = baseURL + \"/assets/plugins/leaflet/images\";\n L.AwesomeMarkers.Icon.prototype.options.prefix = 'fa';\n})\nfunction renderLayer(t, data) {\n\n if (typeof featureGroup[t.unique_id] == \"undefined\") {\n featureGroup[t.unique_id] = new Array();\n }\n\n if (t.type == 2 && (typeof t.cluster != \"undefined\" && t.cluster == 1)) {\n featureGroup[t.unique_id][t.name] = new L.MarkerClusterGroup();\n } else {\n featureGroup[t.unique_id][t.name] = new L.FeatureGroup();\n }\n console.log(t.settings);\n if (typeof t.settings != \"undefined\") {\n if (t.settings.active == 1) {\n add_current_layer_text(t);\n featureGroup[t.unique_id][t.name].addTo(mymap);\n } else {\n t.settings.active = 0;\n }\n } else {\n featureGroup[t.unique_id][t.name].addTo(mymap);\n t.settings = new Object;\n t.settings.active = 1;\n }\n\n if (t.settings.active == 1) {\n activeLayers.push({id: t._id, order: 0});\n order_current_active_layers();\n }\n\n if (typeof page != \"undefined\" && page == \"phantom\") {\n console.log(\"added\" + t._id);\n if ($.inArray(t._id, active_ids) !== -1) {\n // console.log(t.settings.active);\n // if(t.settings.active == 0){\n console.log(\"added\");\n featureGroup[t.unique_id][t.name].addTo(mymap);\n\n //} \n } else if (t.settings.active == 1) {\n console.log(\"not added\");\n mymap.removeLayer(featureGroup[t.unique_id][t.name]);\n }\n\n }\n\n if (typeof page != \"undefined\" && page == \"user_farm\") {\n\n if (t.settings.active == 1 && show_active_layers_flag == true) {\n jQuery('#chk_' + t.unique_id).prop(\"checked\", \"checked\");\n }\n }\n\n if (typeof page != \"undefined\" && page == \"manage\" && show_active_layers_flag == true) {\n\n //jQuery('#active-layers-container').append(Mustache.render(tmpl.activeLayer, t));\n jQuery('#active-layers-container .media-list').append(Mustache.render(tmpl.activeLayer, {t: t, type: layerType[t.type]}));\n if (t.settings.active == 0) {\n jQuery('#at-' + t.unique_id + \" a.dropdown-toggle span\").addClass(\"label-danger\").removeClass(\"label-primary\");\n }\n\n jQuery('.help-active-popup-hover').popover({\n title: 'Active & In-Active',\n content: '<div class=\"row\"><div class=\"col-md-12\"><p>This feature allows you to initially hide a layer. This can be used to achieve a desired layer presentation as well as to provide faster map loading for larger layers.</p></div></div>',\n html: true,\n trigger: 'hover',\n container: 'body'\n });\n\n jQuery('.at_active_chk').bootstrapSwitch({\n size: 'mini',\n onSwitchChange: function (event, state) {\n event.preventDefault();\n var self = jQuery(this).parents(\".active-layer-action:first\");\n var key = self.attr(\"data-id\");\n var index = getIndex(selectedLayers, 'unique_id', key);\n\n if (!selectedLayers[index].settings && typeof selectedLayers[index].settings == \"undefined\") {\n selectedLayers[index].settings = new Object;\n }\n\n update_dirty(index);\n\n if (state === true) {\n selectedLayers[index].settings.active = 1;\n jQuery('#at-' + t.unique_id + \" a.dropdown-toggle span\").removeClass(\"label-danger\").addClass(\"label-primary\");\n mymap.addLayer(featureGroup[key][selectedLayers[index].name]);\n } else {\n selectedLayers[index].settings.active = 0;\n jQuery('#at-' + t.unique_id + \" a.dropdown-toggle span\").addClass(\"label-danger\").removeClass(\"label-primary\");\n mymap.removeLayer(featureGroup[key][selectedLayers[index].name]);\n }\n calculateBounds();\n }\n });\n }\n\n if (t.type == 1 || t.type == 4) {\n\n // L.imageOverlay('http://services.sentinel-hub.com/v1/wms/1977e8da-981e-447b-9f45-876336853164?SERVICE=WMS&REQUEST=GetMap&MAXCC=100&SRS=CRS:84&LAYERS=VEGETATION_INDEX&WIDTH=1141&HEIGHT=600&COLCOR=,BOOST&FORMAT=image/jpeg&BGCOLOR=00000000&TRANSPARENT=1&TIME=2015-01-01/2016-12-04&BBOX=31.86337271,-25.58553214,31.92626005,-25.55247732&GEOMETRY=POLYGON%28%2831.86501197235643%20-25.552477323857563,31.86337270813486%20-25.564976812169963,31.866014590158265%20-25.565714510820147,31.86637945987775%20-25.566359976486257,31.86634960957168%20-25.566972492232132,31.866314735384275%20-25.567069146264945,31.86628018302301%20-25.567197997023754,31.8660717242862%20-25.56784185437009,31.86603721621925%20-25.567970549041522,31.86579847109656%20-25.569127641679255,31.865728265045835%20-25.5692560707222,31.86521915498914%20-25.569470655598835,31.864963139386557%20-25.570045740273795,31.86492153624839%20-25.570699113585093,31.864864465054946%20-25.572219530020224,31.86513680151194%20-25.573523146724966,31.86593214730313%20-25.574992044206205,31.86768405924886%20-25.575919426212707,31.86979657229066%20-25.575715805214962,31.87133132314888%20-25.57577734584977,31.87282582024432%20-25.57555223276595,31.873941937061705%20-25.57524284976536,31.87508945824082%20-25.574888979398064,31.8767961971982%20-25.575014487828785,31.87887319114594%20-25.568987092446744,31.90660330293984%20-25.575217674743918,31.900480916710546%20-25.581002937467453,31.9200238144976%20-25.585532135993283,31.92626004605639%20-25.5706509773005,31.86501197235643%20-25.552477323857563%29%29', [[31.86337271,-25.58553214],[31.92626005,-25.55247732]])\n // .addTo(featureGroup[t.unique_id][t.name]);\n // console.log(t.SRS);\n var options = {\n format: 'image/png',\n layers: t.Name,\n transparent: true,\n crs: L.CRS.EPSG4326,\n unique_id: t.unique_id,\n srs1: t.SRS,\n layer_type: t.type\n };\n\n if (typeof t.geometry_area != \"undefined\") {\n options.geometry = t.geometry_area;\n }\n\n if (typeof t.time != \"undefined\") {\n options.time = t.time;\n }\n\n L.tileLayer.betterWms(t.url, options).addTo(featureGroup[t.unique_id][t.name]);\n\n } else if (t.type == 2) {\n //check data is coming \n if (data == \"\") {\n if (page == \"phantom\") {\n filterGlobalData();\n\n } else {\n if (!t.cache_timer && typeof t.cache_timer == \"undefined\") {\n t.cache_timer = 15;\n }\n data = {\n datasource: t.connection_id,\n sql_layer_name: t.name,\n \"query_box\": t.query,\n \"_token\": jQuery('[name=\"_token\"]').val(),\n \"cache_key\": t.cache_key,\n \"cache_timer\": t.cache_timer,\n \"type\": 2,\n \"map_id\": map.id\n };\n\n ajaxRequest('map/layer/json', 'post', 'json', data, function (data) {\n if (data.status == \"200\") {\n processSQLJSON(data, t);\n } else {\n showMsg(data.status, data.msg);\n }\n });\n }\n } else {\n processSQLJSON(data, t);\n }\n } else if (t.type == 3) {\n\n }\n\n overlayers_controls(t);\n overlays[t.name] = featureGroup[t.unique_id][t.name];\n layerSelector.addOverlay(featureGroup[t.unique_id][t.name], t.name);\n if (t.type == 3) {\n jQuery('#at-' + t.unique_id).find('.style-at-layer').remove();\n }\n calculateBounds();\n}\n\n\nfunction getPopupContent(content, defined_content) {\n // var featuresHTML = defined_content;\n\n $.each(content.features, function (key, feature) {\n\n //featuresHTML += '<div class=\"row\"><div class=\"col-md-12\"><h4>' + feature.id + '</h4><ul class=\"map-popup-feature-lists\">';\n $.each(feature.properties, function (key, value) {\n defined_content = defined_content.replace(\"<\" + key + \">\", value);\n //featuresHTML = '<li>' + key + ' : ' + value + '</li>';\n });\n //featuresHTML += \"</ul></div></div>\";\n })\n return defined_content;\n}\n\n\nfunction processSQLJSON(data, t) {\n t = defaultLayerStyle(t);\n if (data.more_data.sql_type == 3) {\n processheatmapJSON(data, t);\n } else {\n clearLayersAndControls(data, t);\n\n jQuery.each(data.result, function (name, json) {\n L.geoJson(json, {\n onEachFeature: function (feature, layer) {\n if (layer instanceof L.Marker) {\n var found = false;\n if (t.style.type == \"nr\") {\n\n\n $.each(t.style.custom, function (key, val) {\n\n if (between(feature.properties[t.style.field], val.val)) {\n found = true;\n layer.setIcon(L.AwesomeMarkers.icon(val.style));\n return false;\n }\n })\n\n\n\n } else if (t.style.type == \"g\") {\n\n\n $.each(t.style.custom, function (key, val) {\n\n if (feature.properties[t.style.field] == val.val) {\n found = true;\n layer.setIcon(L.AwesomeMarkers.icon(val.style));\n return false;\n }\n });\n }\n\n if (found == false) {\n layer.setIcon(L.AwesomeMarkers.icon(t.style.marker));\n }\n }\n// if (layer instanceof L.Marker) {\n// layer.setIcon(L.AwesomeMarkers.icon(t.style.marker));\n// }\n layer.on('click', function (e) {\n\n var c = getSQLPopupContent(feature.properties, t.pc);\n layer.bindPopup(c);\n\n// if (layer instanceof L.Marker) { \n// var popup = L.popup();\n// popup.setLatLng(layer.getLatLng());\n// popup.setContent(c);\n// mymap.openPopup(popup);\n// } else {\n// var bounds = layer.getBounds();\n// var popup = L.popup();\n// popup.setLatLng(bounds.getCenter());\n// popup.setContent(c);\n// mymap.openPopup(popup);\n// } \n\n })\n },\n style: function (feature, layer) {\n return t.style.polygon;\n }\n }).addTo(featureGroup[t.unique_id][t.name]);\n\n mymap.fitBounds(featureGroup[t.unique_id][t.name].getBounds());\n });\n }\n}\n\nfunction initLayer() {\n\n\n selectedLayers.sort(sort_value_layer);\n\n if (selectedBaseLayers.length > 0) {\n jQuery('#visiable-layers').find('.baselayers-control').removeClass(\"hide\");\n }\n jQuery.each(selectedBaseLayers, function (key, value) {\n\n layerSelector.addBaseLayer(baseLayers['mymap'][value.name], value.name);\n baselayers_controls(value.name);\n\n if (typeof page != \"undefined\" && page == \"manage\") {\n //alert(page);\n var ls = jQuery('#base_layer_selection').find('input:checkbox[data-name=\"' + value.name + '\"]');\n\n if (ls.length > 0) {\n ls.prop(\"checked\", \"checked\");\n baseLayerMap(ls, false);\n }\n }\n })\n\n jQuery.each(selectedLayers, function (key, value) {\n renderLayer(value, '');\n })\n\n //look for custom layers\n var data = {\n \"type\": 3,\n \"id\": map.id,\n \"_token\": jQuery('[name=\"_token\"]').val(),\n }\n ajaxRequest('map/layer/json', 'post', 'json', data, function (data) {\n\n if (data.status == \"200\") {\n processFreeHand(data);\n } else {\n showMsg(data.status, data.msg);\n }\n });\n\n\n}\n\nfunction processFreeHand(cl) {\n\n jQuery.each(cl.result, function (name, json) {\n\n index = getIndex(selectedLayers, 'unique_id', name);\n t = selectedLayers[index];\n\n if (typeof featureGroup[t.unique_id] == \"undefined\") {\n featureGroup[t.unique_id] = new Array();\n }\n featureGroup[t.unique_id][t.name] = new L.FeatureGroup();\n\n if (typeof t.settings != \"undefined\") {\n if (t.settings.active == 1) {\n featureGroup[t.unique_id][t.name].addTo(mymap);\n } else {\n t.settings.active = 0;\n }\n } else {\n featureGroup[t.unique_id][t.name].addTo(mymap);\n t.settings = new Object;\n t.settings.active = 1;\n }\n\n //featureGroup[t.unique_id][t.name].addTo(mymap);\n L.geoJson(json, {\n onEachFeature: function (feature, layer) {\n\n selectedLayers[index].layer = layer;\n\n if (t.settings.active == 1) {\n drawingGroup.addLayer(layer);\n }\n featureGroup[t.unique_id][t.name].addLayer(layer);\n\n if (layer instanceof L.Marker) {\n layer.setIcon(L.AwesomeMarkers.icon(selectedLayers[index].style.marker));\n }\n layer.bindPopup(selectedLayers[index].pc);\n\n// layer.on(\"click\", function () {\n// var index = getLayerIndex1(layer);\n// if (layer instanceof L.Marker) {\n// var popup = L.popup();\n// popup.setLatLng(layer.getLatLng());\n// popup.setContent(selectedLayers[index].pc);\n// mymap.openPopup(popup);\n// } else {\n// var bounds = layer.getBounds();\n// var popup = L.popup();\n// popup.setLatLng(bounds.getCenter());\n// popup.setContent(selectedLayers[index].pc);\n// mymap.openPopup(popup);\n// }\n// });\n\n },\n style: function (feature, layer) {\n return t.style.polygon;\n },\n pointToLayer: function (feature, latlng) {\n //console.log(feature);\n if (typeof t.radius != \"undefined\") {\n return L.circle(latlng, parseInt(t.radius, 10));\n } else {\n return L.marker(latlng);\n }\n },\n })\n\n });\n calculateBounds();\n}\n\nfunction calculateBounds() {\n\n bounds = true;\n\n jQuery.each(selectedLayers, function (key, g) {\n\n if (typeof g.settings.active == \"undefined\" || g.settings.active == 1) {\n\n if (g.type == 1 || (g.type == 4 && typeof g.geometry_area == \"undefined\")) {\n\n// if (bounds != true) {\n// // console.log(\"inside\");\n// bounds.extend([parseFloat(g['LatLonBoundingBox']['@attributes']['miny']), parseFloat(g['LatLonBoundingBox']['@attributes']['minx'])], [parseFloat(g['LatLonBoundingBox']['@attributes']['maxy']), parseFloat(g['LatLonBoundingBox']['@attributes']['maxx'])]);\n// \n// bounds = L.latLngBounds([parseFloat(g['LatLonBoundingBox']['@attributes']['miny']), parseFloat(g['LatLonBoundingBox']['@attributes']['minx'])], [parseFloat(g['LatLonBoundingBox']['@attributes']['maxy']), parseFloat(g['LatLonBoundingBox']['@attributes']['maxx'])]);\n// \n// } else {\n// if(typeof g['LatLonBoundingBox'] != \"undefined\"){\n// bounds = L.latLngBounds([parseFloat(g['LatLonBoundingBox']['@attributes']['miny']), parseFloat(g['LatLonBoundingBox']['@attributes']['minx'])], [parseFloat(g['LatLonBoundingBox']['@attributes']['maxy']), parseFloat(g['LatLonBoundingBox']['@attributes']['maxx'])]);\n// } else if(typeof g['BoundingBox'] != \"undefined\"){\n// bounds = L.latLngBounds([parseFloat(g['BoundingBox']['@attributes']['miny']), parseFloat(g['BoundingBox']['@attributes']['minx'])], [parseFloat(g['BoundingBox']['@attributes']['maxy']), parseFloat(g['BoundingBox']['@attributes']['maxx'])]);\n// } \n// }\n }\n if (g.type == 3) {\n\n\n if (typeof featureGroup[g.unique_id] != \"undefined\" && typeof featureGroup[g.unique_id][g.name] != \"undefined\") {\n\n var layer1 = featureGroup[g.unique_id][g.name];\n if (bounds != true) {\n var b1 = layer1.getBounds();\n\n if (typeof b1._southWest != \"undefined\") {\n bounds.extend(layer1.getBounds());\n }\n } else {\n var b1 = layer1.getBounds();\n\n if (typeof b1._southWest != \"undefined\") {\n console.log(\"checked\");\n bounds = b1;\n }\n }\n }\n\n }\n }\n\n })\n\n// $.each(featureGroup, function (l, layer) {\n// if (bounds != true) {\n// // console.log(\"inside\");\n// bounds.extend(layer.getBounds());\n// } else {\n// bounds = layer.getBounds();\n// }\n// })\n//\n\n if (bounds !== true) {\n mymap.fitBounds(bounds);\n }\n\n}\n\n\nfunction getLayersIndex(id) {\n var len = selectedLayers.length;\n for (i = 0; i < len; i++) {\n if (selectedLayers[i].unique_id == id) {\n return i;\n }\n }\n}\n\nfunction getIndex(obj, key, value) {\n var len = obj.length;\n for (i = 0; i < len; i++) {\n if (obj[i][key] == value) {\n return i;\n }\n }\n}\n\nfunction getSQLPopupContent(properties, defined_content) {\n // var featuresHTML = defined_content;\n\n $.each(properties, function (key, value) {\n \n if (value.match(/\\.(jpeg|jpg|gif|png)$/) != null) {\n console.log(value);\n var image = '<img src=\"' + value + '\" style=\"height:50px;width:50px;\"/>';\n defined_content = defined_content.replace(\"<\" + key + \">\", image);\n } else {\n defined_content = defined_content.replace(\"<\" + key + \">\", value);\n }\n \n });\n //featuresHTML += \"</ul></div></div>\";\n\n return defined_content;\n}\n\nfunction defaultSettings() {\n\n map.settings = map.settings != \"\" ? JSON.parse(map.settings) : new Object;\n\n if (typeof map.settings.width == \"undefined\") {\n map.settings.width = 500;\n }\n if (typeof map.settings.height == \"undefined\") {\n map.settings.height = 500;\n }\n if (typeof map.settings.zoom == \"undefined\") {\n map.settings.zoom = 6;\n }\n\n if (typeof map.settings.fullscreen == \"undefined\") {\n map.settings.fullscreen = 1;\n }\n\n if (typeof map.settings.https == \"undefined\") {\n map.settings.https = 1;\n }\n}\n\nfunction assingSettings() {\n // mymap.setZoom(map.settings.zoom);\n}\n\nfunction saveMapData(type, callback) {\n\n var len = selectedLayers.length;\n\n var jt = new Array();\n for (i = 0; i < len; i++) {\n\n if (typeof selectedLayers[i].is_dirty != \"undefined\") {\n\n if (typeof selectedLayers[i].boundary_id != \"undefined\" && typeof selectedLayers[i].geometry_area != \"undefined\") {\n selectedLayers[i].geometry_area = \"\";\n }\n\n var s = jQuery.extend(true, {}, selectedLayers[i]);\n\n if (s.type == 3) {\n if (s.layer instanceof L.Circle) {\n s.radius = s.layer.getRadius();\n }\n s.layer = s.layer.toGeoJSON();\n }\n jt.push(s);\n }\n }\n var t = {\n \"selectedLayers\": jt,\n \"selectedBaseLayers\": selectedBaseLayers\n }\n jQuery('#action_type').val(type);\n var json = JSON.stringify(t);\n\n jQuery('#layer_json').val(json);\n var formdata = jQuery('#layer-form, #map-settings-form').serialize();\n\n ajaxRequest('/developer/map/save', 'post', 'json', formdata, function (data) {\n\n if (data.status == 200) {\n jQuery('#map_id').val(data.map_id);\n // window.location = baseURL + \"/developer/map/edit/\" + data.map_id;\n //showMsg(data.action, data.msg);\n\n $.each(selectedLayers, function (key, value) {\n selectedLayers[key].is_dirty = undefined;\n if (typeof selectedLayers[key]._id == \"undefined\") {\n selectedLayers[key]._id = data.mapping_array[value.unique_id];\n }\n })\n callback(data);\n } else {\n showMsg(\"error\", data.msg);\n }\n })\n}\n\nfunction sortLayers() {\n var all_id = new Array();\n var i = 0;\n $(\"#visiable-layers div.dropdown-menu .custom-control-layers\").find('li').each(function (i) {\n var id = $(this).attr(\"data-key\");\n all_id[i] = id;\n i++;\n\n });\n\n $.each(all_id, function (index1, value) {\n var index = getIndex(selectedLayers, 'unique_id', value);\n selectedLayers[index].order = index1 + 1;\n });\n\n// $.ajax({\n// type: \"POST\",\n// url: \"{{URL::action('Superadmin\\LayersController@postSetOrder')}}\",\n// data: {'data_id': all_id}\n// }).done(function(data) {\n// alert(\"Order set successfully.\");\n// });\n}\n\nfunction overlayers_controls(t) {\n\n var temp = document.getElementById('map-overlayer-controls-tmpl').innerHTML;\n Mustache.parse(temp);\n // var html = \"\";\n if (t.type == 2 && (t.style.type == \"nr\" || t.style.type == \"g\")) {\n\n var temp2 = document.getElementById('map-overlayer-submenu-controls-tmpl').innerHTML;\n Mustache.parse(temp2);\n $(\"<li/>\").attr(\"data-key\", t.unique_id).attr(\"data-name\", t.name).addClass(\"nav-item treeview overlay_control_\" + t.unique_id).html(Mustache.render(temp2, t)).appendTo(\"#visiable-layers div.dropdown-menu .custom-control-layers\");\n\n addSubOverLayer(t);\n\n } else {\n $(\"<li/>\").attr(\"data-key\", t.unique_id).attr(\"data-name\", t.name).addClass(\"overlay_control_\" + t.unique_id).html(Mustache.render(temp, t)).appendTo(\"#visiable-layers div.dropdown-menu .custom-control-layers\").find('input[type=\"checkbox\"]').bootstrapSwitch({size: 'mini', onSwitchChange: function (event, state) {\n event.preventDefault();\n var self = jQuery(this).parents(\"li:first\");\n var key = self.attr(\"data-key\");\n var name = self.attr(\"data-name\");\n var index = getIndex(selectedLayers, 'unique_id', key);\n var t = selectedLayers[index];\n// if (t.type == 3) {\n// \n// if (state === true) {\n// \n// var layers = featureGroup[key][name];\n// console.log(layers);\n// // $.each(layers, function (key, val) {\n// \n// drawingGroup.addLayer(layers); \n// // });\n// \n// }else{\n// var layers = featureGroup[key][name];\n// //$.each(layers, function (key, val) {\n// drawingGroup.removeLayer(layers); \n// //});\n// }\n// } else {\n if (state === true) {\n mymap.addLayer(featureGroup[key][name]);\n } else {\n mymap.removeLayer(featureGroup[key][name]);\n }\n // }\n\n\n }\n });\n }\n\n\n\n\n if (typeof page != \"undefined\" && page == \"manage\") {\n// $(\"#visiable-layers div.dropdown-menu .custom-control-layers\").sortable({\n// // helper: fixHelperModified,\n// stop: sortLayers,\n// // helper: 'clone'\n// // cursorAt: {left:0, top:0}\n// //connectWith: \"table\"\n// }).disableSelection();\n }\n}\n\nfunction addSubOverLayer(t) {\n\n var $vl = jQuery('li[data-key=\"' + t.unique_id + '\"]');\n var temp1 = document.getElementById('map-overlayer-sub-controls-tmpl').innerHTML;\n // html = '<ul class=\"nav custom-control-layers ui-sortable sub-overlayers-control\"></ul>';\n //$vl.append(html);\n\n $.each(t.style.custom, function (index, val) {\n\n $(\"<li/>\").attr(\"data-key\", t.unique_id).attr(\"data-name\", t.name).attr(\"data-val\", val.val).html(Mustache.render(temp1, {val: val.val, t: t})).appendTo($vl.find(\"ul\")).find('input[type=\"checkbox\"]').bootstrapSwitch({size: 'mini', onSwitchChange: function (event, state) {\n event.preventDefault();\n var self = jQuery(this).parents(\"li:first\");\n var key = self.attr(\"data-key\");\n var name = self.attr(\"data-name\");\n var val = self.attr(\"data-val\");\n\n var index = getIndex(selectedLayers, 'unique_id', key);\n var t = selectedLayers[index];\n var layers = featureGroup[key][name].getLayers();\n\n $.each(layers, function (key1, val1) {\n\n val1.eachLayer(function (layer) {\n\n if (t.style.type == \"nr\") {\n\n if (between(layer.feature.properties[t.style.field], val)) {\n if (state === true) {\n mymap.addLayer(layer);\n } else {\n mymap.removeLayer(layer);\n }\n }\n\n } else if (t.style.type == \"g\") {\n if (layer.feature.properties[t.style.field] == val) {\n if (state === true) {\n mymap.addLayer(layer);\n } else {\n mymap.removeLayer(layer);\n }\n\n }\n }\n\n });\n\n });\n\n }\n });\n\n })\n jQuery('.subcontrol-layer-action').slimScroll({\n alwaysVisible: true,\n height: 100\n });\n\n jQuery('.submenu-overlay-controls').click(function (e) {\n e.preventDefault();\n var $self = jQuery(this);\n $self.toggleClass(\"in\");\n var d = $($self.attr(\"href\"));\n\n if (d.hasClass(\"in\")) {\n d.collapse(\"hide\");\n } else {\n d.collapse(\"show\");\n }\n\n return false;\n\n })\n}\n\nfunction baselayers_controls(name) {\n\n var temp = document.getElementById('map-baselayer-controls-tmpl').innerHTML;\n Mustache.parse(temp);\n\n $(\"<li/>\").attr(\"data-name\", name).addClass(\"baselayer_control_\" + name).html(Mustache.render(temp, {name: name})).prependTo(\"#visiable-layers div.dropdown-menu .baselayers-control-layers\").find('input[type=\"radio\"]').bootstrapSwitch({size: 'mini', onSwitchChange: function (event, state) {\n event.preventDefault();\n\n var self = jQuery(this).parents(\"li:first\");\n var name = self.attr(\"data-name\");\n\n $.each(baseLayers[\"mymap\"], function (name, value) {\n console.log(name);\n mymap.removeLayer(baseLayers[\"mymap\"][name]);\n })\n if (state === true) {\n\n mymap.addLayer(baseLayers[\"mymap\"][name]);\n }\n }});\n\n\n}\n\nfunction removeOverlayerControl(gskey) {\n jQuery('#visiable-layers').find('.overlay_control_' + gskey).remove();\n}\nfunction applyLiveStyle(type) {\n\n var my_unique_id = jQuery('#map-sidebar-container [name=\"my_unique_id\"]').val();\n var index = getIndex(selectedLayers, 'unique_id', my_unique_id);\n update_dirty(index, 2);\n\n var style = {};\n jQuery('#layer-polygon-styling input').each(function () {\n var $self = jQuery(this);\n style[$self.attr(\"name\")] = $self.val();\n })\n\n var marker = {};\n jQuery('#layer-marker-styling .default-marker-style select').each(function () {\n var $self = jQuery(this);\n marker[$self.attr(\"data-name\")] = $self.val();\n })\n\n if (selectedLayers[index].type == 2) {\n var layers = featureGroup[selectedLayers[index].unique_id][selectedLayers[index].name].getLayers();\n $.each(layers, function (key, val) {\n val.eachLayer(function (layer) {\n\n if (layer instanceof L.Marker) {\n layer.setIcon(L.AwesomeMarkers.icon(marker));\n } else if (layer instanceof L.Polyline ||\n layer instanceof L.Polygon ||\n layer instanceof L.Rectangle ||\n layer instanceof L.Circle) {\n layer.setStyle(style);\n }\n\n });\n });\n } else if (selectedLayers[index].type == 3) {\n var layer = selectedLayers[index].layer;\n if (layer instanceof L.Marker) {\n layer.setIcon(L.AwesomeMarkers.icon(marker));\n } else if (layer instanceof L.Polyline ||\n layer instanceof L.Polygon ||\n layer instanceof L.Rectangle ||\n layer instanceof L.Circle) {\n layer.setStyle(style);\n }\n\n }\n\n // .setStyle(style);\n selectedLayers[index]['style'].polygon = style;\n selectedLayers[index]['style'].marker = marker;\n\n}\n\nfunction defaultLayerStyle(t) {\n\n var polygon = new Object;\n var marker = new Object;\n\n if (typeof t.style == \"undefined\") {\n t.style = new Object;\n\n }\n if (typeof t.style.polygon != \"undefined\") {\n polygon = t.style.polygon;\n } else {\n t.style.polygon = new Object;\n }\n\n if (typeof t.style.marker != \"undefined\") {\n marker = t.style.marker;\n } else {\n t.style.marker = new Object;\n }\n\n\n if (typeof polygon.color == \"undefined\") {\n polygon.color = \"#ccc\";\n }\n\n if (typeof polygon.opacity == \"undefined\") {\n polygon.opacity = 1;\n }\n\n if (typeof polygon.fillOpacity == \"undefined\") {\n polygon.fillOpacity = 1;\n }\n\n if (typeof polygon.fillColor == \"undefined\") {\n polygon.fillColor = \"#ccc\";\n }\n\n if (typeof polygon.weight == \"undefined\") {\n polygon.weight = 1;\n }\n\n if (typeof marker.icon == \"undefined\") {\n marker.icon = \"\";\n }\n\n if (typeof marker.color == \"undefined\") {\n marker.color = \"blue\";\n }\n\n t.style.polygon = polygon;\n t.style.marker = marker;\n\n var index = getIndex(selectedLayers, 'unique_id', t.unique_id);\n selectedLayers[index]['style'] = t.style;\n return t;\n}\n\nfunction getLayerIndex1(layer) {\n var len = selectedLayers.length;\n for (i = 0; i < len; i++) {\n if (selectedLayers[i].type == 3 && selectedLayers[i].layer == layer) {\n return i;\n }\n }\n}\n\nfunction between(x, range) {\n x = parseFloat(x);\n var n = range.split('-');\n return x >= n[0] && x <= n[1];\n}\n\nfunction getMarkerStyle(marker) {\n\n if (marker.markerColor == \"\") {\n var marker_color = jQuery('#default_style_marker_color').val();\n console.log(marker_color);\n if (marker_color != \"\") {\n marker.markerColor = marker_color;\n } else {\n marker.markerColor = \"blue\";\n }\n\n }\n\n if (marker.icon == \"\") {\n\n var marker_icon = jQuery('#default_style_marker_icon').val();\n if (marker_icon != \"\") {\n marker.icon = marker_icon;\n } else {\n marker.icon = \"\";\n }\n\n }\n return marker;\n}\n\nfunction update_dirty(index, action) {\n selectedLayers[index].is_dirty = 1;\n if (typeof selectedLayers[index]._id == \"undefined\") {\n if (action == 1 || action == 2) {\n selectedLayers[index].is_dirty = 1;\n } else if (action == 3) {\n selectedLayers.splice(index, 1);\n }\n } else {\n selectedLayers[index].is_dirty = action;\n }\n\n}\nfunction order_current_active_layers() {\n\n activeLayers.sort(sort_value_layer);\n\n var len = activeLayers.length;\n for (i = 0; i < len; i++) {\n activeLayers[i].order = activeLayers[i].order + 1;\n }\n}\n\nfunction add_current_layer_text(t) {\n if (typeof page != \"undefined\" && page == \"user_farm\") {\n var cs_html = document.getElementById('user-farm-active-layers-tmpl').innerHTML;\n Mustache.parse(cs_html);\n\n jQuery('#current-active-layer ul').prepend(Mustache.render(cs_html, t));\n }\n\n}\n\n\nfunction add_sql_legend(t, show) {\n console.log(t);\n if (show == true) {\n if (t.type == 2 && (t.style.type == \"nr\" || t.style.type == \"g\")) {\n\n legend[t.unique_id] = L.control({position: 'bottomright'});\n legend[t.unique_id].onAdd = function (map) {\n\n var div = L.DomUtil.create('div', 'info mapfig-legend');\n div.innerHTML += '<h6 class=\"map-legend-title\">' + t.name + \"</h6>\";\n\n $.each(t.style.custom, function (key, val) {\n\n var icon = val.style.icon;\n\n if (icon.indexOf(\".png\") !== -1) {\n var href = baseURL + \"assets/img/markers/\" + val.style.markerColor + '-' + val.style.icon;\n div.innerHTML += '<div class=\"map-legend\"><img src=\"' + href + '\" height=\"20\"/><div class=\"legend-text\">' + val.val + '</div></div>';\n } else {\n div.innerHTML += '<div class=\"map-legend\"><i class=\"fa fa-map-marker\" style=\"color:' + val.style.markerColor + ' !important\"></i><div class=\"legend-text\">' + val.val + '</div></div>';\n }\n });\n return div;\n };\n\n mymap.addControl(legend[t.unique_id]);\n }\n } else {\n //legend[t.unique_id]).removeFrom(mymap);\n }\n}\n\nfunction runFilterElementJS() {\n\n if (jQuery('.datepicker').length > 0) {\n jQuery('.datepicker').datepicker({\n format: 'yyyy-mm-dd',\n autoclose: true\n });\n }\n\n if (jQuery('.input-daterange').length > 0) {\n $(\".input-daterange input.form-control\").each(function () {\n $self1 = $(this);\n $self1.daterangepicker({\n format: 'YYYY-MM-DD',\n autoclose: true,\n ranges: {\n 'Today': [moment(), moment()],\n 'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],\n 'Last 7 Days': [moment().subtract(6, 'days'), moment()],\n 'Last 30 Days': [moment().subtract(29, 'days'), moment()],\n 'This Month': [moment().startOf('month'), moment().endOf('month')],\n 'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]\n }\n }).on('apply.daterangepicker', function (ev, picker) {\n var startname = $self1.attr(\"data-startname\");\n var endname = $self1.attr(\"data-endname\");\n console.log(startname);\n $self1.parents('.input-daterange:first').find('[name=\"' + startname + '\"]').val(picker.startDate.format('YYYY-MM-DD'));\n $self1.parents('.input-daterange:first').find('[name=\"' + endname + '\"]').val(picker.endDate.format('YYYY-MM-DD'));\n });\n\n });\n\n }\n\n\n if (jQuery('.dbisunique').length > 0) {\n var $dbisunique = jQuery('select.dbisunique');\n $dbisunique.each(function () {\n\n jQuery(this).select2({\n placeholder: \"Select Filter\",\n width: \"100%\"\n });\n });\n }\n}\n\n\nfunction filterGlobalData() {\n\n $.each(selectedLayers, function (key, l) {\n\n if (l.type == 2) {\n\n var data = jQuery('#global_filter').serializeArray();\n data.push({name: \"type\", value: 2});\n data.push({name: \"datasource\", value: l.connection_id});\n data.push({name: \"layer_id\", value: l._id});\n data.push({name: \"map_id\", value: map.id});\n data.push({name: \"_token\", value: jQuery('[name=\"_token\"]').val()});\n data.push({name: \"sql_layer_name\", value: l.name});\n data.push({name: \"query_box\", value: l.query});\n data.push({name: \"cache_key\", value: l.cache_key});\n data.push({name: \"cache_timer\", value: 0});\n\n ajaxRequest('map/layer/json', 'post', 'json', data, function (data) {\n\n if (data.status == \"200\") {\n processSQLJSON(data, l);\n } else {\n showMsg(data.status, data.msg);\n }\n });\n }\n\n })\n\n}\n\n\nfunction clearLayersAndControls(data, t) {\n\n layer = featureGroup[t.unique_id][t.name];\n\n if (layer) {\n layer.clearLayers();\n// if (typeof legend[t.unique_id] != \"undefined\") {\n// legend[t.unique_id].removeFrom(mymap);\n// }\n }\n}\n\nfunction getSQLFeatureData(t) {\n\n var layers = featureGroup[t.unique_id][t.name].getLayers();\n var featuredata = new Array();\n var counter = 0;\n\n $.each(layers, function (key, val) {\n if (typeof t.cluster != \"undefined\" && t.cluster == 1) {\n featuredata[counter++] = val.feature.properties;\n } else {\n val.eachLayer(function (layer) {\n featuredata[counter++] = layer.feature.properties;\n });\n }\n\n });\n\n return featuredata;\n\n}\nvar heatmap = new Array();\nfunction processheatmapJSON(data, t) {\n\n\n// addressPoints = addressPoints.map(function (p) {\n// return [p[0], p[1], parseInt(p[2], 10)];\n// });\n// console.log(addressPoints);\n\n //console.log(featureGroup[t.unique_id][t.name]);\n if (typeof heatmap[t.unique_id] == \"undefined\") {\n heatmap[t.unique_id] = L.heatLayer(data.result, {radius: 30}).addTo(featureGroup[t.unique_id][t.name]);\n } else {\n heatmap[t.unique_id].setLatLngs(data.result).setOptions({radius: 30}).redraw();\n }\n\n}\n\nfunction render_layer_again(t) {\n console.log(t);\n featureGroup[t.unique_id][t.name].clearLayers();\n show_active_layers_flag = false;\n renderLayer(t, '');\n show_active_layers_flag = true;\n}","var pgsql_tmpl;\r\nvar featureGroup = new Array();\r\nvar bounds;\r\nvar layerSelector = new Array();\r\nvar overlays = new Array();\r\nvar mymap;\r\nvar currentBaseMap = new Array();\r\nvar marker_content_tmpl;\r\nvar popupContentId = new Array();\r\nvar drawingGroup;\r\n\r\njQuery(document).ready(function () {\r\n\r\n defaultSettings();\r\n drawingGroup = new L.FeatureGroup();\r\n mymap = L.map('mapid').setView([51.505, -0.09], 13);\r\n\r\n\r\n if (typeof map.settings.base_layer != \"undefined\" && map.settings.base_layer != \"\") {\r\n layername = map.settings.base_layer;\r\n } else if (selectedBaseLayers.length > 0) {\r\n layername = selectedBaseLayers[0]['name'];\r\n } else {\r\n $.each(baseLayers[\"mymap\"], function (layer, value) {\r\n layername = layer;\r\n })\r\n }\r\n \r\n if (isGoogle()){\r\n \r\n currentBaseMap = L.tileLayer('https://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}', {\r\n maxZoom: 20,\r\n subdomains: ['mt0', 'mt1', 'mt2', 'mt3']\r\n }).addTo(mymap);\r\n \r\n\r\n } else {\r\n\r\n currentBaseMap = L.tileLayer(baseLayers['mymap'][layername]._url, {\r\n maxZoom: 18,\r\n attribution: baseLayers['mymap'][layername].options.attribution,\r\n id: baseLayers['mymap'][layername].options.id\r\n }).addTo(mymap);\r\n }\r\n\r\n\r\n layerSelector = L.control.layers({}, {});\r\n\r\n mymap.addControl(layerSelector);\r\n assingSettings();\r\n});\r\n\r\njQuery(document).ready(function () {\r\n initLayer();\r\n\r\n var sqlLayers = getDetailsByAttr(selectedLayers, 'type', 2);\r\n if (sqlLayers.length == 0) {\r\n ajaxLoadSucess();\r\n }\r\n}).ajaxStop(function () {\r\n ajaxLoadSucess();\r\n});\r\n\r\n\r\nfunction ajaxLoadSucess() {\r\n setTimeout(function () {\r\n window.status = \"done\";\r\n jQuery('#ajax-load-check').html(\"ajax-load-done\");\r\n }, 2000)\r\n}\r\n\r\n"]} |