Y-SLD/assets/js/map-598144a0f9.js

3783 lines
160 KiB
JavaScript
Raw Normal View History

2024-03-01 11:23:55 +00:00
toGeoJSON = (function() {
'use strict';
var removeSpace = (/\s*/g),
trimSpace = (/^\s*|\s*$/g),
splitSpace = (/\s+/);
// generate a short, numeric hash of a string
function okhash(x) {
if (!x || !x.length) return 0;
for (var i = 0, h = 0; i < x.length; i++) {
h = ((h << 5) - h) + x.charCodeAt(i) | 0;
} return h;
}
// all Y children of X
function get(x, y) { return x.getElementsByTagName(y); }
function attr(x, y) { return x.getAttribute(y); }
function attrf(x, y) { return parseFloat(attr(x, y)); }
// one Y child of X, if any, otherwise null
function get1(x, y) { var n = get(x, y); return n.length ? n[0] : null; }
// https://developer.mozilla.org/en-US/docs/Web/API/Node.normalize
function norm(el) { if (el.normalize) { el.normalize(); } return el; }
// cast array x into numbers
function numarray(x) {
for (var j = 0, o = []; j < x.length; j++) o[j] = parseFloat(x[j]);
return o;
}
function clean(x) {
var o = {};
for (var i in x) if (x[i]) o[i] = x[i];
return o;
}
// get the content of a text node, if any
function nodeVal(x) {
if (x) { norm(x); }
return (x && x.firstChild && x.firstChild.nodeValue) || '';
}
// get one coordinate from a coordinate array, if any
function coord1(v) { return numarray(v.replace(removeSpace, '').split(',')); }
// get all coordinates from a coordinate array as [[],[]]
function coord(v) {
var coords = v.replace(trimSpace, '').split(splitSpace),
o = [];
for (var i = 0; i < coords.length; i++) {
o.push(coord1(coords[i]));
}
return o;
}
function coordPair(x) {
var ll = [attrf(x, 'lon'), attrf(x, 'lat')],
ele = get1(x, 'ele');
if (ele) ll.push(parseFloat(nodeVal(ele)));
return ll;
}
// create a new feature collection parent object
function fc() {
return {
type: 'FeatureCollection',
features: []
};
}
var serializer;
if (typeof XMLSerializer !== 'undefined') {
serializer = new XMLSerializer();
// only require xmldom in a node environment
} else if (typeof exports === 'object' && typeof process === 'object' && !process.browser) {
serializer = new (require('xmldom').XMLSerializer)();
}
function xml2str(str) { return serializer.serializeToString(str); }
var t = {
kml: function(doc, o) {
o = o || {};
var gj = fc(),
// styleindex keeps track of hashed styles in order to match features
styleIndex = {},
// atomic geospatial types supported by KML - MultiGeometry is
// handled separately
geotypes = ['Polygon', 'LineString', 'Point', 'Track'],
// all root placemarks in the file
placemarks = get(doc, 'Placemark'),
styles = get(doc, 'Style');
for (var k = 0; k < styles.length; k++) {
styleIndex['#' + attr(styles[k], 'id')] = okhash(xml2str(styles[k])).toString(16);
}
for (var j = 0; j < placemarks.length; j++) {
gj.features = gj.features.concat(getPlacemark(placemarks[j]));
}
function kmlColor(v) {
var color, opacity;
v = v || "";
if (v.substr(0, 1) === "#") v = v.substr(1);
if (v.length === 6 || v.length === 3) color = v;
if (v.length === 8) {
opacity = parseInt(v.substr(0, 2), 16) / 255;
color = v.substr(2);
}
return [color, isNaN(opacity) ? undefined : opacity];
}
function gxCoord(v) { return numarray(v.split(' ')); }
function gxCoords(root) {
var elems = get(root, 'coord', 'gx'), coords = [];
for (var i = 0; i < elems.length; i++) coords.push(gxCoord(nodeVal(elems[i])));
return coords;
}
function getGeometry(root) {
var geomNode, geomNodes, i, j, k, geoms = [];
if (get1(root, 'MultiGeometry')) return getGeometry(get1(root, 'MultiGeometry'));
if (get1(root, 'MultiTrack')) return getGeometry(get1(root, 'MultiTrack'));
for (i = 0; i < geotypes.length; i++) {
geomNodes = get(root, geotypes[i]);
if (geomNodes) {
for (j = 0; j < geomNodes.length; j++) {
geomNode = geomNodes[j];
if (geotypes[i] == 'Point') {
geoms.push({
type: 'Point',
coordinates: coord1(nodeVal(get1(geomNode, 'coordinates')))
});
} else if (geotypes[i] == 'LineString') {
geoms.push({
type: 'LineString',
coordinates: coord(nodeVal(get1(geomNode, 'coordinates')))
});
} else if (geotypes[i] == 'Polygon') {
var rings = get(geomNode, 'LinearRing'),
coords = [];
for (k = 0; k < rings.length; k++) {
coords.push(coord(nodeVal(get1(rings[k], 'coordinates'))));
}
geoms.push({
type: 'Polygon',
coordinates: coords
});
} else if (geotypes[i] == 'Track') {
geoms.push({
type: 'LineString',
coordinates: gxCoords(geomNode)
});
}
}
}
}
return geoms;
}
function getPlacemark(root) {
var geoms = getGeometry(root), i, properties = {},
name = nodeVal(get1(root, 'name')),
styleUrl = nodeVal(get1(root, 'styleUrl')),
description = nodeVal(get1(root, 'description')),
timeSpan = get1(root, 'TimeSpan'),
extendedData = get1(root, 'ExtendedData'),
lineStyle = get1(root, 'LineStyle'),
polyStyle = get1(root, 'PolyStyle');
if (!geoms.length) return [];
if (name) properties.name = name;
if (styleUrl && styleIndex[styleUrl]) {
properties.styleUrl = styleUrl;
properties.styleHash = styleIndex[styleUrl];
}
if (description) properties.description = description;
if (timeSpan) {
var begin = nodeVal(get1(timeSpan, 'begin'));
var end = nodeVal(get1(timeSpan, 'end'));
properties.timespan = { begin: begin, end: end };
}
if (lineStyle) {
var linestyles = kmlColor(nodeVal(get1(lineStyle, 'color'))),
color = linestyles[0],
opacity = linestyles[1],
width = parseFloat(nodeVal(get1(lineStyle, 'width')));
if (color) properties.stroke = color;
if (!isNaN(opacity)) properties['stroke-opacity'] = opacity;
if (!isNaN(width)) properties['stroke-width'] = width;
}
if (polyStyle) {
var polystyles = kmlColor(nodeVal(get1(polyStyle, 'color'))),
pcolor = polystyles[0],
popacity = polystyles[1],
fill = nodeVal(get1(polyStyle, 'fill')),
outline = nodeVal(get1(polyStyle, 'outline'));
if (pcolor) properties.fill = pcolor;
if (!isNaN(popacity)) properties['fill-opacity'] = popacity;
if (fill) properties['fill-opacity'] = fill === "1" ? 1 : 0;
if (outline) properties['stroke-opacity'] = outline === "1" ? 1 : 0;
}
if (extendedData) {
var datas = get(extendedData, 'Data'),
simpleDatas = get(extendedData, 'SimpleData');
for (i = 0; i < datas.length; i++) {
properties[datas[i].getAttribute('name')] = nodeVal(get1(datas[i], 'value'));
}
for (i = 0; i < simpleDatas.length; i++) {
properties[simpleDatas[i].getAttribute('name')] = nodeVal(simpleDatas[i]);
}
}
return [{
type: 'Feature',
geometry: (geoms.length === 1) ? geoms[0] : {
type: 'GeometryCollection',
geometries: geoms
},
properties: properties
}];
}
return gj;
},
gpx: function(doc, o) {
var i,
tracks = get(doc, 'trk'),
routes = get(doc, 'rte'),
waypoints = get(doc, 'wpt'),
// a feature collection
gj = fc();
for (i = 0; i < tracks.length; i++) {
gj.features.push(getTrack(tracks[i]));
}
for (i = 0; i < routes.length; i++) {
gj.features.push(getRoute(routes[i]));
}
for (i = 0; i < waypoints.length; i++) {
gj.features.push(getPoint(waypoints[i]));
}
function getPoints(node, pointname) {
var pts = get(node, pointname), line = [];
for (var i = 0; i < pts.length; i++) {
line.push(coordPair(pts[i]));
}
return line;
}
function getTrack(node) {
var segments = get(node, 'trkseg'), track = [];
for (var i = 0; i < segments.length; i++) {
track.push(getPoints(segments[i], 'trkpt'));
}
return {
type: 'Feature',
properties: getProperties(node),
geometry: {
type: track.length === 1 ? 'LineString' : 'MultiLineString',
coordinates: track.length === 1 ? track[0] : track
}
};
}
function getRoute(node) {
return {
type: 'Feature',
properties: getProperties(node),
geometry: {
type: 'LineString',
coordinates: getPoints(node, 'rtept')
}
};
}
function getPoint(node) {
var prop = getProperties(node);
prop.sym = nodeVal(get1(node, 'sym'));
return {
type: 'Feature',
properties: prop,
geometry: {
type: 'Point',
coordinates: coordPair(node)
}
};
}
function getProperties(node) {
var meta = ['name', 'desc', 'author', 'copyright', 'link',
'time', 'keywords'],
prop = {},
k;
for (k = 0; k < meta.length; k++) {
prop[meta[k]] = nodeVal(get1(node, meta[k]));
}
return clean(prop);
}
return gj;
}
};
return t;
})();
if (typeof module !== 'undefined') module.exports = toGeoJSON;
(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={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"};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"/":sectio
// Underscore.js 1.8.3
// http://underscorejs.org
// (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
// Underscore may be freely distributed under the MIT license.
(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&&
//# sourceMappingURL=underscore-min.map
var legend = new Array();
var activeLayers = new Array();
var show_active_layers_flag = true;
function toWKT(layer) {
var lng, lat, coords = [];
if (layer instanceof L.Polygon || layer instanceof L.Polyline) {
var latlngs = layer.getLatLngs();
for (var i = 0; i < latlngs.length; i++) {
latlngs[i]
coords.push(latlngs[i].lng + " " + latlngs[i].lat);
if (i === 0) {
lng = latlngs[i].lng;
lat = latlngs[i].lat;
}
}
;
if (layer instanceof L.Polygon) {
return "POLYGON((" + coords.join(",") + "," + lng + " " + lat + "))";
} else if (layer instanceof L.Polyline) {
return "LINESTRING(" + coords.join(",") + ")";
}
} else if (layer instanceof L.Marker) {
return "POINT(" + layer.getLatLng().lng + " " + layer.getLatLng().lat + ")";
}
}
jQuery(document).ready(function () {
L.TileLayer.BetterWMS = L.TileLayer.WMS.extend({
onAdd: function (map) {
// Triggered when the layer is added to a map.
// Register a click listener, then do all the upstream WMS things
L.TileLayer.WMS.prototype.onAdd.call(this, map);
map.on('click', this.getFeatureInfo, this);
},
onRemove: function (map) {
// Triggered when the layer is removed from a map.
// Unregister a click listener, then do all the upstream WMS things
L.TileLayer.WMS.prototype.onRemove.call(this, map);
map.off('click', this.getFeatureInfo, this);
},
getFeatureInfo: function (evt) {
// Make an AJAX request to the server and hope for the best
var url = this.getFeatureInfoUrl(evt.latlng),
showResults = L.Util.bind(this.showGetFeatureInfo, this);
$.ajax({
url: url,
success: function (data, status, xhr) {
var err = typeof data === 'string' ? null : data;
showResults(err, evt.latlng, data);
},
error: function (xhr, status, error) {
showResults(error);
}
});
},
getFeatureInfoUrl: function (latlng) {
//console.log(this.wmsParams.srs1);
// Construct a GetFeatureInfo request URL given a point
var point = this._map.latLngToContainerPoint(latlng, this._map.getZoom()),
size = this._map.getSize();
var ltype = this.wmsParams.layer_type;
var format = "application/json";
if (ltype == 4) {
format = "text/html";
}
var params = {
request: 'GetFeatureInfo',
service: 'WMS',
//srs: this.wmsParams.srs1,
srs: 'EPSG:4326',
styles: this.wmsParams.styles,
transparent: this.wmsParams.transparent,
version: this.wmsParams.version,
format: this.wmsParams.format,
// bbox: this._map.getBounds().toBBoxString(),
height: size.y,
width: size.x,
layers: this.wmsParams.layers,
query_layers: this.wmsParams.layers,
info_format: format
};
params[params.version === '1.3.0' ? 'i' : 'x'] = point.x;
params[params.version === '1.3.0' ? 'j' : 'y'] = point.y;
return this._url + L.Util.getParamString(params, this._url, true);
},
showGetFeatureInfo: function (err, latlng, content) {
// console.log(err);
// console.log(this.wmsParams.keyname);
// don't open again....
// if (err) {
// console.log(err);
// return;
// } // do nothing if there's an error
// console.log(content);
console.log(content);
var index = getIndex(selectedLayers, 'unique_id', this.wmsParams.unique_id);
var popupContent = "";
if (selectedLayers[index].type == 1) {
if (!content.features || content.features.length == 0) {
return;
}
popupContent = getPopupContent(content, selectedLayers[index].pc);
} else {
if (jQuery(content).find("tr").length < 2) {
return;
}
popupContent = content;
}
// Otherwise show the content in a popup, or something.
L.popup({maxWidth: 'auto'})
.setLatLng(latlng)
.setContent(popupContent)
.openOn(this._map);
// if (selectedLayers[index].type == 4) {
// $('.leaflet-popup-content-wrapper').find('table').addClass("table");
// }
}
});
L.tileLayer.betterWms = function (url, options) {
return new L.TileLayer.BetterWMS(url, options);
};
L.Icon.Default.imagePath = baseURL + "/assets/plugins/leaflet/images";
L.AwesomeMarkers.Icon.prototype.options.prefix = 'fa';
})
function renderLayer(t, data) {
if (typeof featureGroup[t.unique_id] == "undefined") {
featureGroup[t.unique_id] = new Array();
}
if (t.type == 2 && (typeof t.cluster != "undefined" && t.cluster == 1)) {
featureGroup[t.unique_id][t.name] = new L.MarkerClusterGroup();
} else {
featureGroup[t.unique_id][t.name] = new L.FeatureGroup();
}
console.log(t.settings);
if (typeof t.settings != "undefined") {
if (t.settings.active == 1) {
add_current_layer_text(t);
featureGroup[t.unique_id][t.name].addTo(mymap);
} else {
t.settings.active = 0;
}
} else {
featureGroup[t.unique_id][t.name].addTo(mymap);
t.settings = new Object;
t.settings.active = 1;
}
if (t.settings.active == 1) {
activeLayers.push({id: t._id, order: 0});
order_current_active_layers();
}
if (typeof page != "undefined" && page == "phantom") {
console.log("added" + t._id);
if ($.inArray(t._id, active_ids) !== -1) {
// console.log(t.settings.active);
// if(t.settings.active == 0){
console.log("added");
featureGroup[t.unique_id][t.name].addTo(mymap);
//}
} else if (t.settings.active == 1) {
console.log("not added");
mymap.removeLayer(featureGroup[t.unique_id][t.name]);
}
}
if (typeof page != "undefined" && page == "user_farm") {
if (t.settings.active == 1 && show_active_layers_flag == true) {
jQuery('#chk_' + t.unique_id).prop("checked", "checked");
}
}
if (typeof page != "undefined" && page == "manage" && show_active_layers_flag == true) {
//jQuery('#active-layers-container').append(Mustache.render(tmpl.activeLayer, t));
jQuery('#active-layers-container .media-list').append(Mustache.render(tmpl.activeLayer, {t: t, type: layerType[t.type]}));
if (t.settings.active == 0) {
jQuery('#at-' + t.unique_id + " a.dropdown-toggle span").addClass("label-danger").removeClass("label-primary");
}
jQuery('.help-active-popup-hover').popover({
title: 'Active & In-Active',
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>',
html: true,
trigger: 'hover',
container: 'body'
});
jQuery('.at_active_chk').bootstrapSwitch({
size: 'mini',
onSwitchChange: function (event, state) {
event.preventDefault();
var self = jQuery(this).parents(".active-layer-action:first");
var key = self.attr("data-id");
var index = getIndex(selectedLayers, 'unique_id', key);
if (!selectedLayers[index].settings && typeof selectedLayers[index].settings == "undefined") {
selectedLayers[index].settings = new Object;
}
update_dirty(index);
if (state === true) {
selectedLayers[index].settings.active = 1;
jQuery('#at-' + t.unique_id + " a.dropdown-toggle span").removeClass("label-danger").addClass("label-primary");
mymap.addLayer(featureGroup[key][selectedLayers[index].name]);
} else {
selectedLayers[index].settings.active = 0;
jQuery('#at-' + t.unique_id + " a.dropdown-toggle span").addClass("label-danger").removeClass("label-primary");
mymap.removeLayer(featureGroup[key][selectedLayers[index].name]);
}
calculateBounds();
}
});
}
if (t.type == 1 || t.type == 4) {
// 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]])
// .addTo(featureGroup[t.unique_id][t.name]);
// console.log(t.SRS);
var options = {
format: 'image/png',
layers: t.Name,
transparent: true,
crs: L.CRS.EPSG4326,
unique_id: t.unique_id,
srs1: t.SRS,
layer_type: t.type
};
if (typeof t.geometry_area != "undefined") {
options.geometry = t.geometry_area;
}
if (typeof t.time != "undefined") {
options.time = t.time;
}
L.tileLayer.betterWms(t.url, options).addTo(featureGroup[t.unique_id][t.name]);
} else if (t.type == 2) {
//check data is coming
if (data == "") {
if (page == "phantom") {
filterGlobalData();
} else {
if (!t.cache_timer && typeof t.cache_timer == "undefined") {
t.cache_timer = 15;
}
data = {
datasource: t.connection_id,
sql_layer_name: t.name,
"query_box": t.query,
"_token": jQuery('[name="_token"]').val(),
"cache_key": t.cache_key,
"cache_timer": t.cache_timer,
"type": 2,
"map_id": map.id
};
ajaxRequest('map/layer/json', 'post', 'json', data, function (data) {
if (data.status == "200") {
processSQLJSON(data, t);
} else {
showMsg(data.status, data.msg);
}
});
}
} else {
processSQLJSON(data, t);
}
} else if (t.type == 3) {
}
overlayers_controls(t);
overlays[t.name] = featureGroup[t.unique_id][t.name];
layerSelector.addOverlay(featureGroup[t.unique_id][t.name], t.name);
if (t.type == 3) {
jQuery('#at-' + t.unique_id).find('.style-at-layer').remove();
}
calculateBounds();
}
function getPopupContent(content, defined_content) {
// var featuresHTML = defined_content;
$.each(content.features, function (key, feature) {
//featuresHTML += '<div class="row"><div class="col-md-12"><h4>' + feature.id + '</h4><ul class="map-popup-feature-lists">';
$.each(feature.properties, function (key, value) {
defined_content = defined_content.replace("&lt;" + key + "&gt;", value);
//featuresHTML = '<li>' + key + ' : ' + value + '</li>';
});
//featuresHTML += "</ul></div></div>";
})
return defined_content;
}
function processSQLJSON(data, t) {
t = defaultLayerStyle(t);
if (data.more_data.sql_type == 3) {
processheatmapJSON(data, t);
} else {
clearLayersAndControls(data, t);
jQuery.each(data.result, function (name, json) {
L.geoJson(json, {
onEachFeature: function (feature, layer) {
if (layer instanceof L.Marker) {
var found = false;
if (t.style.type == "nr") {
$.each(t.style.custom, function (key, val) {
if (between(feature.properties[t.style.field], val.val)) {
found = true;
layer.setIcon(L.AwesomeMarkers.icon(val.style));
return false;
}
})
} else if (t.style.type == "g") {
$.each(t.style.custom, function (key, val) {
if (feature.properties[t.style.field] == val.val) {
found = true;
layer.setIcon(L.AwesomeMarkers.icon(val.style));
return false;
}
});
}
if (found == false) {
layer.setIcon(L.AwesomeMarkers.icon(t.style.marker));
}
}
// if (layer instanceof L.Marker) {
// layer.setIcon(L.AwesomeMarkers.icon(t.style.marker));
// }
layer.on('click', function (e) {
var c = getSQLPopupContent(feature.properties, t.pc);
layer.bindPopup(c);
// if (layer instanceof L.Marker) {
// var popup = L.popup();
// popup.setLatLng(layer.getLatLng());
// popup.setContent(c);
// mymap.openPopup(popup);
// } else {
// var bounds = layer.getBounds();
// var popup = L.popup();
// popup.setLatLng(bounds.getCenter());
// popup.setContent(c);
// mymap.openPopup(popup);
// }
})
},
style: function (feature, layer) {
return t.style.polygon;
}
}).addTo(featureGroup[t.unique_id][t.name]);
mymap.fitBounds(featureGroup[t.unique_id][t.name].getBounds());
});
}
}
function initLayer() {
selectedLayers.sort(sort_value_layer);
if (selectedBaseLayers.length > 0) {
jQuery('#visiable-layers').find('.baselayers-control').removeClass("hide");
}
jQuery.each(selectedBaseLayers, function (key, value) {
layerSelector.addBaseLayer(baseLayers['mymap'][value.name], value.name);
baselayers_controls(value.name);
if (typeof page != "undefined" && page == "manage") {
//alert(page);
var ls = jQuery('#base_layer_selection').find('input:checkbox[data-name="' + value.name + '"]');
if (ls.length > 0) {
ls.prop("checked", "checked");
baseLayerMap(ls, false);
}
}
})
jQuery.each(selectedLayers, function (key, value) {
renderLayer(value, '');
})
//look for custom layers
var data = {
"type": 3,
"id": map.id,
"_token": jQuery('[name="_token"]').val(),
}
ajaxRequest('map/layer/json', 'post', 'json', data, function (data) {
if (data.status == "200") {
processFreeHand(data);
} else {
showMsg(data.status, data.msg);
}
});
}
function processFreeHand(cl) {
jQuery.each(cl.result, function (name, json) {
index = getIndex(selectedLayers, 'unique_id', name);
t = selectedLayers[index];
if (typeof featureGroup[t.unique_id] == "undefined") {
featureGroup[t.unique_id] = new Array();
}
featureGroup[t.unique_id][t.name] = new L.FeatureGroup();
if (typeof t.settings != "undefined") {
if (t.settings.active == 1) {
featureGroup[t.unique_id][t.name].addTo(mymap);
} else {
t.settings.active = 0;
}
} else {
featureGroup[t.unique_id][t.name].addTo(mymap);
t.settings = new Object;
t.settings.active = 1;
}
//featureGroup[t.unique_id][t.name].addTo(mymap);
L.geoJson(json, {
onEachFeature: function (feature, layer) {
selectedLayers[index].layer = layer;
if (t.settings.active == 1) {
drawingGroup.addLayer(layer);
}
featureGroup[t.unique_id][t.name].addLayer(layer);
if (layer instanceof L.Marker) {
layer.setIcon(L.AwesomeMarkers.icon(selectedLayers[index].style.marker));
}
layer.bindPopup(selectedLayers[index].pc);
// layer.on("click", function () {
// var index = getLayerIndex1(layer);
// if (layer instanceof L.Marker) {
// var popup = L.popup();
// popup.setLatLng(layer.getLatLng());
// popup.setContent(selectedLayers[index].pc);
// mymap.openPopup(popup);
// } else {
// var bounds = layer.getBounds();
// var popup = L.popup();
// popup.setLatLng(bounds.getCenter());
// popup.setContent(selectedLayers[index].pc);
// mymap.openPopup(popup);
// }
// });
},
style: function (feature, layer) {
return t.style.polygon;
},
pointToLayer: function (feature, latlng) {
//console.log(feature);
if (typeof t.radius != "undefined") {
return L.circle(latlng, parseInt(t.radius, 10));
} else {
return L.marker(latlng);
}
},
})
});
calculateBounds();
}
function calculateBounds() {
bounds = true;
jQuery.each(selectedLayers, function (key, g) {
if (typeof g.settings.active == "undefined" || g.settings.active == 1) {
if (g.type == 1 || (g.type == 4 && typeof g.geometry_area == "undefined")) {
// if (bounds != true) {
// // console.log("inside");
// bounds.extend([parseFloat(g['LatLonBoundingBox']['@attributes']['miny']), parseFloat(g['LatLonBoundingBox']['@attributes']['minx'])], [parseFloat(g['LatLonBoundingBox']['@attributes']['maxy']), parseFloat(g['LatLonBoundingBox']['@attributes']['maxx'])]);
//
// bounds = L.latLngBounds([parseFloat(g['LatLonBoundingBox']['@attributes']['miny']), parseFloat(g['LatLonBoundingBox']['@attributes']['minx'])], [parseFloat(g['LatLonBoundingBox']['@attributes']['maxy']), parseFloat(g['LatLonBoundingBox']['@attributes']['maxx'])]);
//
// } else {
// if(typeof g['LatLonBoundingBox'] != "undefined"){
// bounds = L.latLngBounds([parseFloat(g['LatLonBoundingBox']['@attributes']['miny']), parseFloat(g['LatLonBoundingBox']['@attributes']['minx'])], [parseFloat(g['LatLonBoundingBox']['@attributes']['maxy']), parseFloat(g['LatLonBoundingBox']['@attributes']['maxx'])]);
// } else if(typeof g['BoundingBox'] != "undefined"){
// bounds = L.latLngBounds([parseFloat(g['BoundingBox']['@attributes']['miny']), parseFloat(g['BoundingBox']['@attributes']['minx'])], [parseFloat(g['BoundingBox']['@attributes']['maxy']), parseFloat(g['BoundingBox']['@attributes']['maxx'])]);
// }
// }
}
if (g.type == 3) {
if (typeof featureGroup[g.unique_id] != "undefined" && typeof featureGroup[g.unique_id][g.name] != "undefined") {
var layer1 = featureGroup[g.unique_id][g.name];
if (bounds != true) {
var b1 = layer1.getBounds();
if (typeof b1._southWest != "undefined") {
bounds.extend(layer1.getBounds());
}
} else {
var b1 = layer1.getBounds();
if (typeof b1._southWest != "undefined") {
console.log("checked");
bounds = b1;
}
}
}
}
}
})
// $.each(featureGroup, function (l, layer) {
// if (bounds != true) {
// // console.log("inside");
// bounds.extend(layer.getBounds());
// } else {
// bounds = layer.getBounds();
// }
// })
//
if (bounds !== true) {
mymap.fitBounds(bounds);
}
}
function getLayersIndex(id) {
var len = selectedLayers.length;
for (i = 0; i < len; i++) {
if (selectedLayers[i].unique_id == id) {
return i;
}
}
}
function getIndex(obj, key, value) {
var len = obj.length;
for (i = 0; i < len; i++) {
if (obj[i][key] == value) {
return i;
}
}
}
function getSQLPopupContent(properties, defined_content) {
// var featuresHTML = defined_content;
$.each(properties, function (key, value) {
if (value.match(/\.(jpeg|jpg|gif|png)$/) != null) {
console.log(value);
var image = '<img src="' + value + '" style="height:50px;width:50px;"/>';
defined_content = defined_content.replace("&lt;" + key + "&gt;", image);
} else {
defined_content = defined_content.replace("&lt;" + key + "&gt;", value);
}
});
//featuresHTML += "</ul></div></div>";
return defined_content;
}
function defaultSettings() {
map.settings = map.settings != "" ? JSON.parse(map.settings) : new Object;
if (typeof map.settings.width == "undefined") {
map.settings.width = 500;
}
if (typeof map.settings.height == "undefined") {
map.settings.height = 500;
}
if (typeof map.settings.zoom == "undefined") {
map.settings.zoom = 6;
}
if (typeof map.settings.fullscreen == "undefined") {
map.settings.fullscreen = 1;
}
if (typeof map.settings.https == "undefined") {
map.settings.https = 1;
}
}
function assingSettings() {
// mymap.setZoom(map.settings.zoom);
}
function saveMapData(type, callback) {
var len = selectedLayers.length;
var jt = new Array();
for (i = 0; i < len; i++) {
if (typeof selectedLayers[i].is_dirty != "undefined") {
if (typeof selectedLayers[i].boundary_id != "undefined" && typeof selectedLayers[i].geometry_area != "undefined") {
selectedLayers[i].geometry_area = "";
}
var s = jQuery.extend(true, {}, selectedLayers[i]);
if (s.type == 3) {
if (s.layer instanceof L.Circle) {
s.radius = s.layer.getRadius();
}
s.layer = s.layer.toGeoJSON();
}
jt.push(s);
}
}
var t = {
"selectedLayers": jt,
"selectedBaseLayers": selectedBaseLayers
}
jQuery('#action_type').val(type);
var json = JSON.stringify(t);
jQuery('#layer_json').val(json);
var formdata = jQuery('#layer-form, #map-settings-form').serialize();
ajaxRequest('/developer/map/save', 'post', 'json', formdata, function (data) {
if (data.status == 200) {
jQuery('#map_id').val(data.map_id);
// window.location = baseURL + "/developer/map/edit/" + data.map_id;
//showMsg(data.action, data.msg);
$.each(selectedLayers, function (key, value) {
selectedLayers[key].is_dirty = undefined;
if (typeof selectedLayers[key]._id == "undefined") {
selectedLayers[key]._id = data.mapping_array[value.unique_id];
}
})
callback(data);
} else {
showMsg("error", data.msg);
}
})
}
function sortLayers() {
var all_id = new Array();
var i = 0;
$("#visiable-layers div.dropdown-menu .custom-control-layers").find('li').each(function (i) {
var id = $(this).attr("data-key");
all_id[i] = id;
i++;
});
$.each(all_id, function (index1, value) {
var index = getIndex(selectedLayers, 'unique_id', value);
selectedLayers[index].order = index1 + 1;
});
// $.ajax({
// type: "POST",
// url: "{{URL::action('Superadmin\LayersController@postSetOrder')}}",
// data: {'data_id': all_id}
// }).done(function(data) {
// alert("Order set successfully.");
// });
}
function overlayers_controls(t) {
var temp = document.getElementById('map-overlayer-controls-tmpl').innerHTML;
Mustache.parse(temp);
// var html = "";
if (t.type == 2 && (t.style.type == "nr" || t.style.type == "g")) {
var temp2 = document.getElementById('map-overlayer-submenu-controls-tmpl').innerHTML;
Mustache.parse(temp2);
$("<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");
addSubOverLayer(t);
} else {
$("<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) {
event.preventDefault();
var self = jQuery(this).parents("li:first");
var key = self.attr("data-key");
var name = self.attr("data-name");
var index = getIndex(selectedLayers, 'unique_id', key);
var t = selectedLayers[index];
// if (t.type == 3) {
//
// if (state === true) {
//
// var layers = featureGroup[key][name];
// console.log(layers);
// // $.each(layers, function (key, val) {
//
// drawingGroup.addLayer(layers);
// // });
//
// }else{
// var layers = featureGroup[key][name];
// //$.each(layers, function (key, val) {
// drawingGroup.removeLayer(layers);
// //});
// }
// } else {
if (state === true) {
mymap.addLayer(featureGroup[key][name]);
} else {
mymap.removeLayer(featureGroup[key][name]);
}
// }
}
});
}
if (typeof page != "undefined" && page == "manage") {
// $("#visiable-layers div.dropdown-menu .custom-control-layers").sortable({
// // helper: fixHelperModified,
// stop: sortLayers,
// // helper: 'clone'
// // cursorAt: {left:0, top:0}
// //connectWith: "table"
// }).disableSelection();
}
}
function addSubOverLayer(t) {
var $vl = jQuery('li[data-key="' + t.unique_id + '"]');
var temp1 = document.getElementById('map-overlayer-sub-controls-tmpl').innerHTML;
// html = '<ul class="nav custom-control-layers ui-sortable sub-overlayers-control"></ul>';
//$vl.append(html);
$.each(t.style.custom, function (index, val) {
$("<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) {
event.preventDefault();
var self = jQuery(this).parents("li:first");
var key = self.attr("data-key");
var name = self.attr("data-name");
var val = self.attr("data-val");
var index = getIndex(selectedLayers, 'unique_id', key);
var t = selectedLayers[index];
var layers = featureGroup[key][name].getLayers();
$.each(layers, function (key1, val1) {
val1.eachLayer(function (layer) {
if (t.style.type == "nr") {
if (between(layer.feature.properties[t.style.field], val)) {
if (state === true) {
mymap.addLayer(layer);
} else {
mymap.removeLayer(layer);
}
}
} else if (t.style.type == "g") {
if (layer.feature.properties[t.style.field] == val) {
if (state === true) {
mymap.addLayer(layer);
} else {
mymap.removeLayer(layer);
}
}
}
});
});
}
});
})
jQuery('.subcontrol-layer-action').slimScroll({
alwaysVisible: true,
height: 100
});
jQuery('.submenu-overlay-controls').click(function (e) {
e.preventDefault();
var $self = jQuery(this);
$self.toggleClass("in");
var d = $($self.attr("href"));
if (d.hasClass("in")) {
d.collapse("hide");
} else {
d.collapse("show");
}
return false;
})
}
function baselayers_controls(name) {
var temp = document.getElementById('map-baselayer-controls-tmpl').innerHTML;
Mustache.parse(temp);
$("<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) {
event.preventDefault();
var self = jQuery(this).parents("li:first");
var name = self.attr("data-name");
$.each(baseLayers["mymap"], function (name, value) {
console.log(name);
mymap.removeLayer(baseLayers["mymap"][name]);
})
if (state === true) {
mymap.addLayer(baseLayers["mymap"][name]);
}
}});
}
function removeOverlayerControl(gskey) {
jQuery('#visiable-layers').find('.overlay_control_' + gskey).remove();
}
function applyLiveStyle(type) {
var my_unique_id = jQuery('#map-sidebar-container [name="my_unique_id"]').val();
var index = getIndex(selectedLayers, 'unique_id', my_unique_id);
update_dirty(index, 2);
var style = {};
jQuery('#layer-polygon-styling input').each(function () {
var $self = jQuery(this);
style[$self.attr("name")] = $self.val();
})
var marker = {};
jQuery('#layer-marker-styling .default-marker-style select').each(function () {
var $self = jQuery(this);
marker[$self.attr("data-name")] = $self.val();
})
if (selectedLayers[index].type == 2) {
var layers = featureGroup[selectedLayers[index].unique_id][selectedLayers[index].name].getLayers();
$.each(layers, function (key, val) {
val.eachLayer(function (layer) {
if (layer instanceof L.Marker) {
layer.setIcon(L.AwesomeMarkers.icon(marker));
} else if (layer instanceof L.Polyline ||
layer instanceof L.Polygon ||
layer instanceof L.Rectangle ||
layer instanceof L.Circle) {
layer.setStyle(style);
}
});
});
} else if (selectedLayers[index].type == 3) {
var layer = selectedLayers[index].layer;
if (layer instanceof L.Marker) {
layer.setIcon(L.AwesomeMarkers.icon(marker));
} else if (layer instanceof L.Polyline ||
layer instanceof L.Polygon ||
layer instanceof L.Rectangle ||
layer instanceof L.Circle) {
layer.setStyle(style);
}
}
// .setStyle(style);
selectedLayers[index]['style'].polygon = style;
selectedLayers[index]['style'].marker = marker;
}
function defaultLayerStyle(t) {
var polygon = new Object;
var marker = new Object;
if (typeof t.style == "undefined") {
t.style = new Object;
}
if (typeof t.style.polygon != "undefined") {
polygon = t.style.polygon;
} else {
t.style.polygon = new Object;
}
if (typeof t.style.marker != "undefined") {
marker = t.style.marker;
} else {
t.style.marker = new Object;
}
if (typeof polygon.color == "undefined") {
polygon.color = "#ccc";
}
if (typeof polygon.opacity == "undefined") {
polygon.opacity = 1;
}
if (typeof polygon.fillOpacity == "undefined") {
polygon.fillOpacity = 1;
}
if (typeof polygon.fillColor == "undefined") {
polygon.fillColor = "#ccc";
}
if (typeof polygon.weight == "undefined") {
polygon.weight = 1;
}
if (typeof marker.icon == "undefined") {
marker.icon = "";
}
if (typeof marker.color == "undefined") {
marker.color = "blue";
}
t.style.polygon = polygon;
t.style.marker = marker;
var index = getIndex(selectedLayers, 'unique_id', t.unique_id);
selectedLayers[index]['style'] = t.style;
return t;
}
function getLayerIndex1(layer) {
var len = selectedLayers.length;
for (i = 0; i < len; i++) {
if (selectedLayers[i].type == 3 && selectedLayers[i].layer == layer) {
return i;
}
}
}
function between(x, range) {
x = parseFloat(x);
var n = range.split('-');
return x >= n[0] && x <= n[1];
}
function getMarkerStyle(marker) {
if (marker.markerColor == "") {
var marker_color = jQuery('#default_style_marker_color').val();
console.log(marker_color);
if (marker_color != "") {
marker.markerColor = marker_color;
} else {
marker.markerColor = "blue";
}
}
if (marker.icon == "") {
var marker_icon = jQuery('#default_style_marker_icon').val();
if (marker_icon != "") {
marker.icon = marker_icon;
} else {
marker.icon = "";
}
}
return marker;
}
function update_dirty(index, action) {
selectedLayers[index].is_dirty = 1;
if (typeof selectedLayers[index]._id == "undefined") {
if (action == 1 || action == 2) {
selectedLayers[index].is_dirty = 1;
} else if (action == 3) {
selectedLayers.splice(index, 1);
}
} else {
selectedLayers[index].is_dirty = action;
}
}
function order_current_active_layers() {
activeLayers.sort(sort_value_layer);
var len = activeLayers.length;
for (i = 0; i < len; i++) {
activeLayers[i].order = activeLayers[i].order + 1;
}
}
function add_current_layer_text(t) {
if (typeof page != "undefined" && page == "user_farm") {
var cs_html = document.getElementById('user-farm-active-layers-tmpl').innerHTML;
Mustache.parse(cs_html);
jQuery('#current-active-layer ul').prepend(Mustache.render(cs_html, t));
}
}
function add_sql_legend(t, show) {
console.log(t);
if (show == true) {
if (t.type == 2 && (t.style.type == "nr" || t.style.type == "g")) {
legend[t.unique_id] = L.control({position: 'bottomright'});
legend[t.unique_id].onAdd = function (map) {
var div = L.DomUtil.create('div', 'info mapfig-legend');
div.innerHTML += '<h6 class="map-legend-title">' + t.name + "</h6>";
$.each(t.style.custom, function (key, val) {
var icon = val.style.icon;
if (icon.indexOf(".png") !== -1) {
var href = baseURL + "assets/img/markers/" + val.style.markerColor + '-' + val.style.icon;
div.innerHTML += '<div class="map-legend"><img src="' + href + '" height="20"/><div class="legend-text">' + val.val + '</div></div>';
} else {
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>';
}
});
return div;
};
mymap.addControl(legend[t.unique_id]);
}
} else {
//legend[t.unique_id]).removeFrom(mymap);
}
}
function runFilterElementJS() {
if (jQuery('.datepicker').length > 0) {
jQuery('.datepicker').datepicker({
format: 'yyyy-mm-dd',
autoclose: true
});
}
if (jQuery('.input-daterange').length > 0) {
$(".input-daterange input.form-control").each(function () {
$self1 = $(this);
$self1.daterangepicker({
format: 'YYYY-MM-DD',
autoclose: true,
ranges: {
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
}
}).on('apply.daterangepicker', function (ev, picker) {
var startname = $self1.attr("data-startname");
var endname = $self1.attr("data-endname");
console.log(startname);
$self1.parents('.input-daterange:first').find('[name="' + startname + '"]').val(picker.startDate.format('YYYY-MM-DD'));
$self1.parents('.input-daterange:first').find('[name="' + endname + '"]').val(picker.endDate.format('YYYY-MM-DD'));
});
});
}
if (jQuery('.dbisunique').length > 0) {
var $dbisunique = jQuery('select.dbisunique');
$dbisunique.each(function () {
jQuery(this).select2({
placeholder: "Select Filter",
width: "100%"
});
});
}
}
function filterGlobalData() {
$.each(selectedLayers, function (key, l) {
if (l.type == 2) {
var data = jQuery('#global_filter').serializeArray();
data.push({name: "type", value: 2});
data.push({name: "datasource", value: l.connection_id});
data.push({name: "layer_id", value: l._id});
data.push({name: "map_id", value: map.id});
data.push({name: "_token", value: jQuery('[name="_token"]').val()});
data.push({name: "sql_layer_name", value: l.name});
data.push({name: "query_box", value: l.query});
data.push({name: "cache_key", value: l.cache_key});
data.push({name: "cache_timer", value: 0});
ajaxRequest('map/layer/json', 'post', 'json', data, function (data) {
if (data.status == "200") {
processSQLJSON(data, l);
} else {
showMsg(data.status, data.msg);
}
});
}
})
}
function clearLayersAndControls(data, t) {
layer = featureGroup[t.unique_id][t.name];
if (layer) {
layer.clearLayers();
// if (typeof legend[t.unique_id] != "undefined") {
// legend[t.unique_id].removeFrom(mymap);
// }
}
}
function getSQLFeatureData(t) {
var layers = featureGroup[t.unique_id][t.name].getLayers();
var featuredata = new Array();
var counter = 0;
$.each(layers, function (key, val) {
if (typeof t.cluster != "undefined" && t.cluster == 1) {
featuredata[counter++] = val.feature.properties;
} else {
val.eachLayer(function (layer) {
featuredata[counter++] = layer.feature.properties;
});
}
});
return featuredata;
}
var heatmap = new Array();
function processheatmapJSON(data, t) {
// addressPoints = addressPoints.map(function (p) {
// return [p[0], p[1], parseInt(p[2], 10)];
// });
// console.log(addressPoints);
//console.log(featureGroup[t.unique_id][t.name]);
if (typeof heatmap[t.unique_id] == "undefined") {
heatmap[t.unique_id] = L.heatLayer(data.result, {radius: 30}).addTo(featureGroup[t.unique_id][t.name]);
} else {
heatmap[t.unique_id].setLatLngs(data.result).setOptions({radius: 30}).redraw();
}
}
function render_layer_again(t) {
console.log(t);
featureGroup[t.unique_id][t.name].clearLayers();
show_active_layers_flag = false;
renderLayer(t, '');
show_active_layers_flag = true;
}
var pgsql_tmpl;
var featureGroup = new Array();
var bounds;
var layerSelector = new Array();
var overlays = new Array();
var mymap;
var currentBaseMap = new Array();
var marker_content_tmpl;
var popupContentId = new Array();
var tmpl = {};
var db = {};
var table_tmpl = document.getElementById('table-tmpl').innerHTML;
Mustache.parse(table_tmpl);
var column_tmpl = document.getElementById('column-tmpl').innerHTML;
Mustache.parse(column_tmpl);
var currentIndex = -1;
var drawingGroup;
var editMode = false;
var baselayer_arr = new Array();
jQuery(document).ready(function () {
calculateWindow();
manage_map_settings();
$.fn.button.Constructor.DEFAULTS = {
loadingText: '<i class="fa fa-spin fa-spinner"></i> Processing...…'
}
$('.gs-collapse').on('click', function () {
var $self = jQuery(this);
// var $self = jQuery('#' + $self.attr(''));
getGeoLayer($self, 'gs');
})
$('.wms-collapse').on('click', function () {
var $self = jQuery(this);
getGeoLayer($self, 'wms');
})
drawingGroup = new L.FeatureGroup();
marker_content_tmpl = document.getElementById("marker-content-tmpl").innerHTML;
Mustache.parse(marker_content_tmpl);
tmpl.activeLayer = document.getElementById("active-layers-tmpl").innerHTML;
Mustache.parse(tmpl.activeLayer);
defaultSettings();
var drawControl = new L.Control.Draw({
edit: {
featureGroup: drawingGroup
}
});
mymap = L.map('mapid', {
// crs: L.CRS.EPSG4326,
zoomControl: false,
}).setView([51.505, -0.09], 13);
L.control.zoom({
position: 'topright'
}).addTo(mymap);
L.control.fullscreen({
position: 'topright', // change the position of the button can be topleft, topright, bottomright or bottomleft, defaut topleft
// title: 'Show me the fullscreen !', // change the title of the button, default Full Screen
// titleCancel: 'Exit fullscreen mode', // change the title of the button when fullscreen is on, default Exit Full Screen
//content: null, // change the content of the button, can be HTML, default null
// forceSeparateButton: true, // force seperate button to detach from zoom buttons, default false
// forcePseudoFullscreen: true, // force use of pseudo full screen even if full screen API is available, default false
// fullscreenElement: false // Dom element to render in full screen, false by default, fallback to map._container
}).addTo(mymap);
//mymap.addControl(drawControl);
drawControl.addTo(mymap);
drawingGroup.addTo(mymap);
drawing_event();
// if(typeof map.settings.base_layer != "undefined"){
// layername = map.settings.base_layer;
// }else
if (selectedBaseLayers.length > 0) {
layername = selectedBaseLayers[0]['name'];
$.each(selectedBaseLayers, function (layer, value) {
console.log(layer);
console.log(value);
baselayer_arr[value.name] = baseLayers["mymap"][value.name];
});
} else {
baselayer_arr = baseLayers['mymap'];
$.each(baseLayers["mymap"], function (layer, value) {
layername = layer;
})
}
$('#share-modal').on('shown.bs.modal', function () {
var URL = baseURL
if (!map.settings.https && map.settings.https != 1) {
URL = baseURL.replace("s://", "://");
}
var ifrmecode = '<iframe src="' + URL + "map/embed/" + map.random_token + '" height="' + map.settings.height + '" width="' + map.settings.width + '"></iframe>';
jQuery('#ds_iframe_code').val(ifrmecode);
jQuery('#ds_share_url').val(URL + "map/share/" + map.random_token);
jQuery('#ds_json_url').val(URL + "map/json/" + map.random_token);
})
if (isGoogle()) {
currentBaseMap = L.tileLayer('https://{s}.google.com/vt/lyrs=s&x={x}&y={y}&z={z}', {
maxZoom: 20,
subdomains: ['mt0', 'mt1', 'mt2', 'mt3']
}).addTo(mymap);
} else {
currentBaseMap = L.tileLayer(baseLayers['mymap'][layername]._url, {
maxZoom: 18,
attribution: baseLayers['mymap'][layername].options.attribution,
id: baseLayers['mymap'][layername].options.id
}).addTo(mymap);
}
layerSelector = L.control.layers(baselayer_arr, {});
mymap.on("baselayerchange", function (layer, e) {
})
mymap.addControl(layerSelector);
jQuery('#active-layers-container').on("click", '.delete-at-layer', function () {
var $self = jQuery(this);
swal({
title: "Are you sure?",
text: "This will remove layer from current map.",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel plx!",
closeOnConfirm: true,
closeOnCancel: true
},
function (isConfirm) {
if (isConfirm) {
var unique_id = $self.parents(".active-layer-action:first").attr("data-id");
deleteLayer(unique_id);
}
});
})
sentinel_stuff();
jQuery('#active-layers-container').on("click", '.geometry-area-limit', function () {
var $self = jQuery(this);
var unique_id = $self.parents(".active-layer-action:first").attr("data-id");
// alert(unique_id);
var tmpl = document.getElementById("geometry-area-limit-tmpl").innerHTML;
Mustache.parse(tmpl);
var t = getIndex(selectedLayers, 'unique_id', unique_id);
var freehand_map = _.filter(selectedLayers, function (x) {
return x.type == 2 || x.type == 3;
});
jQuery('#geometry-area-limit-form-body').html(Mustache.render(tmpl, {unique_id: unique_id, t: t, f: freehand_map}));
jQuery('#geometry-area-limit-modal').modal("show");
validateForm(jQuery('#geometry-area-limit-form'));
jQuery('#geometry_area_dd').change(function () {
var value = jQuery(this).val();
if (jQuery('#' + value).length > 0) {
var tmpl = document.getElementById(value).innerHTML;
Mustache.parse(tmpl);
jQuery('#geometry-type-render-container').html(Mustache.render(tmpl));
if (value == "query-geometry-type-tmpl") {
console.log("tmc");
setupGeomtryQuery();
}
}
});
jQuery('#geometry_area_dd').trigger("change");
jQuery('#geometry-area-limit-submit').unbind("click");
jQuery('#geometry-area-limit-submit').click(function () {
var $form = jQuery('#geometry-area-limit-form');
if ($form.validate().form()) {
var unique_id = $form.find('[name="unique_id"]').val();
var index = getIndex(selectedLayers, 'unique_id', unique_id);
var l1 = $form.find('[name="geometry_area"]').val();
var type = $form.find('[name="geometry_area"] option:selected').attr("data-type");
if (l1 == "custom-geometry-type-tmpl") {
var index1 = getIndex(selectedLayers, 'unique_id', unique_id);
selectedLayers[index1].geometry_area = jQuery('#custom_geometry_area').val();
ajaxRequest("developer/map/get/wkt", 'post', 'json', {data: selectedLayers[index1].geometry_area, unique_id: unique_id, boundary_type: 'custom', _token: jQuery('[name="_token"]').val(), geometry_name: jQuery('#geometry_name').val()}, function (html) {
if (html.status == 200) {
var index1 = getIndex(selectedLayers, 'unique_id', html.unique_id);
update_dirty(index1, 2);
selectedLayers[index1].boundary_id = html.boundary_id;
selectedLayers[index1].geometry_area = html.wkt;
render_layer_again(selectedLayers[index1]);
jQuery('#geometry-area-limit-modal').modal("hide");
} else {
showMsg("error", html.msg);
}
});
} else if (l1 == "shape-file-geometry-type-tmpl") {
upload_geometry_shape_file();
} else if (type == "boundary") {
$form.find('[name="boundary_type"]').val('boundary');
ajaxRequest("developer/map/get/wkt", 'post', 'json', jQuery('#geometry-area-limit-form').serialize(), function (html) {
if (html.status == 200) {
var index1 = getIndex(selectedLayers, 'unique_id', html.unique_id);
selectedLayers[index1].geometry_area = html.wkt;
selectedLayers[index1].boundary_id = html.boundary_id;
update_dirty(index1, 2);
render_layer_again(selectedLayers[index1]);
jQuery('#geometry-area-limit-modal').modal("hide");
} else {
showMsg("error", html.msg);
}
});
} else {
var geometry_id = $form.find('[name="geometry_area"]').val();
var custom_index = getIndex(selectedLayers, 'unique_id', geometry_id);
var index1 = getIndex(selectedLayers, 'unique_id', unique_id);
//console.log(toWKT(featureGroup[selectedLayers[index1].unique_id][selectedLayers[index1].name]));
jQuery('#geometry-area-limit-modal').modal("hide");
if (selectedLayers[custom_index].type == 2) {
$form.find('[name="boundary_type"]').val('sql');
ajaxRequest("developer/map/get/wkt", 'post', 'json', {data: selectedLayers[custom_index], _token: jQuery('[name="_token"]').val(), boundary_type: 'sql', geometry_name: jQuery('#geometry_name').val(), unique_id: unique_id}, function (html) {
if (html.status == 200) {
var index1 = getIndex(selectedLayers, 'unique_id', html.unique_id);
update_dirty(index1, 2);
selectedLayers[index1].boundary_id = html.boundary_id;
selectedLayers[index1].geometry_area = html.wkt;
render_layer_again(selectedLayers[index1]);
jQuery('#geometry-area-limit-modal').modal("hide");
} else {
showMsg("error", html.msg);
}
});
} else {
$form.find('[name="boundary_type"]').val('custom');
selectedLayers[index1].geometry_area = toWKT(selectedLayers[custom_index].layer);
ajaxRequest("developer/map/get/wkt", 'post', 'json', {data: selectedLayers[index1].geometry_area, _token: jQuery('[name="_token"]').val(), boundary_type: 'custom', unique_id: unique_id, geometry_name: 'default'}, function (html) {
if (html.status == 200) {
var index1 = getIndex(selectedLayers, 'unique_id', html.unique_id);
update_dirty(index1, 2);
selectedLayers[index1].boundary_id = html.boundary_id;
selectedLayers[index1].geometry_area = html.wkt;
render_layer_again(selectedLayers[index1]);
jQuery('#geometry-area-limit-modal').modal("hide");
} else {
showMsg("error", html.msg);
}
});
}
}
}
})
})
jQuery('[href="#layer-panel"], [href="#settings-panel"]').click(function(){
sidebar_toggle(jQuery(this).attr("href"));
})
jQuery('#active-layers-container').on("click", '.edit-at-layer', function () {
var $self = jQuery(this);
var unique_id = $self.parents(".active-layer-action:first").attr("data-id");
console.log(unique_id);
editATLayer(unique_id);
})
jQuery('#active-layers-container').on("click", '.edit-query-at-layer', function () {
var $self = jQuery(this);
var unique_id = $self.parents(".active-layer-action:first").attr("data-id");
editSQLATLayer(unique_id);
})
jQuery('#active-layers-container').on("click", '.cache-at-layer', function () {
var $self = jQuery(this);
var unique_id = $self.parents(".active-layer-action:first").attr("data-id");
editCacheLayer(unique_id);
})
jQuery('#active-layers-container').on("click", '.style-at-layer', function (e) {
var $self = jQuery(this);
var unique_id = $self.parents(".active-layer-action:first").attr("data-id");
editStyleLayer(unique_id);
})
jQuery('#cache-settings-modal').on("click", '#cache-settings-save-btn', function (e) {
e.preventDefault();
var $form = jQuery('#cache_settings_form');
if ($form.validate().form()) {
var unique_id = $form.find('[name="unique_id"]').val();
var index = getIndex(selectedLayers, 'unique_id', unique_id);
update_dirty(index, 2);
var time = $form.find('[name="cache_timer"]').val();
selectedLayers[index].cache_timer = time;
jQuery('#cahe-settings-modal').modal("hide");
saveMapData('settings', function () {
showMsg("success", "Cache settings save successfully.");
});
}
})
jQuery('#layer-tmpl').change(function () {
var tmpl = jQuery(this).val();
var tmpl = document.getElementById(tmpl).innerHTML;
Mustache.parse(tmpl);
jQuery('#layer-render-tmpl').html(Mustache.render(tmpl));
})
jQuery('.layer_chk').change(function () {
var $self = jQuery(this);
WMSLayers($self, true);
})
jQuery('#layer-submit').click(function () {
var data = jQuery('#layer-form').serialize();
ajaxRequest('/developer/connection/save', 'post', 'json', data, function (data) {
if (data.status == 200 && data.table_name == "") {
var tmpl = document.getElementById("table-tmpl").innerHTML;
Mustache.parse(tmpl);
jQuery('#tables_div').html(Mustache.render(tmpl, {tables: data.result}));
} else if (data.status == 200 && data.table_name != "") {
jQuery.each(data.result, function (name, json) {
featureGroup = new L.FeatureGroup();
featureGroup.addTo(mymap);
L.geoJson(json, {
onEachFeature: function (feature, layer) {
}
}).addTo(featureGroup);
mymap.fitBounds(featureGroup.getBounds());
});
jQuery('#layer-modal').modal("hide");
}
});
})
jQuery('#save-your-map').click(function (e) {
e.preventDefault();
var $self = jQuery(this);
$self.button("loading");
saveMapData('map', function (data) {
$self.button("reset");
window.location = baseURL + "/developer/map/edit/" + data.map_id;
});
})
// jQuery('body').click(function(){
// if(jQuery('.control-sidebar').has("control-sidebar-open")){
// jQuery('.control-sidebar').removeClass('control-sidebar-open');
// jQuery('.sidebar_hide').removeClass("hide");
// }
// })
jQuery('.close-right-sidebar').click(function () {
if (jQuery('.sidebar_hide').hasClass("hide")) {
jQuery('.sidebar_hide').toggleClass("hide");
jQuery('.control-sidebar').toggleClass('control-sidebar-open');
}
})
jQuery('#settings-menu-open').click(function (e) {
e.stopPropagation();
e.preventDefault();
var rs_tmpl = document.getElementById('map-settings-sidebar-tmpl').innerHTML;
Mustache.parse(rs_tmpl);
jQuery('#map-sidebar-container').html(Mustache.render(rs_tmpl, {}));
// var htmlMarkerContent = "";
// jQuery('#marker_content_html').html('');
//
// $.each(selectedLayers, function (key, value) {
// htmlMarkerContent += Mustache.render(marker_content_tmpl, {layers: value, unique_id: value.unique_id});
// })
// jQuery('#marker_content_html').html(htmlMarkerContent);
var setting_tab_2 = document.getElementById("map-settings-tmpl").innerHTML;
Mustache.parse(setting_tab_2);
jQuery('#setting_tab_2').html(Mustache.render(setting_tab_2, {settings: map.settings, bg_layers: bglayersrow}));
if (typeof map.settings.base_layer != "undefined") {
jQuery('#map_base_layers').val(map.settings.base_layer);
}
if (!jQuery('.sidebar_hide').hasClass("hide")) {
jQuery('.sidebar_hide').toggleClass("hide");
jQuery('.control-sidebar').toggleClass('control-sidebar-open');
}
tinyMCEInit_Popup('.popup-content-textarea');
var $mform = jQuery('#map-settings-form');
validateForm($mform);
if (map.settings.fullscreen && map.settings.fullscreen == 1) {
$mform.find('[name="fullscreen"]').prop("checked", true);
}
if (map.settings.https && map.settings.https == 1) {
$mform.find('[name="https"]').prop("checked", true);
}
jQuery('.map_settings_chk').bootstrapSwitch({
size: 'small'
})
// jQuery('#marker_content_html').slimScroll({
// height: jQuery(window).height(),
// railVisible: true,
// alwaysVisible: true
// });
})
jQuery('.control-sidebar').on('click', '#save-settings-btn', function (e) {
if (jQuery('#map-settings-form').validate().form()) {
e.preventDefault();
var $self = jQuery(this);
$self.button("loading");
saveMapData('settings', function (data) {
$self.button("reset");
map.settings = data.settings;
showMsg("success", "Settings saved successfully.");
});
}
})
jQuery('.control-sidebar').on('click', '.save-settings', function (e) {
e.preventDefault();
var $self = jQuery(this);
if (jQuery('#style_settings_form').validate().form()) {
$self.button("loading");
saveMapData('style', function (data) {
$self.button("reset");
showMsg("success", "Style saved successfully.");
});
}
})
jQuery('.control-sidebar').on('click', '#save_popup_content', function () {
var formdata = jQuery('#layer-form').serialize();
ajaxRequest('/developer/map/save', 'post', 'json', formdata, function (data) {
if (data.status == 200) {
jQuery('#map_id').val(data.map_id);
window.location = baseURL + "/developer/map/edit/" + data.map_id;
//showMsg(data.action, data.msg);
} else {
showMsg("error", data.msg);
}
})
})
// jQuery('.control-sidebar').on('change', '.popup-content-textarea', function () {
// var $self = jQuery(this);
// var keyname = $self.attr("data-keyname");
// var content = $self.val();
// var index = getGSIndex(keyname);
// selectedLayers[index].gs.layers.pc = content;
// })
sqlFormEvent();
assingSettings();
global_filter_event();
//load settings tab
})
jQuery(document).ready(function () {
jQuery('#main-loader').removeClass("hide");
initLayer();
$('input[type="checkbox"].bg_layer_chk').each(function () {
jQuery(this).bootstrapSwitch({
size: 'mini',
onSwitchChange: function (event, state) {
event.preventDefault();
var $self = jQuery(event.target);
baseLayerMap($self, true);
}
});
});
jQuery('.make-switch').bootstrapSwitch({size: 'mini'});
// $('.make-switch').on('switchChange.bootstrapSwitch', function (event, state) {
// event.preventDefault();
// var $self = jQuery(event.target);
// baseLayerMap($self, true);
// });
// iCheck({
// labelHover: false,
// cursor: true,
// checkboxClass: 'icheckbox_flat-blue'
// }).on('ifChanged', function (event) {
// //console.log(event.target);
// var $self = jQuery(event.target);
// baseLayerMap($self, true);
// });
var sqlLayers = getDetailsByAttr(selectedLayers, 'type', 2);
if (sqlLayers.length == 0) {
ajaxLoadSucess();
}
}).ajaxStop(function () {
//ajaxLoadSucess();a
ajaxLoadSucess();
});
function ajaxLoadSucess() {
jQuery('#main-loader').addClass("hide");
}
function WMSLayers($self, useStore, type) {
var gsid = $self.attr("data-gsid");
var layername = $self.attr("data-layername");
var index = getIndex(DBLayerType, "id", type);
console.log(type);
//console.log(dbType.tmpl + "_" + gsid);
var gg = gslayers[DBLayerType[index].tmpl + "_" + gsid][0];
var g = getDetailsByAttr(gg.layers, "Name", layername);
g = g[0];
var wkname = g['Name'].split(":");
var url;
if (type == 1) {
url = gg.url + wkname[0] + "/wms";
} else {
url = gg.url; //+ wkname[0] + "/wms";
}
//console.log(url);
var gskey = g.l_id;
console.log("test");
var $li = $self.parents("li:first");
// console.log($self.is(":checked"));
if ($self.is(":checked")) {
add_sentinel_date_picker(gsid, $li);
if (useStore == true) {
t = g;
t.id = gg.id;
t.unique_id = gskey;
t.type = type;
t.name = g['Title'];
t.url = url;
t.pc = "";
t.is_dirty = 1;
selectedLayers.push(t);
}
renderLayer(t, '');
} else {
$li.find('.date_sentinel_hub').remove();
jQuery('#at-' + gskey).remove();
var index = getLayersIndex(gskey);
update_dirty(index, 3);
featureGroup[gskey][g.Title].clearLayers();
layerSelector.removeLayer(featureGroup[gskey][g.Title]);
removeOverlayerControl(gskey);
}
calculateBounds();
}
function add_sentinel_date_picker(gsid, $li) {
var g = getDetailsByAttr(wms_layers, "id", gsid);
console.log($li);
if (g.length > 0 && typeof g[0].wms_service_id != "undefined" && g[0].wms_service_id == 1) {
$li.append('<a href="javascript:void(0)" class="date_sentinel_hub"><i class="fa fa-calendar"></i></a>');
jQuery('.date_sentinel_hub').datepicker({
endDate: '+0d',
format: "yyyy-mm-DD"
}).on('changeDate', function (vale, date) {
var $checkbox = jQuery(this).parents("li:first").find('input[type="checkbox"]');
var id = $checkbox.attr("data-gsid");
var layername = $checkbox.attr("data-layername");
var gg = gslayers[ "wms_" + id][0];
var g = getDetailsByAttr(gg.layers, "Name", layername);
g = g[0];
var index = getIndex(selectedLayers, 'unique_id', g.l_id);
selectedLayers[index].time = vale.format('yyyy-mm-dd');
render_layer_again(selectedLayers[index]);
});
}
}
function clearMap() {
jQuery.each(selectedLayers, function (key, value) {
$self = jQuery('#layer_selection_' + value.gs.id).find('input:checkbox[data-layername="' + value.gs.layers.Name + '"]');
var gsid = $self.attr("data-gsid");
var layername = $self.attr("data-layername");
var gg = getDetailsByAttr(layers, "id", gsid);
gg = gg[0];
var g = getDetailsByAttr(gg.layers, "Name", layername);
g = g[0];
var gskey = "gs_" + g['Name'] + "_" + gg.id;
layerSelector.removeLayer(featureGroup[gskey][g.Title]);
featureGroup[gskey][g.Title].clearLayers();
})
}
function tinyMCEInit_Popup(textarea) {
// if (textarea) {
// tinyMCE.remove('#' + textarea);
// }
// tinyMCE.remove('#imageOverlayPopupContentInput');
// tinyMCE.remove('#modalPropertyValue');
// tinyMCE.remove('#edit_overlay_content');
// tinyMCE.remove('#edit_legend_content');
tinyMCE.init({
selector: textarea,
theme: "modern",
plugins: [
// "advlist autolink lists link image charmap print preview hr anchor pagebreak",
// "searchreplace wordcount visualblocks visualchars code fullscreen",
// "insertdatetime media nonbreaking save table contextmenu directionality",
// "emoticons template paste textcolor colorpicker textpattern jbimages mapshapes"
],
toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image jbimages",
toolbar2: "print preview media | forecolor backcolor emoticons | mapshapes",
image_advtab: true,
relative_urls: false,
remove_script_host: false,
convert_urls: true,
autosave_ask_before_unload: false,
extended_valid_elements: "a[onclick|style|href|title|id|class|target]",
setup: function (ed) {
ed.on('change', function (e) {
var $target = jQuery(ed.targetElm);
console.log($target.attr("data-uniqueid"));
var index = getIndex(selectedLayers, 'unique_id', $target.attr("data-uniqueid"));
selectedLayers[index].pc = ed.getContent();
});
}
});
}
function baseLayerMap($self, store) {
var layername = $self.attr("data-name");
var id = $self.val();
console.log("bagg");
if ($self.is(":checked")) {
console.log("bagg1");
if (store === true) {
layerSelector.addBaseLayer(baseLayers['mymap'][layername], layername);
var t = new Object;
t.id = id;
t.name = layername;
selectedBaseLayers.push(t);
baselayers_controls(layername);
}
} else {
layerSelector.removeLayer(baseLayers['mymap'][layername]);
var index = getIndex(selectedBaseLayers, "id", id);
selectedBaseLayers.splice(index, 1);
jQuery('#custom_layers [data-name="' + layername + '"]').remove();
}
if (selectedBaseLayers.length > 0) {
jQuery('#visiable-layers').find('.baselayers-control').removeClass("hide");
}
}
function makeFasterTree(id) {
var t = new Array();
$.each(db.columns, function (key, value) {
var t1 = new Object;
t1.text = key;
t1.href = key;
t1.tags = value.length;
t1.nodes = new Array();
$.each(value, function (key1, value1) {
var t2 = new Object;
t2.text = value1.column_name;
t2.href = value1.column_name;
//t2.tags = value1.length;
t1.nodes.push(t2);
})
t.push(t1);
})
var options = {
bootstrap2: false,
showTags: false,
levels: 1,
data: t,
onNodeSelected: function (event, node) {
if (typeof node.parentId == "undefined") {
$(this).treeview('toggleNodeExpanded', [node.nodeId, {silent: true}]);
} else {
jQuery('#query_box').val(jQuery('#query_box').val() + " " + node.href);
}
}
};
$('#' + id).treeview(options);
jQuery('#table_tree_container').slimScroll({
height: 400
});
jQuery('#query-help-text-btn').slimScroll({
height: 400
});
}
function getGeoLayer(obj, type) {
var id = obj.attr("data-id");
console.log(obj);
obj.find('.loading').removeClass("hide");
if (obj.find("ul").length == 0) {
ajaxRequest('developer/geoserver/layers/json', 'get', 'json', {id: id, type: type}, function (data) {
obj.find('.loading').addClass("hide");
if (data.status == 200) {
gslayers[ type + '_' + id] = data.result;
var d = document.getElementById("geoserver-layers-tmpl").innerHTML;
Mustache.parse(d);
jQuery(obj.attr('href')).html(Mustache.render(d, {geolayers: data.result}));
var index = getIndex(DBLayerType, "tmpl", type);
//find selected Layers based on Type Field
var gg = getDetailsByType(selectedLayers, "id", id, "type", DBLayerType[index].id);
var $gs = jQuery('#' + type + '-layer-collapse-' + id);
jQuery.each(gg, function (key, value) {
$gs.find('[data-layername="' + value.Name + '"]').prop("checked", true);
})
jQuery('.scroller').slimScroll({
railVisible: true,
alwaysVisible: true
});
// alert("called");
$('.gs-container input[type="checkbox"].layer_chk').change(function () {
// alert("called");
var $self = jQuery(this);
WMSLayers($self, true, 1);
});
$('.wms-container input[type="checkbox"].layer_chk').change(function () {
// alert("called");
var $self = jQuery(this);
WMSLayers($self, true, 4);
});
jQuery.each(gg, function (key, value) {
var $li = $gs.find('[data-layername="' + value.Name + '"]').parents("li:first");
console.log(value.name);
add_sentinel_date_picker(value.id, $li);
});
} else {
showMsg(data.error, data.msg);
}
});
}
}
function deleteLayer(id) {
var index = getLayersIndex(id);
if (selectedLayers[index].type == 3) {
drawingGroup.removeLayer(selectedLayers[index].layer);
}
jQuery('#at-' + id).remove();
featureGroup[selectedLayers[index]['unique_id']][selectedLayers[index]['name']].clearLayers();
layerSelector.removeLayer(featureGroup[selectedLayers[index]['unique_id']][selectedLayers[index]['name']]);
update_dirty(index, 3);
}
function editATLayer(id) {
var index = getLayersIndex(id);
//var id = jQuery(this).val();
update_dirty(index, 1);
currentIndex = index;
if (selectedLayers[index]['type'] == 1 || selectedLayers[index]['type'] == 4) {
// var geoserver_tmpl = document.getElementById("geoserver-modal-tmpl").innerHTML;
// Mustache.parse(geoserver_tmpl);
// jQuery('#geoserver_layer_form').html(Mustache.render(geoserver_tmpl));
// jQuery('#geoserver-layer-modal').modal("show");
//
// jQuery('#geoserver_layer_name').val(selectedLayers[index]['name']);
// jQuery('#geoserver_unique_id').val(selectedLayers[index]['unique_id']);
//
// validateForm(jQuery('#geoserver_layer_form'));
//
// sqlFormChange = false;
layerDialog(selectedLayers[index]);
} else if (selectedLayers[index]['type'] == 2) {
// var sql_tmpl = document.getElementById("sql-layer-modal-tmpl").innerHTML;
// Mustache.parse(sql_tmpl);
// jQuery('#sql_layer_form').html(Mustache.render(sql_tmpl, {ds: ds}));
// jQuery('#sql-layer-modal').modal("show");
//
//
// jQuery('#query_box').val(selectedLayers[index]['query']);
//
// jQuery('#query_box').val(selectedLayers[index]['query']);
// jQuery('#sql_layer_name').val(selectedLayers[index]['name']);
// jQuery('#sql_datasource').val(selectedLayers[index]['connection_id']);
// jQuery('#sql_unique_id').val(selectedLayers[index]['unique_id']);
//
// jQuery('#sql_datasource').trigger("change");
// validateForm(jQuery('#sql_layer_form'));
//
// // jQuery('#sql-mode-switch').bootstrapSwitch('state', selectedLayers[index]['sql_mode'], false);
//
// sqlFormChange = false;
// SQLModeModal(selectedLayers[index]['sqlMode']);
layerDialog(selectedLayers[index]);
} else if (selectedLayers[index]['type'] == 3) {
layerDialog(selectedLayers[index]);
}
}
function editSQLATLayer(id) {
var index = getLayersIndex(id);
//var id = jQuery(this).val();
currentIndex = index;
if (selectedLayers[index]['type'] == 1) {
// var geoserver_tmpl = document.getElementById("geoserver-modal-tmpl").innerHTML;
// Mustache.parse(geoserver_tmpl);
// jQuery('#geoserver_layer_form').html(Mustache.render(geoserver_tmpl));
// jQuery('#geoserver-layer-modal').modal("show");
//
// jQuery('#geoserver_layer_name').val(selectedLayers[index]['name']);
// jQuery('#geoserver_unique_id').val(selectedLayers[index]['unique_id']);
//
// validateForm(jQuery('#geoserver_layer_form'));
//
// sqlFormChange = false;
layerDialog(selectedLayers[index]);
} else if (selectedLayers[index]['type'] == 2) {
var sql_tmpl = document.getElementById("sql-layer-modal-tmpl").innerHTML;
Mustache.parse(sql_tmpl);
jQuery('#sql_layer_form').html(Mustache.render(sql_tmpl, {ds: ds}));
jQuery('#sql-layer-modal').modal("show");
jQuery('#query_box').val(selectedLayers[index]['query']);
jQuery('#query_box').val(selectedLayers[index]['query']);
jQuery('#sql_layer_name').val(selectedLayers[index]['name']);
jQuery('#sql_datasource').val(selectedLayers[index]['connection_id']);
jQuery('#sql_unique_id').val(selectedLayers[index]['unique_id']);
jQuery('#sql_datasource').trigger("change");
validateForm(jQuery('#sql_layer_form'));
// jQuery('#sql-mode-switch').bootstrapSwitch('state', selectedLayers[index]['sql_mode'], false);
sqlFormChange = false;
SQLModeModal(selectedLayers[index]['sqlMode']);
} else if (selectedLayers[index]['type'] == 3) {
layerDialog(selectedLayers[index]);
}
}
function editCacheLayer(id) {
var index = getLayersIndex(id);
currentIndex = index;
var $form = jQuery('#cache_settings_form');
if (selectedLayers[index]['type'] == 1 || selectedLayers[index]['type'] == 3) {
var msg = "Cache settings not avaliable for Geoserver layers.";
if (selectedLayers[index]['type'] == 3) {
msg = "Cache settings not avaliable for FreeHand layers.";
}
var geoserver_tmpl = document.getElementById("no-settings-msg-modal-tmpl").innerHTML;
Mustache.parse(geoserver_tmpl);
$form.html(Mustache.render(geoserver_tmpl, {msg: msg}));
jQuery('#cache-settings-modal').modal("show");
jQuery('#cache-settings-modal .btn.btn-success').addClass("hide");
} else if (selectedLayers[index]['type'] == 2) {
var sql_tmpl = document.getElementById("sql-layer-cache-modal-tmpl").innerHTML;
Mustache.parse(sql_tmpl);
$form.html(Mustache.render(sql_tmpl, {ds: ds}));
jQuery('#cache-settings-modal').modal("show");
$form.find('[name="cache_timer"]').val(selectedLayers[index]['cache_timer']);
$form.find('[name="unique_id"]').val(selectedLayers[index]['unique_id']);
validateForm(jQuery('#cache_settings_form'));
jQuery('#cache-settings-modal .btn.btn-success').removeClass("hide");
}
}
function editStyleLayer(id) {
var index = getLayersIndex(id);
currentIndex = index;
var $form = jQuery('#style_settings_form');
if (selectedLayers[index]['type'] == 1) {
var geoserver_tmpl = document.getElementById("geoserver-style-modal-tmpl").innerHTML;
Mustache.parse(geoserver_tmpl);
$form.html(Mustache.render(geoserver_tmpl));
jQuery('#style-settings-modal').modal("show");
jQuery('#style-settings-modal .btn.btn-success').addClass("hide");
} else if (selectedLayers[index]['type'] == 2) {
var rs_tmpl = document.getElementById('sql-layer-style-modal-tmpl').innerHTML;
Mustache.parse(rs_tmpl);
jQuery('#map-sidebar-container').html(Mustache.render(rs_tmpl, {t: selectedLayers[index]}));
jQuery('.control-sidebar').toggleClass('control-sidebar-open');
jQuery('#layer_polygon_fill_color,#layer_polygon_color').colorpicker({
theme: 'bootstrap',
}).on('changeColor', function (ev) {
applyLiveStyle();
});
jQuery('#layer-polygon-styling input').change(function () {
applyLiveStyle();
});
jQuery('#layer-marker-styling select').change(function () {
applyLiveStyle();
});
jQuery('.sidebar_hide').toggleClass("hide");
return;
var sql_tmpl = document.getElementById("sql-layer-style-modal-tmpl").innerHTML;
Mustache.parse(sql_tmpl);
$form.html(Mustache.render(sql_tmpl, {ds: ds}));
jQuery('#style-settings-modal').modal("show");
$form.find('[name="unique_id"]').val(selectedLayers[index]['unique_id']);
validateForm(jQuery('#style_settings_form'));
jQuery('#style-settings-modal .btn.btn-success').removeClass("hide");
} else if (selectedLayers[index]['type'] == 3) {
jQuery('#layer_polygon_fill_color,#layer_polygon_color').colorpicker({
theme: 'bootstrap',
}).on('changeColor', function (ev) {
applyLiveStyle();
});
jQuery('#layer-polygon-styling input').change(function () {
applyLiveStyle();
});
}
}
var sqlFormChange = false;
function sqlFormEvent() {
jQuery('.sql-layers-btn').click(function () {
currentIndex = -1;
var id = jQuery(this).val();
var sql_tmpl = document.getElementById("sql-layer-modal-tmpl").innerHTML;
Mustache.parse(sql_tmpl);
jQuery('#sql_layer_form').html(Mustache.render(sql_tmpl, {ds: ds}));
jQuery('#sql-layer-modal').modal("show");
validateForm(jQuery('#sql_layer_form'));
SQLModeModal();
})
jQuery('#sql-layer-modal,#geometry-area-limit-modal').on('change', "#sql_datasource", function () {
var id = jQuery(this).val();
if (currentIndex != -1) {
if (selectedLayers[currentIndex]['connection_id'] != id) {
setupEditor();
}
}
ajaxRequest('db/table/' + id, 'get', 'json', {}, function (data) {
if (data['status'] == 200) {
db.tables = data['tables'];
db.columns = data['columns'];
makeFasterTree('tree_5');
jQuery('#drag_table').html('');
jQuery('#drag_table').append(Mustache.render(table_tmpl, data));
if (currentIndex != -1) {
jQuery('#drag_table').val(selectedLayers[currentIndex]['table_name']);
jQuery('#drag_table').trigger("change");
}
jQuery('#drag_table').select2({
width: '100%'
})
} else {
showMsg("error", data.error);
}
});
})
jQuery('#sql-layer-modal,#geometry-area-limit-modal').on('change', "#drag_table", function () {
var table_name = jQuery(this).val();
jQuery('#drag_geometry_column').html(Mustache.render(column_tmpl, {columns: db.columns[table_name]}));
jQuery('#drag_other_column').html(Mustache.render(column_tmpl, {columns: db.columns[table_name]}));
if (currentIndex != -1) {
jQuery('#drag_geometry_column').val(selectedLayers[currentIndex]['geometry_col']);
if (typeof selectedLayers[currentIndex]['other_col'] != "undefined" && selectedLayers[currentIndex]['other_col'].length > 0) {
for (var i in selectedLayers[currentIndex]['other_col']) {
var optionVal = selectedLayers[currentIndex]['other_col'][i];
$("#drag_other_column").find("option[value=" + optionVal + "]").prop("selected", "selected");
}
}
}
jQuery('#drag_other_column, #drag_geometry_column').select2({
width: '100%'
})
})
jQuery('#sql-layer-modal,#geometry-area-limit-modal').on('change', "#geohelm_tags", function () {
var tag = jQuery(this).val();
jQuery('#query_box').val(jQuery('#query_box').val() + tag);
})
jQuery('#sql-layer-save-btn').click(function (e) {
e.preventDefault();
var $self = jQuery(this);
if (jQuery('#sql_layer_form').validate().form()) {
//alert(sqlFormChange);
if (sqlFormChange === true) {
$self.button("loading");
var data = jQuery('#sql_layer_form').serialize();
ajaxRequest('developer/map/sql/layer/save', 'post', 'json', data, function (data) {
$self.button("reset");
if (data.status == 200) {
sqlMode = jQuery('#sql-mode-switch').bootstrapSwitch('state');
var unique_id = jQuery('#sql_unique_id').val(), index = -1;
if (unique_id != "") {
index = getLayersIndex(unique_id);
t = selectedLayers[index];
} else {
t = new Object;
t.unique_id = uniqId('pg');
t.pc = "";
t.type = 2;
t.cache_timer = 15;
}
t.connection_id = jQuery('#sql_datasource').val();
if (sqlMode == true) {
t.query = jQuery('#query_box').val();
t.sqlMode = true;
} else {
t.query = data.query;
}
t.table_name = jQuery('#drag_table').val();
t.geometry_col = jQuery('#drag_geometry_column').val();
t.other_col = jQuery('#drag_other_column').val();
t.name = jQuery('#sql_layer_name').val();
t.properties = data.columns;
if (index != -1) {
t.is_dirty = 2;
selectedLayers[index] = t;
mymap.removeLayer(featureGroup[t.unique_id][t.name]);
mymap.addLayer(featureGroup[t.unique_id][t.name]);
processSQLJSON(data, t);
} else {
t.is_dirty = 1;
selectedLayers.push(t);
renderLayer(t, data);
}
jQuery('#sql-layer-modal').modal("hide");
} else {
showMsg(data.status, data.msg);
}
});
} else {
jQuery('#sql-layer-modal').modal("hide");
}
}
})
jQuery('#geoserver-layer-save-btn').click(function (e) {
e.preventDefault();
var $self = jQuery(this);
if (jQuery('#geoserver_layer_form').validate().form()) {
//$self.button("loading");
var unique_id = jQuery('#geoserver_unique_id').val(), index = -1;
if (unique_id != "") {
index = getLayersIndex(unique_id);
t = selectedLayers[index];
} else {
t = new Object;
t.unique_id = uniqId('pg');
t.pc = "";
t.type = 2;
}
t.name = jQuery('#geoserver_layer_name').val();
if (index != -1) {
selectedLayers[index] = t;
jQuery('#at-' + t.unique_id + " span").html(t.name);
} else {
selectedLayers.push(t);
renderLayer(t, data);
}
jQuery('#geoserver-layer-modal').modal("hide");
}
})
jQuery('#sql-layer-modal,#geometry-area-limit-modal').on('change', '#sql_datasource, #drag_sql_datasource', function () {
sqlFormChange = true;
})
jQuery('#sql-layer-modal, #geometry-area-limit-modal').on('change', '#query_box, #drag_geometry_column,#drag_other_column,#drag_table', function () {
sqlFormChange = true;
})
}
function SQLModeModal(sqlMode) {
jQuery('#drag_sql_datasource,#sql_datasource').select2({
width: '100%'
});
$('#sql-mode-switch').on('switchChange.bootstrapSwitch', function (event, state) {
sqlFormChange = true;
event.preventDefault();
//Q.sqlMode = state;
jQuery('#sql_mode').val(true);
if (state === true) {
jQuery('#sql-mode-container').show();
jQuery('#drag-drop-container').hide();
} else {
jQuery('#sql-mode-container').hide();
jQuery('#drag-drop-container').show();
}
});
jQuery('#sql-mode-switch').bootstrapSwitch('state', sqlMode, false);
}
function setupEditor() {
jQuery('#query_box').val('');
jQuery('#drag_table').val('');
jQuery('#drag_geometry_column').val('');
jQuery('#drag_other_column').val('');
}
function setupGeomtryQuery() {
jQuery('#query_box').val('');
jQuery('#drag_table').val('');
jQuery('#drag_geometry_column').val('');
jQuery('#drag_other_column').val('');
SQLModeModal(false);
}
function drawing_event() {
var handleDrawEvent = function () {
mymap.on('draw:drawstart', function (e) {
draw_editStart(e);
});
mymap.on('draw:deletestart', function (e) {
draw_editStart(e);
});
mymap.on('draw:editstop', function (e) {
draw_editStop(e)
});
mymap.on('draw:drawstop', function (e) {
draw_editStop(e)
});
mymap.on('draw:deletestop', function (e) {
draw_editStop(e)
});
mymap.on('moveend', function (e) {
updateMapCenter();
});
mymap.on('draw:created', function (e) {
var layerPro = new Object;
layerPro.lt = e.layerType;
var layer = e.layer;
drawingGroup.addLayer(layer);
layer.on("click", function () {
var index = getLayerIndex1(layer);
if (editMode) {
layerDialog(selectedLayers[index]);
setTimeout(function () {
mymap.closePopup();
}, 50);
} else {
layer.bindPopup(selectedLayers[index].pc);
// if (layer instanceof L.Marker) {
// var popup = L.popup();
// popup.setLatLng(layer.getLatLng());
// popup.setContent();
// mymap.openPopup(popup);
// } else {
// var bounds = layer.getBounds();
// var popup = L.popup();
// popup.setLatLng(bounds.getCenter());
// popup.setContent(selectedLayers[index].pc);
// mymap.openPopup(popup);
// }
//openPopup(layer);
// Otherwise show the content in a popup, or something.
}
});
/* Shape Style */
style = {};
var layerType = "";
if (layer instanceof L.Marker) {
style.marker = new Object;
style.marker.icon = '';
style.marker.color = '';
layerPro.marker = true;
layerPro.polygon = false;
} else if (layer instanceof L.MultiPolygon ||
layer instanceof L.Polyline ||
layer instanceof L.Rectangle ||
layer instanceof L.Circle) {
style.polygon = new Object;
style.polygon.color = '#ff0000';
style.polygon.opacity = 0.5;
style.polygon.weight = 5;
style.polygon.fillColor = '#ff0000';
style.polygon.fillOpacity = 0.5;
layer.setStyle(style.polygon);
layerPro.marker = false;
layerPro.polygon = true;
}
layerPro.layer = layer;
layerPro.style = style;
layerPro.type = 3;
layerPro.name = "Layer Name";
layerPro.location = "";
layerPro.pc = "";
layerPro.is_dirty = 1;
layerPro.unique_id = uniqId('cl'); //custom layers
selectedLayers.push(layerPro);
layerDialog(layerPro);
renderLayer(layerPro);
});
mymap.on('draw:editstart', function (e) {
// setTimeout(function () {
// var layers = drawingGroup.getLayers();
// $.each(layers, function (index, layer) {
// index = getLayerIndex(layer);
// if (layer instanceof L.Marker) {
// if (mapLayers[index].style.markerColor) {
// layer.setIcon(L.AwesomeMarkers.icon(mapLayers[index].style));
// }
// } else if (layer instanceof L.Polyline ||
// layer instanceof L.Polygon ||
// layer instanceof L.Rectangle ||
// layer instanceof L.Circle) {
// layer.setStyle(mapLayers[index].style);
// }
// });
// }, 50);
draw_editStart();
editMode = true;
});
mymap.on('draw:editstop', function (e) {
// setTimeout(function () {
// var layers = drawingGroup.getLayers();
// $.each(layers, function (index, layer) {
// index = getLayerIndex(layer);
// if (layer instanceof L.Marker) {
// if (selectedLayers[index].style.marker) {
// layer.setIcon(L.AwesomeMarkers.icon(selectedLayers[index].style.marker));
// }
// } else if (layer instanceof L.Polyline ||
// layer instanceof L.Polygon ||
// layer instanceof L.Rectangle ||
// layer instanceof L.Circle) {
// layer.setStyle(selectedLayers[index].style.polygon);
// }
// });
// }, 50);
editMode = false;
draw_editStop(e);
});
mymap.on('draw:deleted', function (e) {
var layers = e.layers;
layers.eachLayer(function (layer) {
if (layer instanceof L.MultiPolygon ||
layer instanceof L.Polyline ||
layer instanceof L.Rectangle ||
layer instanceof L.Circle ||
layer instanceof L.Marker) {
deleteLayer(layer.feature.properties.unique_id);
}
});
});
}
handleDrawEvent();
$('.leaflet-draw.leaflet-control').hide();
$('#mapid > #data').show();
$('#draw-polyline,#draw-polygon,#draw-rectangle,#draw-marker, #edit-edit,#edit-remove, #draw-circle').click(function (e) {
if ($(this).attr('href') == "#") {
e.preventDefault();
var id = $(this).attr('id');
$('.leaflet-draw-' + id)[0].click();
}
});
}
function draw_editStart(e) {
var idx = 0;
setTimeout(function () {
info = $('.leaflet-draw-tooltip').text().replace('Click cancel to undo changes.', '');
$('#control-tip-info').html(info);
$('#control-tip-buttons').text('');
$('.leaflet-draw-actions li').each(function (index) {
var obj = $(this);
if (obj.parent().css('display') == 'block') {
var value = obj.text();
var icon = '';
if (/cancel/i.test(value)) {
icon = 'remove';
} else if (/save/i.test(value)) {
icon = 'save';
} else {
icon = 'trash';
}
Actions = '<a href="#" onClick="return tipButtonsclick(' + (idx++) + ');" class="button-top drawing-icon pin-right unround button quiet icon close pad1 inline"><i class="fa fa-' + icon + '"></i> ' + obj.text() + '</a>';
$('#control-tip-buttons').prepend(Actions);
}
});
}, 100);
}
function draw_editStop(e) {
$('#control-tip-info').html('Select the Shape to draw on Map or <a href="#" class="btn btn-primary btn-xs" onClick="$(\'#data-importer\').click(); return false;" style="color:white;">click here to import</a> gpx, json or kml.');
$('#control-tip-buttons').text('');
}
function updateMapCenter() {
canter = mymap.getCenter();
$('input[name=latitude]').val(canter.lat);
$('input[name=longitude]').val(canter.lng);
$('#mapcenter').val('[' + canter.lat + ',' + canter.lng + ']');
}
var autocomplete;
function layerDialog(t) {
var cs_html = document.getElementById('cl-style-modal-tmpl').innerHTML;
Mustache.parse(cs_html);
jQuery('#map-sidebar-container').html(Mustache.render(cs_html, {t: t, type: layerType[t.type]}));
sidebar_toggle('#side-panel');
tinyMCEInit_Popup('#cs-layer-popup [name="pc"]');
if (t.type == 2 || t.type == 3) {
if (t.style.type == "nr" || t.style.type == "g") {
var layers = featureGroup[t.unique_id][t.name].getLayers();
var featuredata = new Array();
var counter = 0;
$.each(layers, function (key, val) {
val.eachLayer(function (layer) {
featuredata[counter++] = layer.feature.properties;
});
});
console.log(featuredata);
if (t.style.type == "nr") {
var featuremax = _.max(featuredata, function (o) {
return o[t.style.field];
});
var numericRange = document.getElementById(t.style.type + "-style-selection").innerHTML;
Mustache.parse(numericRange);
jQuery('#style_column_name').val(t.style.field);
jQuery('#style_data_type').val(t.style.type);
jQuery('#attribute-input-field').html(Mustache.render(numericRange, {max: featuremax[t.style.field]}));
var tr = 0;
$.each(t.style.custom, function (tr, val) {
var numericRange = document.getElementById(t.style.type + "-column-style-selection").innerHTML;
Mustache.parse(numericRange);
var html = Mustache.render(numericRange, {});
jQuery('#attribute-input-field table tbody').append(html);
var $last = jQuery('#attribute-input-field table tbody tr:last');
$last.find("input").val(val.val);
$last.find('select[data-name="markerColor"]').val(val.style.markerColor);
$last.find('select[data-name="icon"]').val(val.style.icon);
})
} else if (t.style.type == "g") {
var featuremax = _.groupBy(featuredata, function (o) {
return parseFloat(o[t.style.field]);
});
var numericRange = document.getElementById(t.style.type + "-style-selection").innerHTML;
Mustache.parse(numericRange);
jQuery('#style_column_name').val(t.style.field);
jQuery('#style_data_type').val(t.style.type);
jQuery('#attribute-input-field').html(Mustache.render(numericRange, {max: featuremax[t.style.field]}));
var tr = 0;
$.each(t.style.custom, function (tr, val) {
var numericRange = document.getElementById(t.style.type + "-column-style-selection").innerHTML;
Mustache.parse(numericRange);
var html = Mustache.render(numericRange, {});
jQuery('#attribute-input-field table tbody').append(html);
var $last = jQuery('#attribute-input-field table tbody tr:last');
$last.find("input").val(val.val);
$last.find('select[data-name="markerColor"]').val(val.style.markerColor);
$last.find('select[data-name="icon"]').val(val.style.icon);
})
}
}
jQuery('#layer_polygon_fill_color,#layer_polygon_color').colorpicker({
theme: 'bootstrap',
}).on('changeColor', function (ev) {
applyLiveStyle();
});
jQuery('#layer-polygon-styling input').change(function () {
applyLiveStyle();
});
jQuery('#layer-marker-styling .default-marker-style select').change(function () {
applyLiveStyle();
});
jQuery('#layer-marker-styling').on("click", ".numeric-range", function () {
var $currentTr = jQuery(this).parents("tr:first");
var cloneTr = $currentTr.clone();
cloneTr.find('input').val('');
$currentTr.after(cloneTr);
})
jQuery('#layer-marker-styling .custom-marker-style #style_data_type, #layer-marker-styling .custom-marker-style #style_column_name').change(function () {
var columnName = jQuery('#style_column_name').val();
var data_type = jQuery('#style_data_type').val();
if (columnName != "" && data_type != "") {
jQuery('#attribute-input-field').html('');
var my_unique_id = jQuery('#map-sidebar-container [name="my_unique_id"]').val();
var index = getIndex(selectedLayers, 'unique_id', my_unique_id);
var layers = featureGroup[selectedLayers[index].unique_id][selectedLayers[index].name].getLayers();
var featuredata = new Array();
var counter = 0;
$.each(layers, function (key, val) {
val.eachLayer(function (layer) {
featuredata[counter++] = layer.feature.properties;
});
});
if (data_type == "nr") {
var featuremax = _.max(featuredata, function (o) {
return parseFloat(o[columnName]);
});
var numericRange = document.getElementById(data_type + "-style-selection").innerHTML;
Mustache.parse(numericRange);
jQuery('#attribute-input-field').html(Mustache.render(numericRange, {max: featuremax[columnName]}));
if (jQuery('#attribute-input-field table tboday tr').length == 0) {
var numericRange = document.getElementById("nr-column-style-selection").innerHTML;
Mustache.parse(numericRange);
var html = Mustache.render(numericRange, {});
jQuery('#attribute-input-field table tbody').append(html);
}
} else {
var featuremax = _.groupBy(featuredata, function (o) {
return o[columnName];
});
var numericRange = document.getElementById(data_type + "-style-selection").innerHTML;
Mustache.parse(numericRange);
jQuery('#attribute-input-field').html(Mustache.render(numericRange, {max: featuremax[columnName]}));
$.each(featuremax, function (tr, val) {
var numericRange = document.getElementById("g-column-style-selection").innerHTML;
Mustache.parse(numericRange);
var html = Mustache.render(numericRange, {attr: tr});
jQuery('#attribute-input-field table tbody').append(html);
// var $last = jQuery('#attribute-input-field table tbody tr:last');
// $last.find("input").val(val.range);
// $last.find('select[data-name="markerColor"]').val(val.style.markerColor);
// $last.find('select[data-name="icon"]').val(val.style.icon);
})
}
}
});
var customStyle = new Array();
var s = 0;
jQuery('#attribute-input-field').on('change', 'table input, table select', function () {
var my_unique_id = jQuery('#map-sidebar-container [name="my_unique_id"]').val();
var index = getIndex(selectedLayers, 'unique_id', my_unique_id);
var layers = featureGroup[selectedLayers[index].unique_id][selectedLayers[index].name].getLayers();
var columnName = jQuery('#style_column_name').val();
var data_type = jQuery('#style_data_type').val();
customStyle = new Array();
s = 0;
jQuery('#attribute-numeric-table tbody tr').each(function () {
var $self = jQuery(this);
var range = $self.find('input:text').val();
var marker = {};
$self.find("select").each(function () {
marker[jQuery(this).attr("data-name")] = jQuery(this).val();
});
customStyle[s] = new Object;
customStyle[s].val = range;
customStyle[s].style = marker;
s++;
marker = getMarkerStyle(marker);
$.each(layers, function (key, val) {
val.eachLayer(function (layer) {
if (data_type == "nr") {
if (between(layer.feature.properties[columnName], range)) {
layer.setIcon(L.AwesomeMarkers.icon(marker));
}
} else if (data_type == "g") {
if (layer.feature.properties[columnName] == range) {
layer.setIcon(L.AwesomeMarkers.icon(marker));
}
}
});
});
})
if (typeof selectedLayers[index].style.custom == "undefined") {
selectedLayers[index].style.custom = new Object;
}
selectedLayers[index].style.custom = customStyle;
selectedLayers[index].style.type = data_type;
selectedLayers[index].style.field = columnName;
})
if (t.style.marker && typeof t.style.marker != "undefined") {
jQuery('#layer-marker-styling select[name="marker_color"]').val(t.style.marker.markerColor);
jQuery('#layer-marker-styling select[name="marker_icon"]').val(t.style.marker.icon);
}
}
jQuery('#cs-layer-info input, #cs-layer-info select').change(function () {
var $self = jQuery(this);
var my_unique_id = jQuery('#map-sidebar-container [name="my_unique_id"]').val();
var index = getIndex(selectedLayers, 'unique_id', my_unique_id);
selectedLayers[index][$self.attr("name")] = $self.val();
jQuery('#at-' + selectedLayers[index]['unique_id'] + " span.at-text").html(selectedLayers[index].name);
});
if (t.type == 3) {
autocomplete = new google.maps.places.Autocomplete(document.getElementById("autoFillAddress"), {types: ["geocode"]});
google.maps.event.addListener(autocomplete, "place_changed", function (e) {
lat = autocomplete.getPlace().geometry.location.lat();
lng = autocomplete.getPlace().geometry.location.lng();
var v = jQuery('#style_settings_form').find('[name="my_unique_id"]').val();
var index = getIndex(selectedLayers, 'unique_id', v);
console.log(index);
selectedLayers[index].layer.setLatLng([lat, lng]);
selectedLayers[index].location = jQuery('#autoFillAddress').val();
mymap.setView([lat, lng], mymap.getZoom());
});
}
}
function tipButtonsclick(index) {
var action = undefined;
$('.leaflet-draw-actions').each(function (index) {
if ($(this).css('display') == 'block') {
action = $(this);
}
});
if (action) {
action.find('a')[index].click();
}
return false;
}
function getDetailsByType(obj, key, val, key1, value1) {
var objects = [];
var len = obj.length;
for (i = 0; i < len; i++) {
if (obj[i][key] == val && obj[i][key1] == value1) {
objects.push(obj[i]);
}
}
return objects;
}
var globalLastFileFormat = '';
function initiateUpload() {
if ($('#data-importer').val() == "") {
globalLastFileFormat = '';
return;
}
var temp = $('form#layer-form input[type=file]').val().split('.');
globalLastFileFormat = temp[temp.length - 1];
//progressBar = createProgressBar();
var formData = new FormData($('form#layer-form')[0]);
$.ajax({
url: baseURL + 'developer/map/file/upload', //Server script to process data
type: 'POST',
xhr: function () {
// Custom XMLHttpRequest
var myXhr = $.ajaxSettings.xhr();
if (myXhr.upload) { // Check if upload property exists
myXhr.upload.addEventListener('progress', function (e) {
if (e.lengthComputable) {
// updateProgressBar(progressBar, Math.floor((e.loaded / e.total) * 100));
}
}, false); // For handling the progress of the upload
}
return myXhr;
},
success: function (data) {
try {
jsonData = JSON.parse(data);
if (jsonData['status'] = 200) {
if (jsonData['format'] == "json") {
// processSQLJSON(jsonData);
jQuery.each(jsonData.result, function (name, json) {
L.geoJson(json, {
onEachFeature: function (feature, layer) {
console.log(feature);
layer.on('click', function (e) {
var c = getSQLPopupContent(feature.properties, t.pc);
var bounds = layer.getBounds();
var popup = L.popup();
popup.setLatLng(bounds.getCenter());
popup.setContent(c);
mymap.openPopup(popup);
return;
})
}
}).addTo(mymap);
// mymap.fitBounds(featureGroup[t.unique_id][t.name].getBounds());
});
} else if (jsonData['format'] == "kml" || jsonData['format'] == "gpx") {
var data = new Object;
var st = new Object;
var t = JSON.parse(JSON.stringify(toGeoJSON[globalLastFileFormat.toLowerCase()]((new DOMParser()).parseFromString(jsonData.kmlData, 'text/xml')), null, 4));
console.log(t);
st.mapfig = t.features;
data.geoJSON = st;
// createLayers(data);
L.geoJson(st, {
onEachFeature: function (feature, layer) {
console.log(feature);
layer.on('click', function (e) {
var c = getSQLPopupContent(feature.properties, t.pc);
var bounds = layer.getBounds();
var popup = L.popup();
popup.setLatLng(bounds.getCenter());
popup.setContent(c);
mymap.openPopup(popup);
return;
})
}
}).addTo(mymap);
}
$('form#layer-form input[type=file]').val('');
} else {
alert("Invalid File");
return;
}
} catch (err) {
console.log(err);
alert("Invalid File", 'error');
return;
}
},
error: function (e) {
alert("Error While Uploading the file", "error");
// progressBar.close();
},
// Form data
data: formData,
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
});
$('form#data-importer-form input[type=file]').val('');
}
function upload_geometry_shape_file() {
var formData = new FormData($('form#geometry-area-limit-form')[0]);
jQuery('#geometry-area-limit-submit').button("loading");
$.ajax({
url: baseURL + 'developer/map/shapefile/upload', //Server script to process data
type: 'POST',
success: function (html) {
try {
jQuery('#geometry-area-limit-submit').button("reset");
if (html.status = 200) {
var index1 = getIndex(selectedLayers, 'unique_id', html.unique_id);
selectedLayers[index1].boundary_id = html.boundary_id;
update_dirty(index1, 2);
render_layer_again(selectedLayers[index1]);
jQuery('#geometry-area-limit-modal').modal("hide");
} else {
alert(html.msg);
return;
}
} catch (err) {
console.log(err);
alert("Invalid File", 'error');
return;
}
},
error: function (e) {
alert("Error While Uploading the file", "error");
progressBar.close();
},
// Form data
data: formData,
//Options to tell jQuery not to process data or worry about content-type.
cache: false,
contentType: false,
processData: false
});
$('form#data-importer-form input[type=file]').val('');
}
function global_filter_event() {
$('#add-control-popover-btn').popover({
container: 'body',
trigger: 'focus',
html: true,
placement: "left",
title: "Add Control",
content: jQuery('#dashboard-control-popupover').html()
})
jQuery('body').on("click", ".global-filter-control-btn", function () {
var $self = jQuery(this);
var value = $self.attr("data-id");
var tmpl = $self.attr("data-tmpl");
var m = document.getElementById(tmpl + "-filter-tmpl").innerHTML;
Mustache.parse(m);
jQuery('#filtering-form-container').html(Mustache.render(m, {}));
validateForm(jQuery("#filtering_form"));
jQuery('#filter_id').val(value);
jQuery('#global_filter_id').val("");
jQuery('#filtering-type-modal').modal({
backdrop: 'static',
keyboard: false,
show: true
});
})
jQuery('#filtering-type-modal').on('change', "#filter_datasource", function () {
var id = jQuery(this).val();
ajaxRequest('db/table/' + id, 'get', 'json', {}, function (data) {
if (data['status'] == 200) {
db.tables = data['tables'];
db.columns = data['columns'];
makeFasterTree('tree_6');
} else {
showMsg("error", data.error);
}
});
})
jQuery('#save_filter_query').click(function () {
if (jQuery('#filtering_form').validate().form()) {
saveFiltering();
}
})
global_filter_listing();
jQuery('#global-filtering-modal').on('click', '.edit_report_global_filter', function () {
var id = jQuery(this).attr("data-id");
var url = 'developer/report/global/filter/edit';
var data = {
"id": id,
"_token": jQuery('[name="_token"]').val()
};
ajaxRequest(url, 'post', 'json', data, function (html) {
if (html['status'] == 200) {
var m = document.getElementById(html.data.tmpl + "-filter-tmpl").innerHTML;
Mustache.parse(m);
jQuery('#filtering-form-container').html(Mustache.render(m, html.data));
jQuery('#filter_id').val(html.data.tmpl_id);
jQuery('#global_filter_id').val(html.data.id);
jQuery('#filtering-type-modal').modal({
backdrop: 'static',
keyboard: false,
show: true
});
if (html.data.tmpl_id == 1) {
jQuery('#filter_datasource').val(html.data.connection_id);
jQuery('#filter_datasource').trigger("change");
}
jQuery('#global-filtering-modal').modal("hide");
} else {
showMsg('error', 'Global Filter', data.msg);
}
})
})
}
var global_filtering_tbl = "";
function global_filter_listing() {
if (global_filtering_tbl != "") {
global_filtering_tbl.fnDestroy();
}
global_filtering_tbl = jQuery('#global-filter-lists').dataTable({
paging: true,
"aoColumns": [
{data: 'name', name: 'name', orderable: false, searchable: false},
{data: 'variable_name', name: 'variable_name'},
{data: 'gname', name: 'gname'},
{data: 'action', name: 'action', orderable: false, searchable: false}
],
autoWidth: false,
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": baseURL + "developer/report/global/filter/lists/" + mapid
});
}
function delete_global_filter(id) {
swal({
title: "Are you sure?",
text: "This will remove layer from current map.",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, delete it!",
cancelButtonText: "No, cancel plx!",
closeOnConfirm: true,
closeOnCancel: true
},
function (isConfirm) {
if (isConfirm) {
data = {
id: id,
"_token": jQuery('[name="_token"]').val()
}
ajaxRequest('developer/report/global/filter/delete', 'post', 'json', data, function (data) {
if (data['status'] == 200) {
global_filter_listing();
showMsg('success', 'Global Filter', data.msg);
} else {
showMsg('error', 'Global Filter', data.msg);
}
})
}
});
}
function saveFiltering() {
var data = jQuery('#filtering_form, #report_type_form').serialize();
ajaxRequest("developer/report/global/filter/save", 'post', 'json', data, function (html) {
//Metronic.unblockUI();
if (html.status == 200) {
window.location.reload();
} else {
jQuery('#notify_filter_type_html').html(html.error_msg);
}
});
}
function sentinel_stuff() {
jQuery('#active-layers-container').on("click", '.sentinel-hub-history-limit', function () {
var unique_id = jQuery(this).parents(".active-layer-action:first").attr("data-id");
var index1 = getIndex(selectedLayers, 'unique_id', unique_id);
var $senti = jQuery('#download-history-range-form');
$senti.find('[name="layer_id"]').val(selectedLayers[index1]._id);
jQuery('#download-history-sentinel-limit-modal').modal("show");
$('#history-sentinel-datetimepicker').daterangepicker({
locale: {
format: 'YYYY-MM-DD'
},
ranges: {
'Today': [moment(), moment()],
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
'Last 7 Days': [moment().subtract(6, 'days'), moment()],
'Last 30 Days': [moment().subtract(29, 'days'), moment()],
'This Month': [moment().startOf('month'), moment().endOf('month')],
'Last Month': [moment().subtract(1, 'month').startOf('month'), moment().subtract(1, 'month').endOf('month')]
},
maxDate: moment().add(1, 'days')
},
function (start, end, label) {
console.log(start.format("YYYY-MM-DD"));
jQuery('#download-history-range-form').find('[name="start_date_range"]').val(start.format("YYYY-MM-DD"));
jQuery('#download-history-range-form').find('[name="end_date_range"]').val(end.format("YYYY-MM-DD"));
}
);
});
jQuery('#download-history-save-btn').click(function (e) {
var data = jQuery('#download-history-range-form').serialize();
jQuery('#download-history-save-btn').button("loading");
ajaxRequest('/developer/sentinel/history/range/save', 'post', 'json', data, function (data) {
jQuery('#download-history-save-btn').button("reset");
if (data['status'] == 200) {
jQuery('#download-history-sentinel-limit-modal').modal("hide");
showMsg('success', 'Sentinel History', data.msg);
} else {
showMsg('error', 'Sentinel History', data.msg);
}
});
})
}
function calculateWindow() {
// if (map.settings.fullscreen == 1) {
var $window = jQuery(window);
jQuery('.map-container').height($window.height());
jQuery('.map-container').width($window.width());
jQuery('#mapid').height($window.height());
jQuery('#mapid').width($window.width());
jQuery('#mapid,.map-container').css("width", "100%");
// } else {
// jQuery('#mapid, .map-container').height(map.settings.height);
// jQuery('#mapid, .map-container').css("width", "100%");
// }
}
function sidebar_toggle(eleid) {
jQuery('.control-sidebar').removeClass('open');
jQuery( eleid).addClass('open');
}
function manage_map_settings() {
var $cancel_btn = $("#btn_setting_close");
var $save_btn = $("#btn_setting_save");
$save_btn.on("click", function (e) {
e.preventDefault();
$save_btn.button("loading");
var data = $("#map_settings_form").serialize();
ajaxRequest("developer/map/settings/save", 'post', 'json', data, function (html) {
$save_btn.button("reset");
if (html.status == 200) {
$cancel_btn.trigger("click");
showMsg("success", html.msg);
$("#map_setting_name").val(html.data.name);
$("#map_setting_width").val(html.data.width);
$("#map_setting_height").val(html.data.height);
} else {
showMsg("error", html.msg);
}
});
});
$cancel_btn.on("click", function (e) {
e.preventDefault();
$save_btn.button("reset");
$("#settings-panel").toggleClass("open");
});
}
//# sourceMappingURL=map.js.map