!function(){"use strict";L.Marker.Measurement=L[L.Layer?"Layer":"Class"].extend({options:{pane:"markerPane"},initialize:function(t,e,s,n,a){L.setOptions(this,a),this._latlng=t,this._measurement=e,this._title=s,this._rotation=n},addTo:function(t){return t.addLayer(this),this},onAdd:function(t){this._map=t;var e=this.getPane?this.getPane():t.getPanes().markerPane,s=this._element=L.DomUtil.create("div","leaflet-zoom-animated leaflet-measure-path-measurement",e),n=L.DomUtil.create("div","",s);n.title=this._title,n.innerHTML=this._measurement,t.on("zoomanim",this._animateZoom,this),this._setPosition()},onRemove:function(t){t.off("zoomanim",this._animateZoom,this),(this.getPane?this.getPane():t.getPanes().markerPane).removeChild(this._element),this._map=null},_setPosition:function(){L.DomUtil.setPosition(this._element,this._map.latLngToLayerPoint(this._latlng)),this._element.style.transform+=" rotate("+this._rotation+"rad)"},_animateZoom:function(t){var e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center).round();L.DomUtil.setPosition(this._element,e),this._element.style.transform+=" rotate("+this._rotation+"rad)"}}),L.marker.measurement=function(t,e,s,n,a){return new L.Marker.Measurement(t,e,s,n,a)};var t=function(t){var e;return this._measurementOptions.imperial?t>404.685642?(t/=4046.85642,e="ac"):(t/=.09290304,e="ft²"):t>1e6?(t/=1e6,e="km²"):e="m²",t<100?t.toFixed(1)+" "+e:Math.round(t)+" "+e},e=6378137,s=function(){var t=this.options.measurementOptions&&this.options.measurementOptions.showOnHover;this.options.showMeasurements&&!t&&this.showMeasurements(),this.options.showMeasurements&&t&&(this.on("mouseover",(function(){this.showMeasurements()})),this.on("mouseout",(function(){this.hideMeasurements()})))},n=function(t,e,s){return s?function(){return e.apply(this,arguments),t.apply(this,arguments)}:function(){var s=t.apply(this,arguments),n=Array.prototype.slice.call(arguments);return n.push(s),e.apply(this,n)}};L.Polyline.include({showMeasurements:function(t){return!this._map||this._measurementLayer||(this._measurementOptions=L.extend({showOnHover:t&&t.showOnHover||!1,minPixelDistance:30,showDistances:!0,showArea:!0,showTotalDistance:!0,lang:{totalLength:"Total length",totalArea:"Total area",segmentLength:"Segment length"}},t||{}),this._measurementLayer=L.layerGroup().addTo(this._map),this.updateMeasurements(),this._map.on("zoomend",this.updateMeasurements,this)),this},hideMeasurements:function(){return this._map?(this._map.off("zoomend",this.updateMeasurements,this),this._measurementLayer?(this._map.removeLayer(this._measurementLayer),this._measurementLayer=null,this):this):this},onAdd:n(L.Polyline.prototype.onAdd,(function(t){var e=this.options.measurementOptions&&this.options.measurementOptions.showOnHover;return this.options.showMeasurements&&!e&&this.showMeasurements(this.options.measurementOptions),t})),onRemove:n(L.Polyline.prototype.onRemove,(function(t){return this.hideMeasurements(),t}),!0),setLatLngs:n(L.Polyline.prototype.setLatLngs,(function(t){return this.updateMeasurements(),t})),spliceLatLngs:n(L.Polyline.prototype.spliceLatLngs,(function(t){return this.updateMeasurements(),t})),formatDistance:function(t){var e,s;return this._measurementOptions.imperial?(s=t/.3048)>3e3?(t/=1609.344,e="mi"):(t=s,e="ft"):t>1e3?(t/=1e3,e="km"):e="m",t<100?t.toFixed(1)+" "+e:Math.round(t)+" "+e},formatArea:t,updateMeasurements:function(){if(!this._measurementLayer)return this;var t,s,n,a,i,r,o=this.getLatLngs(),m=this instanceof L.Polygon,h=this._measurementOptions,u=0;if(o&&o.length&&L.Util.isArray(o[0])&&(o=o[0]),this._measurementLayer.clearLayers(),this._measurementOptions.showDistances&&o.length>1){t=this._measurementOptions.formatDistance||L.bind(this.formatDistance,this);for(var l=1,p=o.length;m&&l<=p||l<p;l++)s=o[l-1],n=o[l%p],u+=r=s.distanceTo(n),a=this._map.latLngToLayerPoint(s),i=this._map.latLngToLayerPoint(n),a.distanceTo(i)>=h.minPixelDistance&&L.marker.measurement(this._map.layerPointToLatLng([(a.x+i.x)/2,(a.y+i.y)/2]),t(r),h.lang.segmentLength,this._getRotation(s,n),h).addTo(this._measurementLayer);!m&&this._measurementOptions.showTotalDistance&&L.marker.measurement(n,t(u),h.lang.totalLength,0,h).addTo(this._measurementLayer)}if(m&&h.showArea&&o.length>2){t=h.formatArea||L.bind(this.formatArea,this);var d=function(t){var s,n,a,i,r,o=function(t){return t*Math.PI/180},m=0,h=t.length;if(h>2){for(var u=0;u<h;u++)u===h-2?(a=h-2,i=h-1,r=0):u===h-1?(a=h-1,i=0,r=1):(a=u,i=u+1,r=u+2),s=t[a],n=t[i],m+=(o(t[r].lng)-o(s.lng))*Math.sin(o(n.lat));m=m*e*e/2}return Math.abs(m)}(o);L.marker.measurement(this.getBounds().getCenter(),t(d),h.lang.totalArea,0,h).addTo(this._measurementLayer)}return this},_getRotation:function(t,e){var s=this._map.project(t),n=this._map.project(e);return Math.atan((n.y-s.y)/(n.x-s.x))}}),L.Polyline.addInitHook((function(){s.call(this)})),L.Circle.include({showMeasurements:function(t){return!this._map||this._measurementLayer||(this._measurementOptions=L.extend({showOnHover:!1,showArea:!0,lang:{totalArea:"Total area"}},t||{}),this._measurementLayer=L.layerGroup().addTo(this._map),this.updateMeasurements(),this._map.on("zoomend",this.updateMeasurements,this)),this},hideMeasurements:function(){return this._map?(this._map.on("zoomend",this.updateMeasurements,this),this._measurementLayer?(this._map.removeLayer(this._measurementLayer),this._measurementLayer=null,this):this):this},onAdd:n(L.Circle.prototype.onAdd,(function(t){var e=this.options.measurementOptions&&this.options.measurementOptions.showOnHover;return this.options.showMeasurements&&!e&&this.showMeasurements(this.options.measurementOptions),t})),onRemove:n(L.Circle.prototype.onRemove,(function(t){return this.hideMeasurements(),t}),!0),setLatLng:n(L.Circle.prototype.setLatLng,(function(t){return this.updateMeasurements(),t})),setRadius:n(L.Circle.prototype.setRadius,(function(t){return this.updateMeasurements(),t})),formatArea:t,updateMeasurements:function(){if(this._measurementLayer){var t,s,n=this.getLatLng(),a=this._measurementOptions,i=a.formatArea||L.bind(this.formatArea,this);if(this._measurementLayer.clearLayers(),a.showArea){i=a.formatArea||L.bind(this.formatArea,this);var r=(t=this.getRadius(),s=t/e,2*Math.PI*e*e*(1-Math.cos(s)));L.marker.measurement(n,i(r),a.lang.totalArea,0,a).addTo(this._measurementLayer)}}}}),L.Circle.addInitHook((function(){s.call(this)}))}();