leaflet-lasso
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -219,3 +219,3 @@ 'use strict'; | ||
} | ||
if (layer instanceof L.Marker || layer instanceof L.Polyline) { | ||
if (layer instanceof L.Marker || layer instanceof L.Path) { | ||
layers.push(layer); | ||
@@ -222,0 +222,0 @@ } |
@@ -213,3 +213,3 @@ import L from 'leaflet'; | ||
} | ||
if (layer instanceof L.Marker || layer instanceof L.Polyline) { | ||
if (layer instanceof L.Marker || layer instanceof L.Path) { | ||
layers.push(layer); | ||
@@ -216,0 +216,0 @@ } |
@@ -1684,3 +1684,3 @@ (function (global, factory) { | ||
} | ||
if (layer instanceof L.Marker || layer instanceof L.Polyline) { | ||
if (layer instanceof L.Marker || layer instanceof L.Path) { | ||
layers.push(layer); | ||
@@ -1687,0 +1687,0 @@ } |
@@ -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 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 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=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 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=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=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=[],y=[],d=0;d<p;++d)f.push.apply(f,(n=t,r=e,i=2*Math.PI*d/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]);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 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",y=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.Polyline?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 d=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 y(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=y,e.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)))},e.Control.Lasso=d,e.control.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)))},t.ACTIVE_CLASS=f,t.DISABLED_EVENT="lasso.disabled",t.ENABLED_EVENT="lasso.enabled",t.FINISHED_EVENT="lasso.finished",t.LassoControl=d,t.LassoHandler=y,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="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})}); | ||
//# sourceMappingURL=leaflet-lasso.umd.min.js.map |
{ | ||
"name": "leaflet-lasso", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Leaflet plugin for lasso selection", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -131,3 +131,3 @@ import L from 'leaflet'; | ||
if (layer instanceof L.Marker || layer instanceof L.Polyline) { | ||
if (layer instanceof L.Marker || layer instanceof L.Path) { | ||
layers.push(layer); | ||
@@ -134,0 +134,0 @@ } else if (L.MarkerCluster && layer instanceof L.MarkerCluster) { |
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
668353