leaflet-lasso
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -19,3 +19,2 @@ import L from 'leaflet'; | ||
private map; | ||
private polyline?; | ||
private polygon?; | ||
@@ -22,0 +21,0 @@ private onDocumentMouseMoveBound; |
@@ -51,2 +51,34 @@ 'use strict'; | ||
var LassoPolygon = /** @class */ (function (_super) { | ||
__extends(LassoPolygon, _super); | ||
function LassoPolygon(latlngs, options) { | ||
var _this = _super.call(this) || this; | ||
_this.polyline = L.polyline(latlngs, options); | ||
_this.polygon = L.polygon(latlngs, __assign({}, options, { weight: 0 })); | ||
return _this; | ||
} | ||
LassoPolygon.prototype.onAdd = function (map) { | ||
this.polyline.addTo(map); | ||
this.polygon.addTo(map); | ||
return this; | ||
}; | ||
LassoPolygon.prototype.onRemove = function () { | ||
this.polyline.remove(); | ||
this.polygon.remove(); | ||
return this; | ||
}; | ||
LassoPolygon.prototype.addLatLng = function (latlng) { | ||
this.polyline.addLatLng(latlng); | ||
this.polygon.addLatLng(latlng); | ||
return this; | ||
}; | ||
LassoPolygon.prototype.getLatLngs = function () { | ||
return this.polygon.getLatLngs()[0]; | ||
}; | ||
LassoPolygon.prototype.toGeoJSON = function () { | ||
return this.polygon.toGeoJSON(); | ||
}; | ||
return LassoPolygon; | ||
}(L.Layer)); | ||
function getCircleMarkerRadius(circleMarker, crs, zoom) { | ||
@@ -183,2 +215,7 @@ var latLng = circleMarker.getLatLng(); | ||
var event2 = event; | ||
// activate lasso only for left mouse button click | ||
if (event2.originalEvent.buttons !== 1) { | ||
this.disable(); | ||
return; | ||
} | ||
// skip clicks on controls | ||
@@ -188,5 +225,3 @@ if (event2.originalEvent.target.closest('.leaflet-control-container')) { | ||
} | ||
// separate polyline and polygon, so that it is rendered unclosed | ||
this.polyline = L.polyline([event2.latlng], this.options.polygon).addTo(this.map); | ||
this.polygon = L.polygon([event2.latlng], __assign({}, this.options.polygon, { weight: 0 })).addTo(this.map); | ||
this.polygon = new LassoPolygon([event2.latlng], this.options.polygon).addTo(this.map); | ||
document.body.classList.add(ACTIVE_CLASS); | ||
@@ -197,12 +232,13 @@ document.addEventListener('mousemove', this.onDocumentMouseMoveBound); | ||
LassoHandler.prototype.onDocumentMouseMove = function (event) { | ||
if (!this.polyline || !this.polygon) { | ||
if (!this.polygon) { | ||
return; | ||
} | ||
var event2 = event; | ||
this.polyline.addLatLng(this.map.mouseEventToLatLng(event2)); | ||
this.polygon.addLatLng(this.map.mouseEventToLatLng(event2)); | ||
if (event2.buttons === 0) { | ||
// keep lasso active only if left mouse button is hold | ||
if (event2.buttons !== 1) { | ||
console.warn('mouseup event was missed'); | ||
this.finish(); | ||
return; | ||
} | ||
this.polygon.addLatLng(this.map.mouseEventToLatLng(event2)); | ||
}; | ||
@@ -214,3 +250,3 @@ LassoHandler.prototype.onDocumentMouseUp = function () { | ||
var _this = this; | ||
if (!this.polyline || !this.polygon) { | ||
if (!this.polygon) { | ||
return; | ||
@@ -221,3 +257,3 @@ } | ||
this.map.eachLayer(function (layer) { | ||
if (layer === _this.polyline || layer === _this.polygon) { | ||
if (layer === _this.polygon || layer === _this.polygon.polyline || layer === _this.polygon.polygon) { | ||
return; | ||
@@ -238,8 +274,6 @@ } | ||
this.map.fire(FINISHED_EVENT, { | ||
latLngs: this.polygon.getLatLngs()[0], | ||
latLngs: this.polygon.getLatLngs(), | ||
layers: selectedFeatures, | ||
}); | ||
this.map.removeLayer(this.polyline); | ||
this.map.removeLayer(this.polygon); | ||
this.polyline = undefined; | ||
this.polygon = undefined; | ||
@@ -246,0 +280,0 @@ this.disable(); |
@@ -45,2 +45,34 @@ import L from 'leaflet'; | ||
var LassoPolygon = /** @class */ (function (_super) { | ||
__extends(LassoPolygon, _super); | ||
function LassoPolygon(latlngs, options) { | ||
var _this = _super.call(this) || this; | ||
_this.polyline = L.polyline(latlngs, options); | ||
_this.polygon = L.polygon(latlngs, __assign({}, options, { weight: 0 })); | ||
return _this; | ||
} | ||
LassoPolygon.prototype.onAdd = function (map) { | ||
this.polyline.addTo(map); | ||
this.polygon.addTo(map); | ||
return this; | ||
}; | ||
LassoPolygon.prototype.onRemove = function () { | ||
this.polyline.remove(); | ||
this.polygon.remove(); | ||
return this; | ||
}; | ||
LassoPolygon.prototype.addLatLng = function (latlng) { | ||
this.polyline.addLatLng(latlng); | ||
this.polygon.addLatLng(latlng); | ||
return this; | ||
}; | ||
LassoPolygon.prototype.getLatLngs = function () { | ||
return this.polygon.getLatLngs()[0]; | ||
}; | ||
LassoPolygon.prototype.toGeoJSON = function () { | ||
return this.polygon.toGeoJSON(); | ||
}; | ||
return LassoPolygon; | ||
}(L.Layer)); | ||
function getCircleMarkerRadius(circleMarker, crs, zoom) { | ||
@@ -177,2 +209,7 @@ var latLng = circleMarker.getLatLng(); | ||
var event2 = event; | ||
// activate lasso only for left mouse button click | ||
if (event2.originalEvent.buttons !== 1) { | ||
this.disable(); | ||
return; | ||
} | ||
// skip clicks on controls | ||
@@ -182,5 +219,3 @@ if (event2.originalEvent.target.closest('.leaflet-control-container')) { | ||
} | ||
// separate polyline and polygon, so that it is rendered unclosed | ||
this.polyline = L.polyline([event2.latlng], this.options.polygon).addTo(this.map); | ||
this.polygon = L.polygon([event2.latlng], __assign({}, this.options.polygon, { weight: 0 })).addTo(this.map); | ||
this.polygon = new LassoPolygon([event2.latlng], this.options.polygon).addTo(this.map); | ||
document.body.classList.add(ACTIVE_CLASS); | ||
@@ -191,12 +226,13 @@ document.addEventListener('mousemove', this.onDocumentMouseMoveBound); | ||
LassoHandler.prototype.onDocumentMouseMove = function (event) { | ||
if (!this.polyline || !this.polygon) { | ||
if (!this.polygon) { | ||
return; | ||
} | ||
var event2 = event; | ||
this.polyline.addLatLng(this.map.mouseEventToLatLng(event2)); | ||
this.polygon.addLatLng(this.map.mouseEventToLatLng(event2)); | ||
if (event2.buttons === 0) { | ||
// keep lasso active only if left mouse button is hold | ||
if (event2.buttons !== 1) { | ||
console.warn('mouseup event was missed'); | ||
this.finish(); | ||
return; | ||
} | ||
this.polygon.addLatLng(this.map.mouseEventToLatLng(event2)); | ||
}; | ||
@@ -208,3 +244,3 @@ LassoHandler.prototype.onDocumentMouseUp = function () { | ||
var _this = this; | ||
if (!this.polyline || !this.polygon) { | ||
if (!this.polygon) { | ||
return; | ||
@@ -215,3 +251,3 @@ } | ||
this.map.eachLayer(function (layer) { | ||
if (layer === _this.polyline || layer === _this.polygon) { | ||
if (layer === _this.polygon || layer === _this.polygon.polyline || layer === _this.polygon.polygon) { | ||
return; | ||
@@ -232,8 +268,6 @@ } | ||
this.map.fire(FINISHED_EVENT, { | ||
latLngs: this.polygon.getLatLngs()[0], | ||
latLngs: this.polygon.getLatLngs(), | ||
layers: selectedFeatures, | ||
}); | ||
this.map.removeLayer(this.polyline); | ||
this.map.removeLayer(this.polygon); | ||
this.polyline = undefined; | ||
this.polygon = undefined; | ||
@@ -240,0 +274,0 @@ this.disable(); |
@@ -49,2 +49,34 @@ (function (global, factory) { | ||
var LassoPolygon = /** @class */ (function (_super) { | ||
__extends(LassoPolygon, _super); | ||
function LassoPolygon(latlngs, options) { | ||
var _this = _super.call(this) || this; | ||
_this.polyline = L.polyline(latlngs, options); | ||
_this.polygon = L.polygon(latlngs, __assign({}, options, { weight: 0 })); | ||
return _this; | ||
} | ||
LassoPolygon.prototype.onAdd = function (map) { | ||
this.polyline.addTo(map); | ||
this.polygon.addTo(map); | ||
return this; | ||
}; | ||
LassoPolygon.prototype.onRemove = function () { | ||
this.polyline.remove(); | ||
this.polygon.remove(); | ||
return this; | ||
}; | ||
LassoPolygon.prototype.addLatLng = function (latlng) { | ||
this.polyline.addLatLng(latlng); | ||
this.polygon.addLatLng(latlng); | ||
return this; | ||
}; | ||
LassoPolygon.prototype.getLatLngs = function () { | ||
return this.polygon.getLatLngs()[0]; | ||
}; | ||
LassoPolygon.prototype.toGeoJSON = function () { | ||
return this.polygon.toGeoJSON(); | ||
}; | ||
return LassoPolygon; | ||
}(L.Layer)); | ||
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; | ||
@@ -1648,2 +1680,7 @@ | ||
var event2 = event; | ||
// activate lasso only for left mouse button click | ||
if (event2.originalEvent.buttons !== 1) { | ||
this.disable(); | ||
return; | ||
} | ||
// skip clicks on controls | ||
@@ -1653,5 +1690,3 @@ if (event2.originalEvent.target.closest('.leaflet-control-container')) { | ||
} | ||
// separate polyline and polygon, so that it is rendered unclosed | ||
this.polyline = L.polyline([event2.latlng], this.options.polygon).addTo(this.map); | ||
this.polygon = L.polygon([event2.latlng], __assign({}, this.options.polygon, { weight: 0 })).addTo(this.map); | ||
this.polygon = new LassoPolygon([event2.latlng], this.options.polygon).addTo(this.map); | ||
document.body.classList.add(ACTIVE_CLASS); | ||
@@ -1662,12 +1697,13 @@ document.addEventListener('mousemove', this.onDocumentMouseMoveBound); | ||
LassoHandler.prototype.onDocumentMouseMove = function (event) { | ||
if (!this.polyline || !this.polygon) { | ||
if (!this.polygon) { | ||
return; | ||
} | ||
var event2 = event; | ||
this.polyline.addLatLng(this.map.mouseEventToLatLng(event2)); | ||
this.polygon.addLatLng(this.map.mouseEventToLatLng(event2)); | ||
if (event2.buttons === 0) { | ||
// keep lasso active only if left mouse button is hold | ||
if (event2.buttons !== 1) { | ||
console.warn('mouseup event was missed'); | ||
this.finish(); | ||
return; | ||
} | ||
this.polygon.addLatLng(this.map.mouseEventToLatLng(event2)); | ||
}; | ||
@@ -1679,3 +1715,3 @@ LassoHandler.prototype.onDocumentMouseUp = function () { | ||
var _this = this; | ||
if (!this.polyline || !this.polygon) { | ||
if (!this.polygon) { | ||
return; | ||
@@ -1686,3 +1722,3 @@ } | ||
this.map.eachLayer(function (layer) { | ||
if (layer === _this.polyline || layer === _this.polygon) { | ||
if (layer === _this.polygon || layer === _this.polygon.polyline || layer === _this.polygon.polygon) { | ||
return; | ||
@@ -1703,8 +1739,6 @@ } | ||
this.map.fire(FINISHED_EVENT, { | ||
latLngs: this.polygon.getLatLngs()[0], | ||
latLngs: this.polygon.getLatLngs(), | ||
layers: selectedFeatures, | ||
}); | ||
this.map.removeLayer(this.polyline); | ||
this.map.removeLayer(this.polygon); | ||
this.polyline = undefined; | ||
this.polygon = undefined; | ||
@@ -1711,0 +1745,0 @@ this.disable(); |
@@ -1,2 +0,2 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("leaflet")):"function"==typeof define&&define.amd?define(["exports","leaflet"],e):e((t=t||self).LeafletLasso={},t.L)}(this,function(t,e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])})(t,e)};function n(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var r=function(){return(r=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)},i="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var s=function(t,e){return t(e={exports:{}},e.exports),e.exports}(function(t,e){var o,n;o=i,n=function(){var t={},e=6378137,o=57.29577951308232,n=.017453292519943,r={type:"link",properties:{href:"http://spatialreference.org/ref/sr-org/6928/ogcwkt/",type:"ogcwkt"}};function i(t){return"[object Array]"===Object.prototype.toString.call(t)}function s(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o]);return t}function a(t){if(t.type)switch(t.type){case"Point":return[t.coordinates[0],t.coordinates[1],t.coordinates[0],t.coordinates[1]];case"MultiPoint":case"LineString":return u(t.coordinates);case"MultiLineString":case"Polygon":return l(t.coordinates);case"MultiPolygon":return function(t){for(var e=null,o=null,n=null,r=null,i=0;i<t.length;i++)for(var s=t[i],a=0;a<s.length;a++)for(var l=s[a],u=0;u<l.length;u++){var c=l[u],h=c[0],p=c[1];null===e?e=h:h<e&&(e=h),null===o?o=h:h>o&&(o=h),null===n?n=p:p<n&&(n=p),null===r?r=p:p>r&&(r=p)}return[e,n,o,r]}(t.coordinates);case"Feature":return t.geometry?a(t.geometry):null;case"FeatureCollection":return function(t){for(var e,o=[],n=t.features.length-1;n>=0;n--)e=a(t.features[n].geometry),o.push([e[0],e[1]]),o.push([e[2],e[3]]);return u(o)}(t);case"GeometryCollection":return function(t){for(var e,o=[],n=t.geometries.length-1;n>=0;n--)e=a(t.geometries[n]),o.push([e[0],e[1]]),o.push([e[2],e[3]]);return u(o)}(t);default:throw new Error("Unknown type: "+t.type)}return null}function l(t){for(var e=null,o=null,n=null,r=null,i=0;i<t.length;i++)for(var s=t[i],a=0;a<s.length;a++){var l=s[a],u=l[0],c=l[1];null===e?e=u:u<e&&(e=u),null===o?o=u:u>o&&(o=u),null===n?n=c:c<n&&(n=c),null===r?r=c:c>r&&(r=c)}return[e,n,o,r]}function u(t){for(var e=null,o=null,n=null,r=null,i=0;i<t.length;i++){var s=t[i],a=s[0],l=s[1];null===e?e=a:a<e&&(e=a),null===o?o=a:a>o&&(o=a),null===n?n=l:l<n&&(n=l),null===r?r=l:l>r&&(r=l)}return[e,n,o,r]}function c(t){var e=a(t);return{x:e[0],y:e[1],w:Math.abs(e[0]-e[2]),h:Math.abs(e[1]-e[3])}}function h(t){return t*o}function p(t){return t*n}function f(t){var o=t[0],n=t[1];return[h(o/e)-360*Math.floor((h(o/e)+180)/360),h(Math.PI/2-2*Math.atan(Math.exp(-1*n/e)))]}function d(t){var o=t[0],n=Math.max(Math.min(t[1],89.99999),-89.99999);return[p(o)*e,e/2*Math.log((1+Math.sin(p(n)))/(1-Math.sin(p(n))))]}function y(t,e,o){if("Point"===t.type)t.coordinates=e(t.coordinates);else if("Feature"===t.type)t.geometry=y(t.geometry,e,!0);else if("FeatureCollection"===t.type)for(var n=0;n<t.features.length;n++)t.features[n]=y(t.features[n],e,!0);else if("GeometryCollection"===t.type)for(var i=0;i<t.geometries.length;i++)t.geometries[i]=y(t.geometries[i],e,!0);else t.coordinates=function t(e,o){for(var n=0;n<e.length;n++)"number"==typeof e[n][0]&&(e[n]=o(e[n])),"object"==typeof e[n]&&(e[n]=t(e[n],o));return e}(t.coordinates,e);return o||e===d&&(t.crs=r),e===f&&delete t.crs,t}function g(t){return y(t,d)}function v(t){return y(t,f)}function m(t,e){return t[0]>e[0]?-1:t[0]<e[0]?1:t[1]>e[1]?-1:t[1]<e[1]?1:0}function M(t,e,o){return(n=(e[0]-t[0])*(o[1]-t[1])-(o[0]-t[0])*(e[1]-t[1]))<(r=0)?-1:n>r?1:0;var n,r}function w(t,e){var o=e[0]-t[0],n=e[1]-t[1];return o*o+n*n}function P(t,e){var o=e;for(var n in t){var r=M(e,o,t[n]);(-1===r||0===r&&w(e,t[n])>w(e,o))&&(o=t[n])}return o}function A(t){if(0===t.length)return[];if(1===t.length)return t;for(var e=[t.sort(m)[0]],o=0;o<e.length;o++){var n=P(t,e[o]);n!==e[0]&&e.push(n)}return e}function b(t,e){for(var o=!1,n=-1,r=t.length,i=r-1;++n<r;i=n)(t[n][1]<=e[1]&&e[1]<t[i][1]||t[i][1]<=e[1]&&e[1]<t[n][1])&&e[0]<(t[i][0]-t[n][0])*(e[1]-t[n][1])/(t[i][1]-t[n][1])+t[n][0]&&(o=!o);return o}function L(t,e){if(t&&t.length){if(1===t.length)return b(t[0],e);if(b(t[0],e)){for(var o=1;o<t.length;o++)if(b(t[o],e))return!1;return!0}return!1}return!1}function S(t,e,o,n){var r=(n[0]-o[0])*(t[1]-o[1])-(n[1]-o[1])*(t[0]-o[0]),i=(e[0]-t[0])*(t[1]-o[1])-(e[1]-t[1])*(t[0]-o[0]),s=(n[1]-o[1])*(e[0]-t[0])-(n[0]-o[0])*(e[1]-t[1]);if(0!==s){var a=r/s,l=i/s;if(0<=a&&a<=1&&0<=l&&l<=1)return!0}return!1}function T(t){return!isNaN(parseFloat(t))&&isFinite(t)}function C(t,e){if(T(t[0][0])){if(T(e[0][0])){for(var o=0;o<t.length-1;o++)for(var n=0;n<e.length-1;n++)if(S(t[o],t[o+1],e[n],e[n+1]))return!0}else for(var r=0;r<e.length;r++)if(C(t,e[r]))return!0}else for(var i=0;i<t.length;i++)if(C(t[i],e))return!0;return!1}function E(t){for(var e=[],o=0;o<t.length;o++){var n=t[o].slice();!1===D(n[0],n[n.length-1])&&n.push(n[0]),e.push(n)}return e}function D(t,e){for(var o=0;o<t.length;o++)if(t[o]!==e[o])return!1;return!0}function F(t,e){if(t.length!==e.length)return!1;for(var o=t.slice().sort(m),n=e.slice().sort(m),r=0;r<o.length;r++){if(o[r].length!==n[r].length)return!1;for(var i=0;i<o.length;i++)if(o[r][i]!==n[r][i])return!1}return!0}var I=["length"];function x(t){if(t)switch(t.type){case"Point":return new O(t);case"MultiPoint":return new k(t);case"LineString":return new G(t);case"MultiLineString":return new U(t);case"Polygon":return new B(t);case"MultiPolygon":return new R(t);case"Feature":return new H(t);case"FeatureCollection":return new N(t);case"GeometryCollection":return new V(t);default:throw new Error("Unknown type: "+t.type)}}function O(t){var e=Array.prototype.slice.call(arguments);if(t&&"Point"===t.type&&t.coordinates)s(this,t);else if(t&&i(t))this.coordinates=t;else{if(!(e.length>=2))throw"Terraformer: invalid input for Terraformer.Point";this.coordinates=e}this.type="Point"}function k(t){if(t&&"MultiPoint"===t.type&&t.coordinates)s(this,t);else{if(!i(t))throw"Terraformer: invalid input for Terraformer.MultiPoint";this.coordinates=t}this.type="MultiPoint"}function G(t){if(t&&"LineString"===t.type&&t.coordinates)s(this,t);else{if(!i(t))throw"Terraformer: invalid input for Terraformer.LineString";this.coordinates=t}this.type="LineString"}function U(t){if(t&&"MultiLineString"===t.type&&t.coordinates)s(this,t);else{if(!i(t))throw"Terraformer: invalid input for Terraformer.MultiLineString";this.coordinates=t}this.type="MultiLineString"}function B(t){if(t&&"Polygon"===t.type&&t.coordinates)s(this,t);else{if(!i(t))throw"Terraformer: invalid input for Terraformer.Polygon";this.coordinates=t}this.type="Polygon"}function R(t){if(t&&"MultiPolygon"===t.type&&t.coordinates)s(this,t);else{if(!i(t))throw"Terraformer: invalid input for Terraformer.MultiPolygon";this.coordinates=t}this.type="MultiPolygon"}function H(t){if(t&&"Feature"===t.type)s(this,t);else{if(!(t&&t.type&&t.coordinates))throw"Terraformer: invalid input for Terraformer.Feature";this.geometry=t}this.type="Feature"}function N(t){if(t&&"FeatureCollection"===t.type&&t.features)s(this,t);else{if(!i(t))throw"Terraformer: invalid input for Terraformer.FeatureCollection";this.features=t}this.type="FeatureCollection"}function V(t){if(t&&"GeometryCollection"===t.type&&t.geometries)s(this,t);else if(i(t))this.geometries=t;else{if(!t.coordinates||!t.type)throw"Terraformer: invalid input for Terraformer.GeometryCollection";this.type="GeometryCollection",this.geometries=[t]}this.type="GeometryCollection"}function Q(t,e,o){for(var n=d(t),r=o||64,i={type:"Polygon",coordinates:[[]]},s=1;s<=r;s++){var a=s*(360/r)*Math.PI/180;i.coordinates[0].push([n[0]+e*Math.cos(a),n[1]+e*Math.sin(a)])}return i.coordinates=E(i.coordinates),v(i)}function K(t,e,o){var n=o||64,r=e||250;if(!t||t.length<2||!r||!n)throw new Error("Terraformer: missing parameter for Terraformer.Circle");s(this,new H({type:"Feature",geometry:Q(t,r,n),properties:{radius:r,center:t,steps:n}}))}return x.prototype.toMercator=function(){return g(this)},x.prototype.toGeographic=function(){return v(this)},x.prototype.envelope=function(){return c(this)},x.prototype.bbox=function(){return a(this)},x.prototype.convexHull=function(){var t,e,o=[];if("Point"===this.type)return null;if("LineString"===this.type||"MultiPoint"===this.type){if(!(this.coordinates&&this.coordinates.length>=3))return null;o=this.coordinates}else if("Polygon"===this.type||"MultiLineString"===this.type){if(!(this.coordinates&&this.coordinates.length>0))return null;for(t=0;t<this.coordinates.length;t++)o=o.concat(this.coordinates[t]);if(o.length<3)return null}else if("MultiPolygon"===this.type){if(!(this.coordinates&&this.coordinates.length>0))return null;for(t=0;t<this.coordinates.length;t++)for(e=0;e<this.coordinates[t].length;e++)o=o.concat(this.coordinates[t][e]);if(o.length<3)return null}else if("Feature"===this.type){return new x(this.geometry).convexHull()}return new B({type:"Polygon",coordinates:E([A(o)])})},x.prototype.toJSON=function(){var t={};for(var e in this)this.hasOwnProperty(e)&&-1===I.indexOf(e)&&(t[e]=this[e]);return t.bbox=a(this),t},x.prototype.contains=function(t){return new x(t).within(this)},x.prototype.within=function(t){var e,o;if("Feature"===t.type&&(t=t.geometry),"Point"===t.type&&"Point"===this.type)return D(this.coordinates,t.coordinates);if("MultiLineString"===t.type&&"Point"===this.type)for(e=0;e<t.coordinates.length;e++){var n={type:"LineString",coordinates:t.coordinates[e]};if(this.within(n))return!0}if(("LineString"===t.type||"MultiPoint"===t.type)&&"Point"===this.type)for(e=0;e<t.coordinates.length;e++){if(this.coordinates.length!==t.coordinates[e].length)return!1;if(D(this.coordinates,t.coordinates[e]))return!0}if("Polygon"===t.type){if("Polygon"===this.type){if(t.coordinates.length===this.coordinates.length)for(e=0;e<this.coordinates.length;e++)if(F(this.coordinates[e],t.coordinates[e]))return!0;return!(!this.coordinates.length||!L(t.coordinates,this.coordinates[0][0]))&&!C(E(this.coordinates),E(t.coordinates))}if("Point"===this.type)return L(t.coordinates,this.coordinates);if("LineString"===this.type||"MultiPoint"===this.type){if(!this.coordinates||0===this.coordinates.length)return!1;for(e=0;e<this.coordinates.length;e++)if(!1===L(t.coordinates,this.coordinates[e]))return!1;return!0}if("MultiLineString"===this.type){for(e=0;e<this.coordinates.length;e++){if(!1===new G(this.coordinates[e]).within(t))return o++,!1}return!0}if("MultiPolygon"===this.type){for(e=0;e<this.coordinates.length;e++){if(!1===new x({type:"Polygon",coordinates:this.coordinates[e]}).within(t))return!1}return!0}}if("MultiPolygon"===t.type){if("Point"===this.type){if(t.coordinates.length)for(e=0;e<t.coordinates.length;e++)if(L(t.coordinates[e],this.coordinates)&&!1===C([this.coordinates],t.coordinates))return!0;return!1}if("Polygon"===this.type){for(e=0;e<this.coordinates.length;e++)if(t.coordinates[e].length===this.coordinates.length)for(j=0;j<this.coordinates.length;j++)if(F(this.coordinates[j],t.coordinates[e][j]))return!0;if(!1===C(this.coordinates,t.coordinates)&&t.coordinates.length){for(e=0;e<t.coordinates.length;e++)o=!1!==L(t.coordinates[e],this.coordinates[0][0]);return o}}else if("LineString"===this.type||"MultiPoint"===this.type)for(e=0;e<t.coordinates.length;e++){var r={type:"Polygon",coordinates:t.coordinates[e]};return!!this.within(r)}else{if("MultiLineString"===this.type){for(e=0;e<this.coordinates.length;e++){if(!1===new G(this.coordinates[e]).within(t))return!1}return!0}if("MultiPolygon"===this.type){for(e=0;e<t.coordinates.length;e++){var i={type:"Polygon",coordinates:t.coordinates[e]};if(!1===this.within(i))return!1}return!0}}}return!1},x.prototype.intersects=function(t){"Feature"===t.type&&(t=t.geometry);var e=new x(t);return!(!this.within(t)&&!e.within(this))||("Point"!==this.type&&"MultiPoint"!==this.type&&"Point"!==t.type&&"MultiPoint"!==t.type?C(this.coordinates,t.coordinates):"Feature"===this.type?new x(this.geometry).intersects(t):(function(){var t=Array.prototype.slice.apply(arguments);void 0!==typeof console&&console.warn&&console.warn.apply(console,t)}("Type "+this.type+" to "+t.type+" intersection is not supported by intersects"),!1))},O.prototype=new x,O.prototype.constructor=O,k.prototype=new x,k.prototype.constructor=k,k.prototype.forEach=function(t){for(var e=0;e<this.coordinates.length;e++)t.apply(this,[this.coordinates[e],e,this.coordinates]);return this},k.prototype.addPoint=function(t){return this.coordinates.push(t),this},k.prototype.insertPoint=function(t,e){return this.coordinates.splice(e,0,t),this},k.prototype.removePoint=function(t){return"number"==typeof t?this.coordinates.splice(t,1):this.coordinates.splice(this.coordinates.indexOf(t),1),this},k.prototype.get=function(t){return new O(this.coordinates[t])},G.prototype=new x,G.prototype.constructor=G,G.prototype.addVertex=function(t){return this.coordinates.push(t),this},G.prototype.insertVertex=function(t,e){return this.coordinates.splice(e,0,t),this},G.prototype.removeVertex=function(t){return this.coordinates.splice(t,1),this},U.prototype=new x,U.prototype.constructor=U,U.prototype.forEach=function(t){for(var e=0;e<this.coordinates.length;e++)t.apply(this,[this.coordinates[e],e,this.coordinates])},U.prototype.get=function(t){return new G(this.coordinates[t])},B.prototype=new x,B.prototype.constructor=B,B.prototype.addVertex=function(t){return this.insertVertex(t,this.coordinates[0].length-1),this},B.prototype.insertVertex=function(t,e){return this.coordinates[0].splice(e,0,t),this},B.prototype.removeVertex=function(t){return this.coordinates[0].splice(t,1),this},B.prototype.close=function(){this.coordinates=E(this.coordinates)},B.prototype.hasHoles=function(){return this.coordinates.length>1},B.prototype.holes=function(){if(holes=[],this.hasHoles())for(var t=1;t<this.coordinates.length;t++)holes.push(new B([this.coordinates[t]]));return holes},R.prototype=new x,R.prototype.constructor=R,R.prototype.forEach=function(t){for(var e=0;e<this.coordinates.length;e++)t.apply(this,[this.coordinates[e],e,this.coordinates])},R.prototype.get=function(t){return new B(this.coordinates[t])},R.prototype.close=function(){var t=[];return this.forEach(function(e){t.push(E(e))}),this.coordinates=t,this},H.prototype=new x,H.prototype.constructor=H,N.prototype=new x,N.prototype.constructor=N,N.prototype.forEach=function(t){for(var e=0;e<this.features.length;e++)t.apply(this,[this.features[e],e,this.features])},N.prototype.get=function(t){var e;return this.forEach(function(o){o.id===t&&(e=o)}),new H(e)},V.prototype=new x,V.prototype.constructor=V,V.prototype.forEach=function(t){for(var e=0;e<this.geometries.length;e++)t.apply(this,[this.geometries[e],e,this.geometries])},V.prototype.get=function(t){return new x(this.geometries[t])},K.prototype=new x,K.prototype.constructor=K,K.prototype.recalculate=function(){return this.geometry=Q(this.properties.center,this.properties.radius,this.properties.steps),this},K.prototype.center=function(t){return t&&(this.properties.center=t,this.recalculate()),this.properties.center},K.prototype.radius=function(t){return t&&(this.properties.radius=t,this.recalculate()),this.properties.radius},K.prototype.steps=function(t){return t&&(this.properties.steps=t,this.recalculate()),this.properties.steps},K.prototype.toJSON=function(){return x.prototype.toJSON.call(this)},t.Primitive=x,t.Point=O,t.MultiPoint=k,t.LineString=G,t.MultiLineString=U,t.Polygon=B,t.MultiPolygon=R,t.Feature=H,t.FeatureCollection=N,t.GeometryCollection=V,t.Circle=K,t.toMercator=g,t.toGeographic=v,t.Tools={},t.Tools.positionToMercator=d,t.Tools.positionToGeographic=f,t.Tools.applyConverter=y,t.Tools.toMercator=g,t.Tools.toGeographic=v,t.Tools.createCircle=Q,t.Tools.calculateBounds=a,t.Tools.calculateEnvelope=c,t.Tools.coordinatesContainPoint=b,t.Tools.polygonContainsPoint=L,t.Tools.arraysIntersectArrays=C,t.Tools.coordinatesContainPoint=b,t.Tools.coordinatesEqual=F,t.Tools.convexHull=A,t.Tools.isConvex=function(t){for(var e,o=0;o<t.length-3;o++){var n=t[o],r=t[o+1],i=t[o+2],s=[r[0]-n[0],r[1]-n[1]],a=i[0]*s[1]-i[1]*s[0]+s[0]*n[1]-s[1]*n[0];if(0===o)e=a<0;else if(e&&a>0||!e&&a<0)return!1}return!0},t.MercatorCRS=r,t.GeographicCRS={type:"link",properties:{href:"http://spatialreference.org/ref/epsg/4326/ogcwkt/",type:"ogcwkt"}},t},t.exports=n(),"object"==typeof window&&(o.Terraformer=n())});function a(t){return t*Math.PI/180}function l(t){return 180*t/Math.PI}var u=function(t,e,o){for(var n,r,i,s,u,c,h,p=o||32,f=[],d=[],y=0;y<p;++y)f.push.apply(f,(n=t,r=e,i=2*Math.PI*y/p,s=void 0,u=void 0,c=void 0,h=void 0,s=a(n[1]),u=a(n[0]),c=r/6378137,h=Math.asin(Math.sin(s)*Math.cos(c)+Math.cos(s)*Math.sin(c)*Math.cos(i)),[l(u+Math.atan2(Math.sin(i)*Math.sin(c)*Math.cos(s),Math.cos(c)-Math.sin(s)*Math.sin(h))),l(h)]));f.push(f[0],f[1]);y=0;for(var g=0;g<f.length;g+=2)d[y++]=f.slice(g,g+2);return{type:"Polygon",coordinates:[d.reverse()]}};function c(t,o){return u(e.GeoJSON.latLngToCoords(t),o)}function h(t,o,n){void 0===n&&(n={});var r=n.crs||e.CRS.EPSG3857,i=new s.Primitive(t);return o.filter(function(t){var o;if(t instanceof e.Circle)o=c(t.getLatLng(),t.getRadius());else if(t instanceof e.CircleMarker){if(null!=n.zoom)o=c(t.getLatLng(),function(t,o,n){var r=t.getLatLng(),i=o.latLngToPoint(r,n),s=t.getRadius()/Math.SQRT2,a=e.point([i.x-s,i.y-s]),l=o.pointToLatLng(a,n);return o.distance(r,l)}(t,r,n.zoom));else console.warn("Zoom is required for calculating CircleMarker polygon, falling back to center point only"),o=t.toGeoJSON().geometry}else{if(!(t instanceof e.Marker||t instanceof e.Polyline))return!1;o=t.toGeoJSON().geometry}return n.intersect&&"Point"!==o.type?i.intersects(o):i.contains(o)})}function p(t,e){void 0===e&&(e={});var o=e.insertAt;if(t&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===o&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=t:r.appendChild(document.createTextNode(t))}}p(".leaflet-lasso-active {\n cursor: crosshair;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n\n.leaflet-lasso-active .leaflet-interactive {\n cursor: crosshair;\n pointer-events: none;\n}");var f="leaflet-lasso-active",d=function(t){function o(o,n){void 0===n&&(n={});var r=t.call(this,o)||this;return r.options={polygon:{color:"#00C3FF",weight:2},intersect:!1},r.onDocumentMouseMoveBound=r.onDocumentMouseMove.bind(r),r.onDocumentMouseUpBound=r.onDocumentMouseUp.bind(r),r.map=o,e.Util.setOptions(r,n),r}return n(o,t),o.prototype.setOptions=function(t){this.options=r({},this.options,t)},o.prototype.toggle=function(){this.enabled()?this.disable():this.enable()},o.prototype.addHooks=function(){this.map.getPane("mapPane"),this.map.on("mousedown",this.onMapMouseDown,this),this.map.getContainer().classList.add(f),this.map.dragging.disable(),this.map.fire("lasso.enabled")},o.prototype.removeHooks=function(){this.map.off("mousedown",this.onMapMouseDown,this),document.removeEventListener("mousemove",this.onDocumentMouseMoveBound),document.removeEventListener("mouseup",this.onDocumentMouseUpBound),this.map.getContainer().classList.remove(f),document.body.classList.remove(f),this.map.dragging.enable(),this.map.fire("lasso.disabled")},o.prototype.onMapMouseDown=function(t){var o=t;o.originalEvent.target.closest(".leaflet-control-container")||(this.polyline=e.polyline([o.latlng],this.options.polygon).addTo(this.map),this.polygon=e.polygon([o.latlng],r({},this.options.polygon,{weight:0})).addTo(this.map),document.body.classList.add(f),document.addEventListener("mousemove",this.onDocumentMouseMoveBound),document.addEventListener("mouseup",this.onDocumentMouseUpBound))},o.prototype.onDocumentMouseMove=function(t){if(this.polyline&&this.polygon){var e=t;this.polyline.addLatLng(this.map.mouseEventToLatLng(e)),this.polygon.addLatLng(this.map.mouseEventToLatLng(e)),0===e.buttons&&(console.warn("mouseup event was missed"),this.finish())}},o.prototype.onDocumentMouseUp=function(){this.finish()},o.prototype.finish=function(){var t=this;if(this.polyline&&this.polygon){var o=this.polygon.toGeoJSON().geometry,n=[];this.map.eachLayer(function(o){o!==t.polyline&&o!==t.polygon&&(o instanceof e.Marker||o instanceof e.Path?n.push(o):e.MarkerCluster&&o instanceof e.MarkerCluster&&n.push.apply(n,o.getAllChildMarkers()))});var r=h(o,n,{zoom:this.map.getZoom(),crs:this.map.options.crs,intersect:this.options.intersect});this.map.fire("lasso.finished",{latLngs:this.polygon.getLatLngs()[0],layers:r}),this.map.removeLayer(this.polyline),this.map.removeLayer(this.polygon),this.polyline=void 0,this.polygon=void 0,this.disable()}},o}(e.Handler);p(".leaflet-control-lasso {\n background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsSAAALEgHS3X78AAAD6UlEQVR4nO1b7XHbMAwFfP0fdYKqE8QbRJ0gGUEjaAR3A4/gbuBOUHWCKhs4E1SegD06jzmYpWhJpiRKNu58Tix+AA8gCQIQK6Xolml109LfAbgDcAfg5gH4NPQEzJwSkf4kRLR2NKmJqNLfSqlqaH7+4y/0McjML0SUQdinHkO8ApCSiPZKqToogxYFAQBC50T03NDkN74raFzSGtahreSLo+9PALG7mlEXaQD6fMD0BgIp8TkQ0ZaINChpl7ExZoZxK2vcGr8nfXl2ztm5g1twI/Q6KHPvVlFg/DMgJgEAWpWCay3lIYX2zJ1bQFQhAO+i9b2l8VEEd/BSWEooBgUAm5REPvg67AGCrZDdIABgQ6qF1oOu8QBAbK4FwTd4bq23SbXeks/OIPg0f7V5TQRCpz3BNdhamH30wgu+CwFC66VqD5IIByRas/eAYDbGqi8AW+FszEp4ocC6y1KQneW6z+YmvJDDLIVDVwBKdNzPVXghi/FbLjprp4AIM2fi6loMcusal8zN8eXirOp885jNrn/BAlKxnL17GWPj+As8viqlDguwAG3V+hR7JKJvSqmyqd1KmMnrUoQHGaEzX6OVaLAfg6sRyUSeUt+UKxGobDSTmZKR5yIAj/h79IhsDPSRFxg6+ho9AAukpI1IgydGxiY4dSRON+/SXgwAyE1sHbkF79JmeEuaPs91H4DWf+Ffk1nSgDwQ0RH5iUbZqgXcAI0MG/FbKn7f+i5DZo14PabISR/lb0qpjWETXq252LmSsidaCYfh8s0pbnKZuFHuEzNvmNl5MiR9YmmRLYHaxb8VJ3SG+UzD3ZyvwyI/UEPozMoZFE2xTjOADId1yuhGBMLO0raSUSE74HsGgDoPiZULsIISPkFqtUlEuOx0YsiHadeIakTC57bGPW0zAVRiP+yVXJhY+M6JHLFcCtfDvUAoahCseoXW0Wz0Oy1310O5WUQLgmX2ZddEzkffhoc2CJMUQ3h4kzt+v7S4ke/CRKWYaBtBYURmF2tcMda7bC0absWEk5TG4ISyS3Suury1BqAB+XIMIDCv7eAEsUTvHtDQoak8bhPSexSlcXadYBlqHu8p0BMIZRVIti9QeD/Hc/S1hVawgKDuufQDriqVZeYcAjeVyL4BGBc1lcaSKY8dolaYmTXgf0ykKFStcCIKpM33Q8vuR1EcXeEuMkhoDnyWCKB81wGUQV+aEhFaJ/mSlgPwYvyHZ8QN9SlS38RbY3hnYQ/NHyH8KVq0+DdGdCgMS+sRe1ImX8xYvAUw8wGb7Q9c88/2l1sAIEPBlPM0ur85GgEPk9IdgAh4mJTuAETAw3RERP8Ab2Uzgrad13wAAAAASUVORK5CYII=');\n background-size: 22px;\n}");var y=function(t){function o(o){void 0===o&&(o={});var n=t.call(this)||this;return n.options={position:"topright"},e.Util.setOptions(n,o),n}return n(o,t),o.prototype.setOptions=function(t){this.options=r({},this.options,t),this.lasso&&this.lasso.setOptions(this.options)},o.prototype.onAdd=function(t){this.lasso=new d(t,this.options);var o=e.DomUtil.create("div","leaflet-bar leaflet-control"),n=e.DomUtil.create("a","leaflet-control-lasso",o);return n.href="#",n.title="Toggle Lasso",n.setAttribute("role","button"),n.setAttribute("aria-label",n.title),e.DomEvent.addListener(n,"click",this.toggle,this),o},o.prototype.enabled=function(){return!!this.lasso&&this.lasso.enabled()},o.prototype.enable=function(){this.lasso&&this.lasso.enable()},o.prototype.disable=function(){this.lasso&&this.lasso.disable()},o.prototype.toggle=function(){this.lasso&&this.lasso.toggle()},o}(e.Control);e.Lasso=d,e.lasso=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new(d.bind.apply(d,[void 0].concat(t)))},e.Control.Lasso=y,e.control.lasso=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new(y.bind.apply(y,[void 0].concat(t)))},t.ACTIVE_CLASS=f,t.DISABLED_EVENT="lasso.disabled",t.ENABLED_EVENT="lasso.enabled",t.FINISHED_EVENT="lasso.finished",t.LassoControl=y,t.LassoHandler=d,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("leaflet")):"function"==typeof define&&define.amd?define(["exports","leaflet"],e):e((t=t||self).LeafletLasso={},t.L)}(this,function(t,e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var o=function(t,e){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o])})(t,e)};function n(t,e){function n(){this.constructor=t}o(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var r=function(){return(r=Object.assign||function(t){for(var e,o=1,n=arguments.length;o<n;o++)for(var r in e=arguments[o])Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t}).apply(this,arguments)},i=function(t){function o(o,n){var i=t.call(this)||this;return i.polyline=e.polyline(o,n),i.polygon=e.polygon(o,r({},n,{weight:0})),i}return n(o,t),o.prototype.onAdd=function(t){return this.polyline.addTo(t),this.polygon.addTo(t),this},o.prototype.onRemove=function(){return this.polyline.remove(),this.polygon.remove(),this},o.prototype.addLatLng=function(t){return this.polyline.addLatLng(t),this.polygon.addLatLng(t),this},o.prototype.getLatLngs=function(){return this.polygon.getLatLngs()[0]},o.prototype.toGeoJSON=function(){return this.polygon.toGeoJSON()},o}(e.Layer),s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var a=function(t,e){return t(e={exports:{}},e.exports),e.exports}(function(t,e){var o,n;o=s,n=function(){var t={},e=6378137,o=57.29577951308232,n=.017453292519943,r={type:"link",properties:{href:"http://spatialreference.org/ref/sr-org/6928/ogcwkt/",type:"ogcwkt"}};function i(t){return"[object Array]"===Object.prototype.toString.call(t)}function s(t,e){for(var o in e)e.hasOwnProperty(o)&&(t[o]=e[o]);return t}function a(t){if(t.type)switch(t.type){case"Point":return[t.coordinates[0],t.coordinates[1],t.coordinates[0],t.coordinates[1]];case"MultiPoint":case"LineString":return u(t.coordinates);case"MultiLineString":case"Polygon":return l(t.coordinates);case"MultiPolygon":return function(t){for(var e=null,o=null,n=null,r=null,i=0;i<t.length;i++)for(var s=t[i],a=0;a<s.length;a++)for(var l=s[a],u=0;u<l.length;u++){var c=l[u],h=c[0],p=c[1];null===e?e=h:h<e&&(e=h),null===o?o=h:h>o&&(o=h),null===n?n=p:p<n&&(n=p),null===r?r=p:p>r&&(r=p)}return[e,n,o,r]}(t.coordinates);case"Feature":return t.geometry?a(t.geometry):null;case"FeatureCollection":return function(t){for(var e,o=[],n=t.features.length-1;n>=0;n--)e=a(t.features[n].geometry),o.push([e[0],e[1]]),o.push([e[2],e[3]]);return u(o)}(t);case"GeometryCollection":return function(t){for(var e,o=[],n=t.geometries.length-1;n>=0;n--)e=a(t.geometries[n]),o.push([e[0],e[1]]),o.push([e[2],e[3]]);return u(o)}(t);default:throw new Error("Unknown type: "+t.type)}return null}function l(t){for(var e=null,o=null,n=null,r=null,i=0;i<t.length;i++)for(var s=t[i],a=0;a<s.length;a++){var l=s[a],u=l[0],c=l[1];null===e?e=u:u<e&&(e=u),null===o?o=u:u>o&&(o=u),null===n?n=c:c<n&&(n=c),null===r?r=c:c>r&&(r=c)}return[e,n,o,r]}function u(t){for(var e=null,o=null,n=null,r=null,i=0;i<t.length;i++){var s=t[i],a=s[0],l=s[1];null===e?e=a:a<e&&(e=a),null===o?o=a:a>o&&(o=a),null===n?n=l:l<n&&(n=l),null===r?r=l:l>r&&(r=l)}return[e,n,o,r]}function c(t){var e=a(t);return{x:e[0],y:e[1],w:Math.abs(e[0]-e[2]),h:Math.abs(e[1]-e[3])}}function h(t){return t*o}function p(t){return t*n}function f(t){var o=t[0],n=t[1];return[h(o/e)-360*Math.floor((h(o/e)+180)/360),h(Math.PI/2-2*Math.atan(Math.exp(-1*n/e)))]}function y(t){var o=t[0],n=Math.max(Math.min(t[1],89.99999),-89.99999);return[p(o)*e,e/2*Math.log((1+Math.sin(p(n)))/(1-Math.sin(p(n))))]}function d(t,e,o){if("Point"===t.type)t.coordinates=e(t.coordinates);else if("Feature"===t.type)t.geometry=d(t.geometry,e,!0);else if("FeatureCollection"===t.type)for(var n=0;n<t.features.length;n++)t.features[n]=d(t.features[n],e,!0);else if("GeometryCollection"===t.type)for(var i=0;i<t.geometries.length;i++)t.geometries[i]=d(t.geometries[i],e,!0);else t.coordinates=function t(e,o){for(var n=0;n<e.length;n++)"number"==typeof e[n][0]&&(e[n]=o(e[n])),"object"==typeof e[n]&&(e[n]=t(e[n],o));return e}(t.coordinates,e);return o||e===y&&(t.crs=r),e===f&&delete t.crs,t}function g(t){return d(t,y)}function v(t){return d(t,f)}function m(t,e){return t[0]>e[0]?-1:t[0]<e[0]?1:t[1]>e[1]?-1:t[1]<e[1]?1:0}function M(t,e,o){return(n=(e[0]-t[0])*(o[1]-t[1])-(o[0]-t[0])*(e[1]-t[1]))<(r=0)?-1:n>r?1:0;var n,r}function w(t,e){var o=e[0]-t[0],n=e[1]-t[1];return o*o+n*n}function P(t,e){var o=e;for(var n in t){var r=M(e,o,t[n]);(-1===r||0===r&&w(e,t[n])>w(e,o))&&(o=t[n])}return o}function A(t){if(0===t.length)return[];if(1===t.length)return t;for(var e=[t.sort(m)[0]],o=0;o<e.length;o++){var n=P(t,e[o]);n!==e[0]&&e.push(n)}return e}function L(t,e){for(var o=!1,n=-1,r=t.length,i=r-1;++n<r;i=n)(t[n][1]<=e[1]&&e[1]<t[i][1]||t[i][1]<=e[1]&&e[1]<t[n][1])&&e[0]<(t[i][0]-t[n][0])*(e[1]-t[n][1])/(t[i][1]-t[n][1])+t[n][0]&&(o=!o);return o}function b(t,e){if(t&&t.length){if(1===t.length)return L(t[0],e);if(L(t[0],e)){for(var o=1;o<t.length;o++)if(L(t[o],e))return!1;return!0}return!1}return!1}function S(t,e,o,n){var r=(n[0]-o[0])*(t[1]-o[1])-(n[1]-o[1])*(t[0]-o[0]),i=(e[0]-t[0])*(t[1]-o[1])-(e[1]-t[1])*(t[0]-o[0]),s=(n[1]-o[1])*(e[0]-t[0])-(n[0]-o[0])*(e[1]-t[1]);if(0!==s){var a=r/s,l=i/s;if(0<=a&&a<=1&&0<=l&&l<=1)return!0}return!1}function T(t){return!isNaN(parseFloat(t))&&isFinite(t)}function C(t,e){if(T(t[0][0])){if(T(e[0][0])){for(var o=0;o<t.length-1;o++)for(var n=0;n<e.length-1;n++)if(S(t[o],t[o+1],e[n],e[n+1]))return!0}else for(var r=0;r<e.length;r++)if(C(t,e[r]))return!0}else for(var i=0;i<t.length;i++)if(C(t[i],e))return!0;return!1}function E(t){for(var e=[],o=0;o<t.length;o++){var n=t[o].slice();!1===D(n[0],n[n.length-1])&&n.push(n[0]),e.push(n)}return e}function D(t,e){for(var o=0;o<t.length;o++)if(t[o]!==e[o])return!1;return!0}function F(t,e){if(t.length!==e.length)return!1;for(var o=t.slice().sort(m),n=e.slice().sort(m),r=0;r<o.length;r++){if(o[r].length!==n[r].length)return!1;for(var i=0;i<o.length;i++)if(o[r][i]!==n[r][i])return!1}return!0}var I=["length"];function O(t){if(t)switch(t.type){case"Point":return new x(t);case"MultiPoint":return new G(t);case"LineString":return new k(t);case"MultiLineString":return new U(t);case"Polygon":return new B(t);case"MultiPolygon":return new R(t);case"Feature":return new N(t);case"FeatureCollection":return new H(t);case"GeometryCollection":return new V(t);default:throw new Error("Unknown type: "+t.type)}}function x(t){var e=Array.prototype.slice.call(arguments);if(t&&"Point"===t.type&&t.coordinates)s(this,t);else if(t&&i(t))this.coordinates=t;else{if(!(e.length>=2))throw"Terraformer: invalid input for Terraformer.Point";this.coordinates=e}this.type="Point"}function G(t){if(t&&"MultiPoint"===t.type&&t.coordinates)s(this,t);else{if(!i(t))throw"Terraformer: invalid input for Terraformer.MultiPoint";this.coordinates=t}this.type="MultiPoint"}function k(t){if(t&&"LineString"===t.type&&t.coordinates)s(this,t);else{if(!i(t))throw"Terraformer: invalid input for Terraformer.LineString";this.coordinates=t}this.type="LineString"}function U(t){if(t&&"MultiLineString"===t.type&&t.coordinates)s(this,t);else{if(!i(t))throw"Terraformer: invalid input for Terraformer.MultiLineString";this.coordinates=t}this.type="MultiLineString"}function B(t){if(t&&"Polygon"===t.type&&t.coordinates)s(this,t);else{if(!i(t))throw"Terraformer: invalid input for Terraformer.Polygon";this.coordinates=t}this.type="Polygon"}function R(t){if(t&&"MultiPolygon"===t.type&&t.coordinates)s(this,t);else{if(!i(t))throw"Terraformer: invalid input for Terraformer.MultiPolygon";this.coordinates=t}this.type="MultiPolygon"}function N(t){if(t&&"Feature"===t.type)s(this,t);else{if(!(t&&t.type&&t.coordinates))throw"Terraformer: invalid input for Terraformer.Feature";this.geometry=t}this.type="Feature"}function H(t){if(t&&"FeatureCollection"===t.type&&t.features)s(this,t);else{if(!i(t))throw"Terraformer: invalid input for Terraformer.FeatureCollection";this.features=t}this.type="FeatureCollection"}function V(t){if(t&&"GeometryCollection"===t.type&&t.geometries)s(this,t);else if(i(t))this.geometries=t;else{if(!t.coordinates||!t.type)throw"Terraformer: invalid input for Terraformer.GeometryCollection";this.type="GeometryCollection",this.geometries=[t]}this.type="GeometryCollection"}function Q(t,e,o){for(var n=y(t),r=o||64,i={type:"Polygon",coordinates:[[]]},s=1;s<=r;s++){var a=s*(360/r)*Math.PI/180;i.coordinates[0].push([n[0]+e*Math.cos(a),n[1]+e*Math.sin(a)])}return i.coordinates=E(i.coordinates),v(i)}function K(t,e,o){var n=o||64,r=e||250;if(!t||t.length<2||!r||!n)throw new Error("Terraformer: missing parameter for Terraformer.Circle");s(this,new N({type:"Feature",geometry:Q(t,r,n),properties:{radius:r,center:t,steps:n}}))}return O.prototype.toMercator=function(){return g(this)},O.prototype.toGeographic=function(){return v(this)},O.prototype.envelope=function(){return c(this)},O.prototype.bbox=function(){return a(this)},O.prototype.convexHull=function(){var t,e,o=[];if("Point"===this.type)return null;if("LineString"===this.type||"MultiPoint"===this.type){if(!(this.coordinates&&this.coordinates.length>=3))return null;o=this.coordinates}else if("Polygon"===this.type||"MultiLineString"===this.type){if(!(this.coordinates&&this.coordinates.length>0))return null;for(t=0;t<this.coordinates.length;t++)o=o.concat(this.coordinates[t]);if(o.length<3)return null}else if("MultiPolygon"===this.type){if(!(this.coordinates&&this.coordinates.length>0))return null;for(t=0;t<this.coordinates.length;t++)for(e=0;e<this.coordinates[t].length;e++)o=o.concat(this.coordinates[t][e]);if(o.length<3)return null}else if("Feature"===this.type){return new O(this.geometry).convexHull()}return new B({type:"Polygon",coordinates:E([A(o)])})},O.prototype.toJSON=function(){var t={};for(var e in this)this.hasOwnProperty(e)&&-1===I.indexOf(e)&&(t[e]=this[e]);return t.bbox=a(this),t},O.prototype.contains=function(t){return new O(t).within(this)},O.prototype.within=function(t){var e,o;if("Feature"===t.type&&(t=t.geometry),"Point"===t.type&&"Point"===this.type)return D(this.coordinates,t.coordinates);if("MultiLineString"===t.type&&"Point"===this.type)for(e=0;e<t.coordinates.length;e++){var n={type:"LineString",coordinates:t.coordinates[e]};if(this.within(n))return!0}if(("LineString"===t.type||"MultiPoint"===t.type)&&"Point"===this.type)for(e=0;e<t.coordinates.length;e++){if(this.coordinates.length!==t.coordinates[e].length)return!1;if(D(this.coordinates,t.coordinates[e]))return!0}if("Polygon"===t.type){if("Polygon"===this.type){if(t.coordinates.length===this.coordinates.length)for(e=0;e<this.coordinates.length;e++)if(F(this.coordinates[e],t.coordinates[e]))return!0;return!(!this.coordinates.length||!b(t.coordinates,this.coordinates[0][0]))&&!C(E(this.coordinates),E(t.coordinates))}if("Point"===this.type)return b(t.coordinates,this.coordinates);if("LineString"===this.type||"MultiPoint"===this.type){if(!this.coordinates||0===this.coordinates.length)return!1;for(e=0;e<this.coordinates.length;e++)if(!1===b(t.coordinates,this.coordinates[e]))return!1;return!0}if("MultiLineString"===this.type){for(e=0;e<this.coordinates.length;e++){if(!1===new k(this.coordinates[e]).within(t))return o++,!1}return!0}if("MultiPolygon"===this.type){for(e=0;e<this.coordinates.length;e++){if(!1===new O({type:"Polygon",coordinates:this.coordinates[e]}).within(t))return!1}return!0}}if("MultiPolygon"===t.type){if("Point"===this.type){if(t.coordinates.length)for(e=0;e<t.coordinates.length;e++)if(b(t.coordinates[e],this.coordinates)&&!1===C([this.coordinates],t.coordinates))return!0;return!1}if("Polygon"===this.type){for(e=0;e<this.coordinates.length;e++)if(t.coordinates[e].length===this.coordinates.length)for(j=0;j<this.coordinates.length;j++)if(F(this.coordinates[j],t.coordinates[e][j]))return!0;if(!1===C(this.coordinates,t.coordinates)&&t.coordinates.length){for(e=0;e<t.coordinates.length;e++)o=!1!==b(t.coordinates[e],this.coordinates[0][0]);return o}}else if("LineString"===this.type||"MultiPoint"===this.type)for(e=0;e<t.coordinates.length;e++){var r={type:"Polygon",coordinates:t.coordinates[e]};return!!this.within(r)}else{if("MultiLineString"===this.type){for(e=0;e<this.coordinates.length;e++){if(!1===new k(this.coordinates[e]).within(t))return!1}return!0}if("MultiPolygon"===this.type){for(e=0;e<t.coordinates.length;e++){var i={type:"Polygon",coordinates:t.coordinates[e]};if(!1===this.within(i))return!1}return!0}}}return!1},O.prototype.intersects=function(t){"Feature"===t.type&&(t=t.geometry);var e=new O(t);return!(!this.within(t)&&!e.within(this))||("Point"!==this.type&&"MultiPoint"!==this.type&&"Point"!==t.type&&"MultiPoint"!==t.type?C(this.coordinates,t.coordinates):"Feature"===this.type?new O(this.geometry).intersects(t):(function(){var t=Array.prototype.slice.apply(arguments);void 0!==typeof console&&console.warn&&console.warn.apply(console,t)}("Type "+this.type+" to "+t.type+" intersection is not supported by intersects"),!1))},x.prototype=new O,x.prototype.constructor=x,G.prototype=new O,G.prototype.constructor=G,G.prototype.forEach=function(t){for(var e=0;e<this.coordinates.length;e++)t.apply(this,[this.coordinates[e],e,this.coordinates]);return this},G.prototype.addPoint=function(t){return this.coordinates.push(t),this},G.prototype.insertPoint=function(t,e){return this.coordinates.splice(e,0,t),this},G.prototype.removePoint=function(t){return"number"==typeof t?this.coordinates.splice(t,1):this.coordinates.splice(this.coordinates.indexOf(t),1),this},G.prototype.get=function(t){return new x(this.coordinates[t])},k.prototype=new O,k.prototype.constructor=k,k.prototype.addVertex=function(t){return this.coordinates.push(t),this},k.prototype.insertVertex=function(t,e){return this.coordinates.splice(e,0,t),this},k.prototype.removeVertex=function(t){return this.coordinates.splice(t,1),this},U.prototype=new O,U.prototype.constructor=U,U.prototype.forEach=function(t){for(var e=0;e<this.coordinates.length;e++)t.apply(this,[this.coordinates[e],e,this.coordinates])},U.prototype.get=function(t){return new k(this.coordinates[t])},B.prototype=new O,B.prototype.constructor=B,B.prototype.addVertex=function(t){return this.insertVertex(t,this.coordinates[0].length-1),this},B.prototype.insertVertex=function(t,e){return this.coordinates[0].splice(e,0,t),this},B.prototype.removeVertex=function(t){return this.coordinates[0].splice(t,1),this},B.prototype.close=function(){this.coordinates=E(this.coordinates)},B.prototype.hasHoles=function(){return this.coordinates.length>1},B.prototype.holes=function(){if(holes=[],this.hasHoles())for(var t=1;t<this.coordinates.length;t++)holes.push(new B([this.coordinates[t]]));return holes},R.prototype=new O,R.prototype.constructor=R,R.prototype.forEach=function(t){for(var e=0;e<this.coordinates.length;e++)t.apply(this,[this.coordinates[e],e,this.coordinates])},R.prototype.get=function(t){return new B(this.coordinates[t])},R.prototype.close=function(){var t=[];return this.forEach(function(e){t.push(E(e))}),this.coordinates=t,this},N.prototype=new O,N.prototype.constructor=N,H.prototype=new O,H.prototype.constructor=H,H.prototype.forEach=function(t){for(var e=0;e<this.features.length;e++)t.apply(this,[this.features[e],e,this.features])},H.prototype.get=function(t){var e;return this.forEach(function(o){o.id===t&&(e=o)}),new N(e)},V.prototype=new O,V.prototype.constructor=V,V.prototype.forEach=function(t){for(var e=0;e<this.geometries.length;e++)t.apply(this,[this.geometries[e],e,this.geometries])},V.prototype.get=function(t){return new O(this.geometries[t])},K.prototype=new O,K.prototype.constructor=K,K.prototype.recalculate=function(){return this.geometry=Q(this.properties.center,this.properties.radius,this.properties.steps),this},K.prototype.center=function(t){return t&&(this.properties.center=t,this.recalculate()),this.properties.center},K.prototype.radius=function(t){return t&&(this.properties.radius=t,this.recalculate()),this.properties.radius},K.prototype.steps=function(t){return t&&(this.properties.steps=t,this.recalculate()),this.properties.steps},K.prototype.toJSON=function(){return O.prototype.toJSON.call(this)},t.Primitive=O,t.Point=x,t.MultiPoint=G,t.LineString=k,t.MultiLineString=U,t.Polygon=B,t.MultiPolygon=R,t.Feature=N,t.FeatureCollection=H,t.GeometryCollection=V,t.Circle=K,t.toMercator=g,t.toGeographic=v,t.Tools={},t.Tools.positionToMercator=y,t.Tools.positionToGeographic=f,t.Tools.applyConverter=d,t.Tools.toMercator=g,t.Tools.toGeographic=v,t.Tools.createCircle=Q,t.Tools.calculateBounds=a,t.Tools.calculateEnvelope=c,t.Tools.coordinatesContainPoint=L,t.Tools.polygonContainsPoint=b,t.Tools.arraysIntersectArrays=C,t.Tools.coordinatesContainPoint=L,t.Tools.coordinatesEqual=F,t.Tools.convexHull=A,t.Tools.isConvex=function(t){for(var e,o=0;o<t.length-3;o++){var n=t[o],r=t[o+1],i=t[o+2],s=[r[0]-n[0],r[1]-n[1]],a=i[0]*s[1]-i[1]*s[0]+s[0]*n[1]-s[1]*n[0];if(0===o)e=a<0;else if(e&&a>0||!e&&a<0)return!1}return!0},t.MercatorCRS=r,t.GeographicCRS={type:"link",properties:{href:"http://spatialreference.org/ref/epsg/4326/ogcwkt/",type:"ogcwkt"}},t},t.exports=n(),"object"==typeof window&&(o.Terraformer=n())});function l(t){return t*Math.PI/180}function u(t){return 180*t/Math.PI}var c=function(t,e,o){for(var n,r,i,s,a,c,h,p=o||32,f=[],y=[],d=0;d<p;++d)f.push.apply(f,(n=t,r=e,i=2*Math.PI*d/p,s=void 0,a=void 0,c=void 0,h=void 0,s=l(n[1]),a=l(n[0]),c=r/6378137,h=Math.asin(Math.sin(s)*Math.cos(c)+Math.cos(s)*Math.sin(c)*Math.cos(i)),[u(a+Math.atan2(Math.sin(i)*Math.sin(c)*Math.cos(s),Math.cos(c)-Math.sin(s)*Math.sin(h))),u(h)]));f.push(f[0],f[1]);d=0;for(var g=0;g<f.length;g+=2)y[d++]=f.slice(g,g+2);return{type:"Polygon",coordinates:[y.reverse()]}};function h(t,o){return c(e.GeoJSON.latLngToCoords(t),o)}function p(t,o,n){void 0===n&&(n={});var r=n.crs||e.CRS.EPSG3857,i=new a.Primitive(t);return o.filter(function(t){var o;if(t instanceof e.Circle)o=h(t.getLatLng(),t.getRadius());else if(t instanceof e.CircleMarker){if(null!=n.zoom)o=h(t.getLatLng(),function(t,o,n){var r=t.getLatLng(),i=o.latLngToPoint(r,n),s=t.getRadius()/Math.SQRT2,a=e.point([i.x-s,i.y-s]),l=o.pointToLatLng(a,n);return o.distance(r,l)}(t,r,n.zoom));else console.warn("Zoom is required for calculating CircleMarker polygon, falling back to center point only"),o=t.toGeoJSON().geometry}else{if(!(t instanceof e.Marker||t instanceof e.Polyline))return!1;o=t.toGeoJSON().geometry}return n.intersect&&"Point"!==o.type?i.intersects(o):i.contains(o)})}function f(t,e){void 0===e&&(e={});var o=e.insertAt;if(t&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],r=document.createElement("style");r.type="text/css","top"===o&&n.firstChild?n.insertBefore(r,n.firstChild):n.appendChild(r),r.styleSheet?r.styleSheet.cssText=t:r.appendChild(document.createTextNode(t))}}f(".leaflet-lasso-active {\n cursor: crosshair;\n -webkit-user-select: none;\n -moz-user-select: none;\n -ms-user-select: none;\n user-select: none;\n}\n\n.leaflet-lasso-active .leaflet-interactive {\n cursor: crosshair;\n pointer-events: none;\n}");var y="leaflet-lasso-active",d=function(t){function o(o,n){void 0===n&&(n={});var r=t.call(this,o)||this;return r.options={polygon:{color:"#00C3FF",weight:2},intersect:!1},r.onDocumentMouseMoveBound=r.onDocumentMouseMove.bind(r),r.onDocumentMouseUpBound=r.onDocumentMouseUp.bind(r),r.map=o,e.Util.setOptions(r,n),r}return n(o,t),o.prototype.setOptions=function(t){this.options=r({},this.options,t)},o.prototype.toggle=function(){this.enabled()?this.disable():this.enable()},o.prototype.addHooks=function(){this.map.getPane("mapPane"),this.map.on("mousedown",this.onMapMouseDown,this),this.map.getContainer().classList.add(y),this.map.dragging.disable(),this.map.fire("lasso.enabled")},o.prototype.removeHooks=function(){this.map.off("mousedown",this.onMapMouseDown,this),document.removeEventListener("mousemove",this.onDocumentMouseMoveBound),document.removeEventListener("mouseup",this.onDocumentMouseUpBound),this.map.getContainer().classList.remove(y),document.body.classList.remove(y),this.map.dragging.enable(),this.map.fire("lasso.disabled")},o.prototype.onMapMouseDown=function(t){var e=t;1===e.originalEvent.buttons?e.originalEvent.target.closest(".leaflet-control-container")||(this.polygon=new i([e.latlng],this.options.polygon).addTo(this.map),document.body.classList.add(y),document.addEventListener("mousemove",this.onDocumentMouseMoveBound),document.addEventListener("mouseup",this.onDocumentMouseUpBound)):this.disable()},o.prototype.onDocumentMouseMove=function(t){if(this.polygon){var e=t;if(1!==e.buttons)return console.warn("mouseup event was missed"),void this.finish();this.polygon.addLatLng(this.map.mouseEventToLatLng(e))}},o.prototype.onDocumentMouseUp=function(){this.finish()},o.prototype.finish=function(){var t=this;if(this.polygon){var o=this.polygon.toGeoJSON().geometry,n=[];this.map.eachLayer(function(o){o!==t.polygon&&o!==t.polygon.polyline&&o!==t.polygon.polygon&&(o instanceof e.Marker||o instanceof e.Path?n.push(o):e.MarkerCluster&&o instanceof e.MarkerCluster&&n.push.apply(n,o.getAllChildMarkers()))});var r=p(o,n,{zoom:this.map.getZoom(),crs:this.map.options.crs,intersect:this.options.intersect});this.map.fire("lasso.finished",{latLngs:this.polygon.getLatLngs(),layers:r}),this.map.removeLayer(this.polygon),this.polygon=void 0,this.disable()}},o}(e.Handler);f(".leaflet-control-lasso {\n background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsSAAALEgHS3X78AAAD6UlEQVR4nO1b7XHbMAwFfP0fdYKqE8QbRJ0gGUEjaAR3A4/gbuBOUHWCKhs4E1SegD06jzmYpWhJpiRKNu58Tix+AA8gCQIQK6Xolml109LfAbgDcAfg5gH4NPQEzJwSkf4kRLR2NKmJqNLfSqlqaH7+4y/0McjML0SUQdinHkO8ApCSiPZKqToogxYFAQBC50T03NDkN74raFzSGtahreSLo+9PALG7mlEXaQD6fMD0BgIp8TkQ0ZaINChpl7ExZoZxK2vcGr8nfXl2ztm5g1twI/Q6KHPvVlFg/DMgJgEAWpWCay3lIYX2zJ1bQFQhAO+i9b2l8VEEd/BSWEooBgUAm5REPvg67AGCrZDdIABgQ6qF1oOu8QBAbK4FwTd4bq23SbXeks/OIPg0f7V5TQRCpz3BNdhamH30wgu+CwFC66VqD5IIByRas/eAYDbGqi8AW+FszEp4ocC6y1KQneW6z+YmvJDDLIVDVwBKdNzPVXghi/FbLjprp4AIM2fi6loMcusal8zN8eXirOp885jNrn/BAlKxnL17GWPj+As8viqlDguwAG3V+hR7JKJvSqmyqd1KmMnrUoQHGaEzX6OVaLAfg6sRyUSeUt+UKxGobDSTmZKR5yIAj/h79IhsDPSRFxg6+ho9AAukpI1IgydGxiY4dSRON+/SXgwAyE1sHbkF79JmeEuaPs91H4DWf+Ffk1nSgDwQ0RH5iUbZqgXcAI0MG/FbKn7f+i5DZo14PabISR/lb0qpjWETXq252LmSsidaCYfh8s0pbnKZuFHuEzNvmNl5MiR9YmmRLYHaxb8VJ3SG+UzD3ZyvwyI/UEPozMoZFE2xTjOADId1yuhGBMLO0raSUSE74HsGgDoPiZULsIISPkFqtUlEuOx0YsiHadeIakTC57bGPW0zAVRiP+yVXJhY+M6JHLFcCtfDvUAoahCseoXW0Wz0Oy1310O5WUQLgmX2ZddEzkffhoc2CJMUQ3h4kzt+v7S4ke/CRKWYaBtBYURmF2tcMda7bC0absWEk5TG4ISyS3Suury1BqAB+XIMIDCv7eAEsUTvHtDQoak8bhPSexSlcXadYBlqHu8p0BMIZRVIti9QeD/Hc/S1hVawgKDuufQDriqVZeYcAjeVyL4BGBc1lcaSKY8dolaYmTXgf0ykKFStcCIKpM33Q8vuR1EcXeEuMkhoDnyWCKB81wGUQV+aEhFaJ/mSlgPwYvyHZ8QN9SlS38RbY3hnYQ/NHyH8KVq0+DdGdCgMS+sRe1ImX8xYvAUw8wGb7Q9c88/2l1sAIEPBlPM0ur85GgEPk9IdgAh4mJTuAETAw3RERP8Ab2Uzgrad13wAAAAASUVORK5CYII=');\n background-size: 22px;\n}");var g=function(t){function o(o){void 0===o&&(o={});var n=t.call(this)||this;return n.options={position:"topright"},e.Util.setOptions(n,o),n}return n(o,t),o.prototype.setOptions=function(t){this.options=r({},this.options,t),this.lasso&&this.lasso.setOptions(this.options)},o.prototype.onAdd=function(t){this.lasso=new d(t,this.options);var o=e.DomUtil.create("div","leaflet-bar leaflet-control"),n=e.DomUtil.create("a","leaflet-control-lasso",o);return n.href="#",n.title="Toggle Lasso",n.setAttribute("role","button"),n.setAttribute("aria-label",n.title),e.DomEvent.addListener(n,"click",this.toggle,this),o},o.prototype.enabled=function(){return!!this.lasso&&this.lasso.enabled()},o.prototype.enable=function(){this.lasso&&this.lasso.enable()},o.prototype.disable=function(){this.lasso&&this.lasso.disable()},o.prototype.toggle=function(){this.lasso&&this.lasso.toggle()},o}(e.Control);e.Lasso=d,e.lasso=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new(d.bind.apply(d,[void 0].concat(t)))},e.Control.Lasso=g,e.control.lasso=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return new(g.bind.apply(g,[void 0].concat(t)))},t.ACTIVE_CLASS=y,t.DISABLED_EVENT="lasso.disabled",t.ENABLED_EVENT="lasso.enabled",t.FINISHED_EVENT="lasso.finished",t.LassoControl=g,t.LassoHandler=d,Object.defineProperty(t,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=leaflet-lasso.umd.min.js.map |
@@ -5,7 +5,12 @@ module.exports = { | ||
setupFiles: [ | ||
"<rootDir>/jest-pre.ts" | ||
'<rootDir>/jest-pre.ts', | ||
], | ||
moduleNameMapper: { | ||
'\\.css$': 'identity-obj-proxy' | ||
'\\.css$': 'identity-obj-proxy', | ||
}, | ||
}; | ||
collectCoverage: true, | ||
collectCoverageFrom: [ | ||
'src/**/*.ts', | ||
'!src/**/*.test.ts', | ||
], | ||
}; |
{ | ||
"name": "leaflet-lasso", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "Leaflet plugin for lasso selection", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -5,3 +5,3 @@ # leaflet-lasso | ||
![Screenshot](docs/screenshot.jpg) | ||
<img src="http://zakjan.github.io/leaflet-lasso/docs/screenshot@2x.jpg" alt="Screenshot" width="640" height="320"> | ||
@@ -36,3 +36,3 @@ Supports all Leaflet vector layers: | ||
``` | ||
<script src="https://unpkg.com/leaflet-lasso@latest/dist/leaflet-lasso.umd.min.js"></script> | ||
<script src="https://unpkg.com/leaflet-lasso@2.0.1/dist/leaflet-lasso.umd.min.js"></script> | ||
``` | ||
@@ -39,0 +39,0 @@ |
@@ -1,2 +0,1 @@ | ||
import pkg from './package.json'; | ||
@@ -3,0 +2,0 @@ import commonjs from 'rollup-plugin-commonjs'; |
import L from 'leaflet'; | ||
import { LassoPolygon } from './lasso-polygon'; | ||
import { getLayersInPolygon } from './calc'; | ||
@@ -122,3 +123,3 @@ | ||
return L.polygon([ | ||
return new LassoPolygon([ | ||
[center.lat - latSmallDelta * scale * ratio, center.lng - lngSmallDelta * scale * inversedRatio], | ||
@@ -128,3 +129,3 @@ [center.lat - latSmallDelta * scale * ratio, center.lng + lngSmallDelta * scale * inversedRatio], | ||
[center.lat + latSmallDelta * scale * ratio, center.lng - lngSmallDelta * scale * inversedRatio], | ||
]).toGeoJSON().geometry as GeoJSON.Polygon; | ||
]).toGeoJSON().geometry; | ||
} | ||
@@ -148,3 +149,3 @@ | ||
// plus shape | ||
const lassoPolygon = L.polygon([ | ||
const lassoPolygon = new LassoPolygon([ | ||
[markers[7].getLatLng().lat + latSmallDelta, markers[7].getLatLng().lng - lngSmallDelta], | ||
@@ -162,3 +163,3 @@ [markers[7].getLatLng().lat + latSmallDelta, markers[7].getLatLng().lng + lngSmallDelta], | ||
[markers[4].getLatLng().lat + latSmallDelta, markers[4].getLatLng().lng - lngSmallDelta], | ||
]).toGeoJSON().geometry as GeoJSON.Polygon; | ||
]).toGeoJSON().geometry; | ||
const expectedResult = [markers[1], markers[3], markers[4], markers[5], markers[7]]; | ||
@@ -165,0 +166,0 @@ const result = getLayersInPolygon(lassoPolygon, layers, { zoom: zoom }); |
@@ -9,3 +9,3 @@ import L from 'leaflet'; | ||
beforeEach(() => { | ||
beforeEach(() => { | ||
container = document.createElement('div'); | ||
@@ -79,2 +79,2 @@ container.style.width = '400px'; | ||
}); | ||
}) | ||
}) |
import L from 'leaflet'; | ||
import { LassoPolygon } from './lasso-polygon'; | ||
import { getLayersInPolygon } from './calc'; | ||
@@ -34,4 +35,3 @@ import './lasso-handler.css'; | ||
private polyline?: L.Polyline; | ||
private polygon?: L.Polygon; | ||
private polygon?: LassoPolygon; | ||
@@ -86,2 +86,8 @@ private onDocumentMouseMoveBound = this.onDocumentMouseMove.bind(this); | ||
// activate lasso only for left mouse button click | ||
if (event2.originalEvent.buttons !== 1) { | ||
this.disable(); | ||
return; | ||
} | ||
// skip clicks on controls | ||
@@ -92,5 +98,3 @@ if ((event2.originalEvent.target as HTMLElement).closest('.leaflet-control-container')) { | ||
// separate polyline and polygon, so that it is rendered unclosed | ||
this.polyline = L.polyline([event2.latlng], this.options.polygon).addTo(this.map); | ||
this.polygon = L.polygon([event2.latlng], { ...this.options.polygon, weight: 0 }).addTo(this.map); | ||
this.polygon = new LassoPolygon([event2.latlng], this.options.polygon).addTo(this.map); | ||
@@ -104,3 +108,3 @@ document.body.classList.add(ACTIVE_CLASS); | ||
private onDocumentMouseMove(event: Event) { | ||
if (!this.polyline || !this.polygon) { | ||
if (!this.polygon) { | ||
return; | ||
@@ -110,9 +114,11 @@ } | ||
const event2 = event as MouseEvent; | ||
this.polyline.addLatLng(this.map.mouseEventToLatLng(event2)); | ||
this.polygon.addLatLng(this.map.mouseEventToLatLng(event2)); | ||
if (event2.buttons === 0) { | ||
// keep lasso active only if left mouse button is hold | ||
if (event2.buttons !== 1) { | ||
console.warn('mouseup event was missed'); | ||
this.finish(); | ||
return; | ||
} | ||
this.polygon.addLatLng(this.map.mouseEventToLatLng(event2)); | ||
} | ||
@@ -125,13 +131,13 @@ | ||
private finish() { | ||
if (!this.polyline || !this.polygon) { | ||
if (!this.polygon) { | ||
return; | ||
} | ||
const polygon = this.polygon.toGeoJSON().geometry as GeoJSON.Polygon; | ||
const polygon = this.polygon.toGeoJSON().geometry; | ||
const layers: L.Layer[] = []; | ||
this.map.eachLayer(layer => { | ||
if (layer === this.polyline || layer === this.polygon) { | ||
if (layer === this.polygon || layer === this.polygon!.polyline || layer === this.polygon!.polygon) { | ||
return; | ||
} | ||
if (layer instanceof L.Marker || layer instanceof L.Path) { | ||
@@ -151,9 +157,7 @@ layers.push(layer); | ||
this.map.fire(FINISHED_EVENT, { | ||
latLngs: this.polygon.getLatLngs()[0], | ||
latLngs: this.polygon.getLatLngs(), | ||
layers: selectedFeatures, | ||
} as LassoHandlerFinishedEventData); | ||
this.map.removeLayer(this.polyline); | ||
this.map.removeLayer(this.polygon); | ||
this.polyline = undefined; | ||
this.polygon = undefined; | ||
@@ -160,0 +164,0 @@ |
@@ -10,2 +10,3 @@ { | ||
"declaration": true, | ||
"sourceMap": true, | ||
"strict": true, | ||
@@ -23,2 +24,2 @@ "noUnusedLocals": true, | ||
] | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1029521
40
3269