hy-dispatch-ui-v3 0.2.53 → 0.2.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (116) hide show
  1. package/dist/tailwind.css +53 -0
  2. package/es/components/hyBatchUploadDialog/batchUploadDialog.vue.mjs +39 -10
  3. package/es/components/hyConfirmDialog/confirmDialog.vue.mjs +12 -22
  4. package/es/components/hyDialog/dialog.vue.mjs +9 -7
  5. package/es/components/hyForm/cpns/arrayItem.vue.mjs +5 -5
  6. package/es/components/hyForm/cpns/extraItem.vue.mjs +6 -1
  7. package/es/components/hyForm/cpns/formItem.vue.mjs +29 -14
  8. package/es/components/hyForm/js/index.mjs +29 -25
  9. package/es/components/hyForm/js/useAppForm.mjs +15 -30
  10. package/es/components/hyIconBox/iconBox.vue.mjs +1 -1
  11. package/es/components/hyIconBox/style/iconBox.scss +1 -1
  12. package/es/components/hyMap/index.mjs +6 -0
  13. package/es/components/hyMap/js/index.mjs +59 -0
  14. package/es/components/hyMap/map.vue.mjs +59 -0
  15. package/es/components/hyOrgCascader/js/index.mjs +53 -0
  16. package/es/components/hyOrgCascader/orgCascader.vue.mjs +22 -25
  17. package/es/components/hySearch/search.vue.mjs +6 -8
  18. package/es/components/hyTable/cpns/columnSelect.vue.mjs +10 -18
  19. package/es/components/hyTable/table.vue.mjs +8 -11
  20. package/es/components/hyTableActionButton/tableActionButton.vue.mjs +6 -3
  21. package/es/components/hyTableForm/batchTableForm.vue.mjs +182 -135
  22. package/es/components/hyTableForm/js/index.mjs +2 -2
  23. package/es/components/hyTableForm/tableForm.vue.mjs +29 -20
  24. package/es/components/hyTooltip/tooltip.vue.mjs +1 -1
  25. package/es/components/hyTree/js/index.mjs +5 -4
  26. package/es/components/hyTree/tree.vue.mjs +5 -0
  27. package/es/components/index.mjs +1 -0
  28. package/es/hooks/index.mjs +1 -0
  29. package/es/hooks/useApi.mjs +11 -5
  30. package/es/hooks/useAudioPlayerConfig.mjs +13 -5
  31. package/es/hooks/useEnsureHyIcon.mjs +11 -5
  32. package/es/hooks/useLocale.mjs +6 -5
  33. package/es/hooks/usePermissionMap.mjs +13 -5
  34. package/es/hooks/useSubscribe.mjs +28 -0
  35. package/es/hooks/useTooltipConfig.mjs +11 -5
  36. package/es/hooks/useUserAvatarMap.mjs +13 -5
  37. package/es/hooks/useVideoPlayerConfig.mjs +13 -5
  38. package/es/index.mjs +3 -2
  39. package/es/static/map/CFCASIPInput.min.js +258 -0
  40. package/es/static/map/MarkerCluster.css +75 -0
  41. package/es/static/map/bigemap.css +838 -0
  42. package/es/static/map/bigemap.js +5 -0
  43. package/es/static/map/bm.geometryutil.js +754 -0
  44. package/es/static/map/bmDraw.css +329 -0
  45. package/es/static/map/bmDraw.js +181 -0
  46. package/es/static/map/car.png +0 -0
  47. package/es/static/map/markercluster.js +2679 -0
  48. package/es/static/map/moveMarker.js +74 -0
  49. package/es/utils/form.mjs +38 -2
  50. package/es/utils/index.mjs +1 -2
  51. package/es/utils/map/hook/bigMap.mjs +1136 -0
  52. package/es/utils/map/hook/gaode.mjs +683 -0
  53. package/es/utils/map/hook/leafletjs.mjs +1336 -0
  54. package/es/utils/map/index.mjs +291 -0
  55. package/es/utils/map/js/mapProxy.mjs +38 -0
  56. package/es/utils/map/js/webgis.mjs +153 -0
  57. package/es/version.mjs +1 -1
  58. package/lib/components/hyBatchUploadDialog/batchUploadDialog.vue.js +40 -11
  59. package/lib/components/hyConfirmDialog/confirmDialog.vue.js +13 -23
  60. package/lib/components/hyDialog/dialog.vue.js +9 -7
  61. package/lib/components/hyForm/cpns/arrayItem.vue.js +4 -4
  62. package/lib/components/hyForm/cpns/extraItem.vue.js +6 -1
  63. package/lib/components/hyForm/cpns/formItem.vue.js +26 -11
  64. package/lib/components/hyForm/js/index.js +29 -23
  65. package/lib/components/hyForm/js/useAppForm.js +14 -29
  66. package/lib/components/hyIconBox/iconBox.vue.js +1 -1
  67. package/lib/components/hyIconBox/style/iconBox.scss +1 -1
  68. package/lib/components/hyMap/index.js +11 -0
  69. package/lib/components/hyMap/js/index.js +61 -0
  70. package/lib/components/hyMap/map.vue.js +63 -0
  71. package/lib/components/hyOrgCascader/js/index.js +56 -0
  72. package/lib/components/hyOrgCascader/orgCascader.vue.js +21 -24
  73. package/lib/components/hySearch/search.vue.js +4 -6
  74. package/lib/components/hyTable/cpns/columnSelect.vue.js +12 -20
  75. package/lib/components/hyTable/table.vue.js +17 -20
  76. package/lib/components/hyTableActionButton/tableActionButton.vue.js +5 -2
  77. package/lib/components/hyTableForm/batchTableForm.vue.js +181 -134
  78. package/lib/components/hyTableForm/js/index.js +1 -1
  79. package/lib/components/hyTableForm/tableForm.vue.js +29 -20
  80. package/lib/components/hyTooltip/tooltip.vue.js +1 -1
  81. package/lib/components/hyTree/js/index.js +5 -4
  82. package/lib/components/hyTree/tree.vue.js +5 -0
  83. package/lib/components/index.js +22 -20
  84. package/lib/hooks/index.js +3 -0
  85. package/lib/hooks/useApi.js +10 -4
  86. package/lib/hooks/useAudioPlayerConfig.js +12 -4
  87. package/lib/hooks/useEnsureHyIcon.js +10 -4
  88. package/lib/hooks/useLocale.js +5 -4
  89. package/lib/hooks/usePermissionMap.js +12 -4
  90. package/lib/hooks/useSubscribe.js +31 -0
  91. package/lib/hooks/useTooltipConfig.js +10 -4
  92. package/lib/hooks/useUserAvatarMap.js +12 -4
  93. package/lib/hooks/useVideoPlayerConfig.js +12 -4
  94. package/lib/index.js +27 -22
  95. package/lib/static/map/CFCASIPInput.min.js +258 -0
  96. package/lib/static/map/MarkerCluster.css +75 -0
  97. package/lib/static/map/bigemap.css +838 -0
  98. package/lib/static/map/bigemap.js +5 -0
  99. package/lib/static/map/bm.geometryutil.js +754 -0
  100. package/lib/static/map/bmDraw.css +329 -0
  101. package/lib/static/map/bmDraw.js +181 -0
  102. package/lib/static/map/car.png +0 -0
  103. package/lib/static/map/markercluster.js +2679 -0
  104. package/lib/static/map/moveMarker.js +74 -0
  105. package/lib/utils/form.js +38 -0
  106. package/lib/utils/index.js +2 -2
  107. package/lib/utils/map/hook/bigMap.js +1140 -0
  108. package/lib/utils/map/hook/gaode.js +687 -0
  109. package/lib/utils/map/hook/leafletjs.js +1360 -0
  110. package/lib/utils/map/index.js +298 -0
  111. package/lib/utils/map/js/mapProxy.js +44 -0
  112. package/lib/utils/map/js/webgis.js +162 -0
  113. package/lib/version.js +1 -1
  114. package/package.json +16 -1
  115. package/es/utils/bus.mjs +0 -5
  116. package/lib/utils/bus.js +0 -7
@@ -0,0 +1,181 @@
1
+ BM.drawVersion='0.4.2';BM.Draw={};BM.drawLocal={draw:{toolbar:{actions:{title:'取消',text:'取消'},finish:{title:'完成',text:'完成'},undo:{title:'删除最后一个点',text:'删除最后一个点'},buttons:{polyline:'线条',polygon:'多边形',rectangle:'矩形',circle:'圆',marker:'标注',circlemarker:'圆标注'}},handlers:{circle:{tooltip:{start:'单击开始'},radius:'半径'},circlemarker:{tooltip:{start:'单击地图开始'}},marker:{tooltip:{start:'单击地图开始'}},polygon:{tooltip:{start:'单击地图开始',cont:'',end:'双击完成'}},polyline:{error:'<strong>Error:</strong> 边界出错!',tooltip:{start:'单击地图开始',cont:'',end:'双击点完成'}},rectangle:{tooltip:{start:'单击地图开始'}},simpleshape:{tooltip:{end:'松开鼠标结束'}}}},edit:{toolbar:{actions:{save:{title:'保存',text:'保存'},cancel:{title:'取消',text:'Cancel'},clearAll:{title:'全部取消',text:'全部取消'}},buttons:{edit:'编辑',editDisabled:'请先选择一个要素',remove:'删除',removeDisabled:'没有删除的要素'}},handlers:{edit:{tooltip:{text:'单击定位点来编辑',subtext:''}},remove:{tooltip:{text:'删除'}}}}};BM.Draw.Event={};BM.Draw.Event.CREATED='draw:created';BM.Draw.Event.EDITED='draw:edited';BM.Draw.Event.DELETED='draw:deleted';BM.Draw.Event.DRAWSTART='draw:drawstart';BM.Draw.Event.DRAWSTOP='draw:drawstop';BM.Draw.Event.DRAWVERTEX='draw:drawvertex';BM.Draw.Event.EDITSTART='draw:editstart';BM.Draw.Event.EDITMOVE='draw:editmove';BM.Draw.Event.EDITRESIZE='draw:editresize';BM.Draw.Event.EDITVERTEX='draw:editvertex';BM.Draw.Event.EDITSTOP='draw:editstop';BM.Draw.Event.DELETESTART='draw:deletestart';BM.Draw.Event.DELETESTOP='draw:deletestop';BM.Draw.Event.TOOLBAROPENED='draw:toolbaropened';BM.Draw.Event.TOOLBARCLOSED='draw:toolbarclosed';BM.Draw.Event.MARKERCONTEXT='draw:markercontext';BM.Draw=BM.Draw||{};BM.Draw.Feature=BM.Handler.extend({initialize:function(map,options){this._map=map;this._container=map._container;this._overlayPane=map._panes.overlayPane;this._popupPane=map._panes.popupPane;if(options&&options.shapeOptions){options.shapeOptions=BM.Util.extend({},this.options.shapeOptions,options.shapeOptions);}
2
+ BM.setOptions(this,options);var version=BM.version.split('.');if(parseInt(version[0],10)===1&&parseInt(version[1],10)>=2){BM.Draw.Feature.include(BM.Evented.prototype);}else{BM.Draw.Feature.include(BM.Mixin.Events);}},enable:function(){if(this._enabled){return;}
3
+ BM.Handler.prototype.enable.call(this);this.fire('enabled',{handler:this.type});this._map.fire(BM.Draw.Event.DRAWSTART,{layerType:this.type});},disable:function(){if(!this._enabled){return;}
4
+ BM.Handler.prototype.disable.call(this);this._map.fire(BM.Draw.Event.DRAWSTOP,{layerType:this.type});this.fire('disabled',{handler:this.type});},addHooks:function(){var map=this._map;if(map){BM.DomUtil.disableTextSelection();map.getContainer().focus();this._tooltip=new BM.Draw.Tooltip(this._map);BM.DomEvent.on(this._container,'keyup',this._cancelDrawing,this);}},removeHooks:function(){if(this._map){BM.DomUtil.enableTextSelection();this._tooltip.dispose();this._tooltip=null;BM.DomEvent.off(this._container,'keyup',this._cancelDrawing,this);}},setOptions:function(options){BM.setOptions(this,options);},_fireCreatedEvent:function(layer){this._map.fire(BM.Draw.Event.CREATED,{layer:layer,layerType:this.type});},_cancelDrawing:function(e){if(e.keyCode===27){this._map.fire('draw:canceled',{layerType:this.type});this.disable();}}});BM.Draw.Polyline=BM.Draw.Feature.extend({statics:{TYPE:'polyline'},Poly:BM.Polyline,options:{allowIntersection:true,repeatMode:false,drawError:{color:'#b00b00',timeout:2500},icon:new BM.DivIcon({iconSize:new BM.Point(8,8),className:'bigemap-div-icon bigemap-editing-icon'}),touchIcon:new BM.DivIcon({iconSize:new BM.Point(20,20),className:'bigemap-div-icon bigemap-editing-icon bigemap-touch-icon'}),guidelineDistance:20,maxGuideLineLength:4000,shapeOptions:{stroke:true,color:'#3388ff',weight:4,opacity:0.5,fill:false,clickable:true},metric:true,feet:true,nautic:false,showLength:true,zIndexOffset:2000,factor:1,maxPoints:0},initialize:function(map,options){if(BM.Browser.touch){this.options.icon=this.options.touchIcon;}
5
+ this.options.drawError.message=BM.drawLocal.draw.handlers.polyline.error;if(options&&options.drawError){options.drawError=BM.Util.extend({},this.options.drawError,options.drawError);}
6
+ this.type=BM.Draw.Polyline.TYPE;BM.Draw.Feature.prototype.initialize.call(this,map,options);},addHooks:function(){BM.Draw.Feature.prototype.addHooks.call(this);if(this._map){this._markers=[];this._markerGroup=new BM.LayerGroup();this._map.addLayer(this._markerGroup);this._clickHandle=true;this._poly=new BM.Polyline([],this.options.shapeOptions);this._tooltip.updateContent(this._getTooltipText());if(!this._mouseMarker){this._mouseMarker=BM.marker(this._map.getCenter(),{icon:BM.divIcon({className:'bigemap-mouse-marker',iconAnchor:[20,20],iconSize:[40,40]}),opacity:0,zIndexOffset:this.options.zIndexOffset});}
7
+ this._map.on('mouseup',this._upEvent,this).on('mousemove',this._onMouseMove,this).on('zoomlevelschange',this._onZoomEnd,this).on('dragstart',this._dragStart,this).on('zoomend',this._onZoomEnd,this);if(!this._map.getContainer()._bindTouch){this._map.getContainer()._bindTouch=true;this._map.getContainer().addEventListener('touchend',this._upEvent.bind(this));}}},_dragStart:function(){this._drag=true;},_upEvent:function(e){if(BM.Draw._clickHandled){return;}
8
+ BM.Draw._clickHandled=true;setTimeout(()=>{BM.Draw._clickHandled=false;},100);if(!this._clickHandle)return;if(this._drag)return this._drag=false;var origin=e.originalEvent||e.changedTouches[0];var clientX=origin.clientX;var clientY=origin.clientY;this._disableNewMarkers();this._startPoint.call(this,clientX,clientY);if(!e.latlng){var newPos=this._map.mouseEventToLayerPoint(origin);e.latlng=this._map.layerPointToLatLng(newPos);}
9
+ this._endPoint.call(this,clientX,clientY,e);if(!this._tttt)this._tttt={x:0,y:0};if(Math.abs(this._tttt.x-clientX)>5&&Math.abs(this._tttt.y-clientY)>5){this._updateTooltip(e.latlng);}
10
+ this._tttt={x:clientX,y:clientY,}
11
+ this._touchHandled=null;this._clickHandled=null;},removeHooks:function(){BM.Draw.Feature.prototype.removeHooks.call(this);this._clickHandle=false;this._clearHideErrorTimeout();this._cleanUpShape();this._map.removeLayer(this._markerGroup);delete this._markerGroup;delete this._markers;this._map.removeLayer(this._poly);delete this._poly;this._mouseMarker.off('mousedown',this._onMouseDown,this).off('mouseout',this._onMouseOut,this).off('mouseup',this._onMouseUp,this).off('mousemove',this._onMouseMove,this);this._map.removeLayer(this._mouseMarker);delete this._mouseMarker;this._clearGuides();this._map.off('mouseup',this._onMouseUp,this).off('mousemove',this._onMouseMove,this).off('zoomlevelschange',this._onZoomEnd,this).off('zoomend',this._onZoomEnd,this).off('touchstart',this._onTouch,this).off('click',this._onTouch,this);},deleteLastVertex:function(){if(this._markers.length<=1){return;}
12
+ var lastMarker=this._markers.pop(),poly=this._poly,latlngs=poly.getLatLngs(),latlng=latlngs.splice(-1,1)[0];this._poly.setLatLngs(latlngs);this._markerGroup.removeLayer(lastMarker);if(poly.getLatLngs().length<2){this._map.removeLayer(poly);}
13
+ this._vertexChanged(latlng,false);},addVertex:function(latlng){var markersLength=this._markers.length;if(markersLength>=2&&!this.options.allowIntersection&&this._poly.newLatLngIntersects(latlng)){this._showErrorTooltip();return;}
14
+ else if(this._errorShown){this._hideErrorTooltip();}
15
+ this._markers.push(this._createMarker(latlng));this._poly.addLatLng(latlng);if(this._poly.getLatLngs().length===2){this._map.addLayer(this._poly);}
16
+ this._vertexChanged(latlng,true);},completeShape:function(){if(this._markers.length<=1||!this._shapeIsValid()){return;}
17
+ this._fireCreatedEvent();this.disable();if(this.options.repeatMode){this.enable();}},_finishShape:function(){var latlngs=this._poly._defaultShape?this._poly._defaultShape():this._poly.getLatLngs();var intersects=this._poly.newLatLngIntersects(latlngs[latlngs.length-1]);if((!this.options.allowIntersection&&intersects)||!this._shapeIsValid()){this._showErrorTooltip();return;}
18
+ this._fireCreatedEvent();this.disable();if(this.options.repeatMode){this.enable();}},_shapeIsValid:function(){return true;},_onZoomEnd:function(){if(this._markers!==null){this._updateGuide();}},_onMouseMove:function(e){var newPos=this._map.mouseEventToLayerPoint(e.originalEvent);var latlng=this._map.layerPointToLatLng(newPos);this._currentLatLng=latlng;this._updateTooltip(latlng);this._updateGuide(newPos);this._mouseMarker.setLatLng(latlng);BM.DomEvent.preventDefault(e.originalEvent);},_vertexChanged:function(latlng,added){this._map.fire(BM.Draw.Event.DRAWVERTEX,{layers:this._markerGroup});this._updateFinishHandler();this._updateRunningMeasure(latlng,added);this._clearGuides();this._updateTooltip();},_onMouseDown:function(e){if(!this._clickHandled&&!this._touchHandled&&!this._disableMarkers){this._onMouseMove(e);this._clickHandled=true;this._disableNewMarkers();var originalEvent=e.originalEvent;var clientX=originalEvent.clientX;var clientY=originalEvent.clientY;this._startPoint.call(this,clientX,clientY);}},_startPoint:function(clientX,clientY){this._mouseDownOrigin=BM.point(clientX,clientY);},_onMouseUp:function(e){var originalEvent=e.originalEvent;var clientX=originalEvent.clientX;var clientY=originalEvent.clientY;this._endPoint.call(this,clientX,clientY,e);this._clickHandled=null;},_endPoint:function(clientX,clientY,e){if(this._mouseDownOrigin){var dragCheckDistance=BM.point(clientX,clientY).distanceTo(this._mouseDownOrigin);var lastPtDistance=this._calculateFinishDistance(e.latlng);if(this.options.maxPoints>1&&this.options.maxPoints==this._markers.length+1){this.addVertex(e.latlng);this._finishShape();}else if(lastPtDistance<10&&BM.Browser.touch){this._finishShape();}else if(Math.abs(dragCheckDistance)<9*(window.devicePixelRatio||1)){this.addVertex(e.latlng);}
19
+ this._enableNewMarkers();}
20
+ this._mouseDownOrigin=null;},_onTouch:function(e){var originalEvent=e.originalEvent;var clientX;var clientY;if(originalEvent.touches&&originalEvent.touches[0]&&!this._clickHandled&&!this._touchHandled&&!this._disableMarkers){clientX=originalEvent.touches[0].clientX;clientY=originalEvent.touches[0].clientY;this._disableNewMarkers();this._touchHandled=true;this._startPoint.call(this,clientX,clientY);this._endPoint.call(this,clientX,clientY,e);this._touchHandled=null;}
21
+ this._clickHandled=null;},_onMouseOut:function(){if(this._tooltip){this._tooltip._onMouseOut.call(this._tooltip);}},_calculateFinishDistance:function(potentialLatLng){var lastPtDistance;if(this._markers.length>0){var finishMarker;if(this.type===BM.Draw.Polyline.TYPE){finishMarker=this._markers[this._markers.length-1];}else if(this.type===BM.Draw.Polygon.TYPE){finishMarker=this._markers[this._markers.length-1];}else{return Infinity;}
22
+ var lastMarkerPoint=this._map.latLngToContainerPoint(finishMarker.getLatLng()),potentialMarker=new BM.Marker(potentialLatLng,{icon:this.options.icon,zIndexOffset:this.options.zIndexOffset*2});var potentialMarkerPint=this._map.latLngToContainerPoint(potentialMarker.getLatLng());lastPtDistance=lastMarkerPoint.distanceTo(potentialMarkerPint);}else{lastPtDistance=Infinity;}
23
+ return lastPtDistance;},_updateFinishHandler:function(){var markerCount=this._markers.length;if(markerCount>1){}
24
+ if(markerCount>2){this._markers[markerCount-2].off('click',this._finishShape,this);}},_createMarker:function(latlng){var marker=new BM.Marker(latlng,{icon:this.options.icon,zIndexOffset:this.options.zIndexOffset*2});this._markerGroup.addLayer(marker);return marker;},_updateGuide:function(newPos){var markerCount=this._markers?this._markers.length:0;if(markerCount>0){newPos=newPos||this._map.latLngToLayerPoint(this._currentLatLng);this._clearGuides();this._drawGuide(this._map.latLngToLayerPoint(this._markers[markerCount-1].getLatLng()),newPos);}},_updateTooltip:function(latLng){var text=this._getTooltipText();if(latLng){this._tooltip&&this._tooltip.updatePosition(latLng);}
25
+ if(!this._errorShown){this._tooltip&&this._tooltip.updateContent(text);}},_drawGuide:function(pointA,pointB){var length=Math.floor(Math.sqrt(Math.pow((pointB.x-pointA.x),2)+Math.pow((pointB.y-pointA.y),2))),guidelineDistance=this.options.guidelineDistance,maxGuideLineLength=this.options.maxGuideLineLength,i=length>maxGuideLineLength?length-maxGuideLineLength:guidelineDistance,fraction,dashPoint,dash;if(!this._guidesContainer){this._guidesContainer=BM.DomUtil.create('div','bigemap-draw-guides',this._overlayPane);}
26
+ for(;i<length;i+=this.options.guidelineDistance){fraction=i/length;dashPoint={x:Math.floor((pointA.x*(1-fraction))+(fraction*pointB.x)),y:Math.floor((pointA.y*(1-fraction))+(fraction*pointB.y))};dash=BM.DomUtil.create('div','bigemap-draw-guide-dash',this._guidesContainer);dash.style.backgroundColor=!this._errorShown?this.options.shapeOptions.color:this.options.drawError.color;BM.DomUtil.setPosition(dash,dashPoint);}},_updateGuideColor:function(color){if(this._guidesContainer){for(var i=0,l=this._guidesContainer.childNodes.length;i<l;i++){this._guidesContainer.childNodes[i].style.backgroundColor=color;}}},_clearGuides:function(){if(this._guidesContainer){while(this._guidesContainer.firstChild){this._guidesContainer.removeChild(this._guidesContainer.firstChild);}}},_getTooltipText:function(){var showLength=this.options.showLength,labelText,distanceStr;if(this._markers.length===0){labelText={text:BM.drawLocal.draw.handlers.polyline.tooltip.start};}else{distanceStr=showLength?this._getMeasurementString():'';if(this._markers.length===1){labelText={text:BM.drawLocal.draw.handlers.polyline.tooltip.cont,subtext:distanceStr};}else{labelText={text:BM.drawLocal.draw.handlers.polyline.tooltip.end,subtext:distanceStr};}}
27
+ return labelText;},_updateRunningMeasure:function(latlng,added){var markersLength=this._markers.length,previousMarkerIndex,distance;if(this._markers.length===1){this._measurementRunningTotal=0;}else{previousMarkerIndex=markersLength-(added?2:1);if(BM.GeometryUtil.isVersion07x()){distance=latlng.distanceTo(this._markers[previousMarkerIndex].getLatLng())*(this.options.factor||1);}else{distance=this._map.distance(latlng,this._markers[previousMarkerIndex].getLatLng())*(this.options.factor||1);}
28
+ this._measurementRunningTotal+=distance*(added?1:-1);}},_getMeasurementString:function(){var currentLatLng=this._currentLatLng,previousLatLng=this._markers[this._markers.length-1].getLatLng(),distance;if(BM.GeometryUtil.isVersion07x()){distance=previousLatLng&&currentLatLng&&currentLatLng.distanceTo?this._measurementRunningTotal+currentLatLng.distanceTo(previousLatLng)*(this.options.factor||1):this._measurementRunningTotal||0;}else{distance=previousLatLng&&currentLatLng?this._measurementRunningTotal+this._map.distance(currentLatLng,previousLatLng)*(this.options.factor||1):this._measurementRunningTotal||0;}
29
+ return BM.GeometryUtil.readableDistance(distance,this.options.metric,this.options.feet,this.options.nautic,this.options.precision);},_showErrorTooltip:function(){this._errorShown=true;this._tooltip.showAsError().updateContent({text:this.options.drawError.message});this._updateGuideColor(this.options.drawError.color);this._poly.setStyle({color:this.options.drawError.color});this._clearHideErrorTimeout();this._hideErrorTimeout=setTimeout(BM.Util.bind(this._hideErrorTooltip,this),this.options.drawError.timeout);},_hideErrorTooltip:function(){this._errorShown=false;this._clearHideErrorTimeout();this._tooltip.removeError().updateContent(this._getTooltipText());this._updateGuideColor(this.options.shapeOptions.color);this._poly.setStyle({color:this.options.shapeOptions.color});},_clearHideErrorTimeout:function(){if(this._hideErrorTimeout){clearTimeout(this._hideErrorTimeout);this._hideErrorTimeout=null;}},_disableNewMarkers:function(){this._disableMarkers=true;},_enableNewMarkers:function(){setTimeout(function(){this._disableMarkers=false;}.bind(this),50);},_cleanUpShape:function(){if(this._markers.length>1){this._markers[this._markers.length-1].off('click',this._finishShape,this);}},_fireCreatedEvent:function(){var poly=new this.Poly(this._poly.getLatLngs(),this.options.shapeOptions);BM.Draw.Feature.prototype._fireCreatedEvent.call(this,poly);}});BM.Draw.Polygon=BM.Draw.Polyline.extend({statics:{TYPE:'polygon'},Poly:BM.Polygon,options:{showArea:false,showLength:false,shapeOptions:{stroke:true,color:'#3388ff',weight:4,opacity:0.5,fill:true,fillColor:null,fillOpacity:0.2,clickable:true},metric:true,feet:true,nautic:false,precision:{}},initialize:function(map,options){BM.Draw.Polyline.prototype.initialize.call(this,map,options);this.type=BM.Draw.Polygon.TYPE;},_updateFinishHandler:function(){var markerCount=this._markers.length;if(markerCount===1){}
30
+ if(markerCount>2){if(markerCount>3){this._markers[markerCount-2].off('dblclick',this._finishShape,this);}}},_getTooltipText:function(){var text,subtext;if(!this._markers)return;if(this._markers.length===0){text=BM.drawLocal.draw.handlers.polygon.tooltip.start;}else if(this._markers.length<3){text=BM.drawLocal.draw.handlers.polygon.tooltip.cont;subtext=this._getMeasurementString();}else{text=BM.drawLocal.draw.handlers.polygon.tooltip.end;subtext=this._getMeasurementString();}
31
+ return{text:text,subtext:subtext};},_getMeasurementString:function(){var area=this._area,measurementString='';if(!area&&!this.options.showLength){return null;}
32
+ if(this.options.showLength){measurementString=BM.Draw.Polyline.prototype._getMeasurementString.call(this);}
33
+ if(area){measurementString+='<br>'+BM.GeometryUtil.readableArea(area,this.options.metric,this.options.precision);}
34
+ return measurementString;},_shapeIsValid:function(){return this._markers.length>=3;},_vertexChanged:function(latlng,added){var latLngs;if(!this.options.allowIntersection&&this.options.showArea){latLngs=this._poly.getLatLngs();this._area=BM.GeometryUtil.geodesicArea(latLngs);}
35
+ BM.Draw.Polyline.prototype._vertexChanged.call(this,latlng,added);},_cleanUpShape:function(){var markerCount=this._markers.length;if(markerCount>0){this._markers[0].off('click',this._finishShape,this);if(markerCount>2){this._markers[markerCount-1].off('dblclick',this._finishShape,this);}}}});BM.SimpleShape={};BM.Draw.SimpleShape=BM.Draw.Feature.extend({options:{repeatMode:false},initialize:function(map,options){this._endLabelText=BM.drawLocal.draw.handlers.simpleshape.tooltip.end;BM.Draw.Feature.prototype.initialize.call(this,map,options);},addHooks:function(){BM.Draw.Feature.prototype.addHooks.call(this);if(this._map){this._mapDraggable=this._map.dragging.enabled();if(this._mapDraggable){this._map.dragging.disable();}
36
+ this._container.style.cursor='crosshair';this._tooltip.updateContent({text:this._initialLabelText});this._map.on('mousedown',this._onMouseDown,this).on('mousemove',this._onMouseMove,this).on('touchstart',this._onMouseDown,this).on('touchmove',this._onMouseMove,this);document.addEventListener('touchstart',BM.DomEvent.preventDefault,{passive:false});}},removeHooks:function(){BM.Draw.Feature.prototype.removeHooks.call(this);if(this._map){if(this._mapDraggable){this._map.dragging.enable();}
37
+ this._container.style.cursor='';this._map.off('mousedown',this._onMouseDown,this).off('mousemove',this._onMouseMove,this).off('touchstart',this._onMouseDown,this).off('touchmove',this._onMouseMove,this);BM.DomEvent.off(document,'mouseup',this._onMouseUp,this);BM.DomEvent.off(document,'touchend',this._onMouseUp,this);document.removeEventListener('touchstart',BM.DomEvent.preventDefault);if(this._shape){this._map.removeLayer(this._shape);delete this._shape;}}
38
+ this._isDrawing=false;},_getTooltipText:function(){return{text:this._endLabelText};},_onMouseDown:function(e){this._isDrawing=true;this._startLatLng=e.latlng;BM.DomEvent.on(document,'mouseup',this._onMouseUp,this).on(document,'touchend',this._onMouseUp,this).preventDefault(e.originalEvent);},_onMouseMove:function(e){var latlng=e.latlng;this._tooltip.updatePosition(latlng);if(this._isDrawing){this._tooltip.updateContent(this._getTooltipText());this._drawShape(latlng);}},_onMouseUp:function(){if(this._shape){this._fireCreatedEvent();}
39
+ this.disable();if(this.options.repeatMode){this.enable();}}});BM.Draw.Rectangle=BM.Draw.SimpleShape.extend({statics:{TYPE:'rectangle'},options:{shapeOptions:{stroke:true,color:'#3388ff',weight:4,opacity:0.5,fill:true,fillColor:null,fillOpacity:0.2,clickable:true},showArea:true,metric:true},initialize:function(map,options){this.type=BM.Draw.Rectangle.TYPE;this._initialLabelText=BM.drawLocal.draw.handlers.rectangle.tooltip.start;BM.Draw.SimpleShape.prototype.initialize.call(this,map,options);},disable:function(){if(!this._enabled){return;}
40
+ this._isCurrentlyTwoClickDrawing=false;BM.Draw.SimpleShape.prototype.disable.call(this);},_onMouseUp:function(e){if(!this._shape&&!this._isCurrentlyTwoClickDrawing){this._isCurrentlyTwoClickDrawing=true;return;}
41
+ if(this._isCurrentlyTwoClickDrawing&&!_hasAncestor(e.target,'bigemap-pane')){return;}
42
+ BM.Draw.SimpleShape.prototype._onMouseUp.call(this);},_drawShape:function(latlng){if(!this._shape){this._shape=new BM.Rectangle(new BM.LatLngBounds(this._startLatLng,latlng),this.options.shapeOptions);this._map.addLayer(this._shape);}else{this._shape.setBounds(new BM.LatLngBounds(this._startLatLng,latlng));}},_fireCreatedEvent:function(){var rectangle=new BM.Rectangle(this._shape.getBounds(),this.options.shapeOptions);BM.Draw.SimpleShape.prototype._fireCreatedEvent.call(this,rectangle);},_getTooltipText:function(){var tooltipText=BM.Draw.SimpleShape.prototype._getTooltipText.call(this),shape=this._shape,showArea=this.options.showArea,latLngs,area,subtext;if(shape){latLngs=this._shape._defaultShape?this._shape._defaultShape():this._shape.getLatLngs();area=BM.GeometryUtil.geodesicArea(latLngs);subtext=showArea?BM.GeometryUtil.readableArea(area,this.options.metric):'';}
43
+ return{text:tooltipText.text,subtext:subtext};}});function _hasAncestor(el,cls){while((el=el.parentElement)&&!el.classList.contains(cls)){;}
44
+ return el;}
45
+ BM.Draw.Circle=BM.Draw.SimpleShape.extend({statics:{TYPE:'circle'},options:{shapeOptions:{stroke:true,color:'#3388ff',weight:4,opacity:0.5,fill:true,fillColor:null,fillOpacity:0.2,clickable:true},showRadius:true,metric:true,feet:true,nautic:false},initialize:function(map,options){this.type=BM.Draw.Circle.TYPE;this._initialLabelText=BM.drawLocal.draw.handlers.circle.tooltip.start;BM.Draw.SimpleShape.prototype.initialize.call(this,map,options);},_drawShape:function(latlng){if(BM.GeometryUtil.isVersion07x()){var distance=this._startLatLng.distanceTo(latlng);}else{var distance=this._map.distance(this._startLatLng,latlng);}
46
+ if(!this._shape){this._shape=new BM.Circle(this._startLatLng,distance,this.options.shapeOptions);this._map.addLayer(this._shape);}else{this._shape.setRadius(distance);}},_fireCreatedEvent:function(){var circle=new BM.Circle(this._startLatLng,this._shape.getRadius(),this.options.shapeOptions);BM.Draw.SimpleShape.prototype._fireCreatedEvent.call(this,circle);},_onMouseMove:function(e){var latlng=e.latlng,showRadius=this.options.showRadius,useMetric=this.options.metric,radius;this._tooltip.updatePosition(latlng);if(this._isDrawing){this._drawShape(latlng);radius=this._shape.getRadius().toFixed(1);var subtext='';if(showRadius){subtext=BM.drawLocal.draw.handlers.circle.radius+': '+
47
+ BM.GeometryUtil.readableDistance(radius,useMetric,this.options.feet,this.options.nautic);}
48
+ this._tooltip.updateContent({text:this._endLabelText,subtext:subtext});}}});BM.Draw.Marker=BM.Draw.Feature.extend({statics:{TYPE:'marker'},options:{icon:new BM.Icon.Default(),repeatMode:false,zIndexOffset:2000},initialize:function(map,options){this.type=BM.Draw.Marker.TYPE;this._initialLabelText=BM.drawLocal.draw.handlers.marker.tooltip.start;BM.Draw.Feature.prototype.initialize.call(this,map,options);},addHooks:function(){BM.Draw.Feature.prototype.addHooks.call(this);if(this._map){this._tooltip.updateContent({text:this._initialLabelText});if(!this._mouseMarker){this._mouseMarker=BM.marker(this._map.getCenter(),{icon:BM.divIcon({className:'bigemap-mouse-marker',iconAnchor:[20,20],iconSize:[40,40]}),opacity:0,zIndexOffset:this.options.zIndexOffset});}
49
+ this._mouseMarker.on('click',this._onClick,this).addTo(this._map);this._map.on('mousemove',this._onMouseMove,this);this._map.on('click',this._onTouch,this);}},removeHooks:function(){BM.Draw.Feature.prototype.removeHooks.call(this);if(this._map){this._map.off('click',this._onClick,this).off('click',this._onTouch,this);if(this._marker){this._marker.off('click',this._onClick,this);this._map.removeLayer(this._marker);delete this._marker;}
50
+ this._mouseMarker.off('click',this._onClick,this);this._map.removeLayer(this._mouseMarker);delete this._mouseMarker;this._map.off('mousemove',this._onMouseMove,this);}},_onMouseMove:function(e){var latlng=e.latlng;this._tooltip.updatePosition(latlng);this._mouseMarker.setLatLng(latlng);if(!this._marker){this._marker=this._createMarker(latlng);this._marker.on('click',this._onClick,this);this._map.on('click',this._onClick,this).addLayer(this._marker);}
51
+ else{latlng=this._mouseMarker.getLatLng();this._marker.setLatLng(latlng);}},_createMarker:function(latlng){return new BM.Marker(latlng,{icon:this.options.icon,zIndexOffset:this.options.zIndexOffset});},_onClick:function(){this._fireCreatedEvent();this.disable();if(this.options.repeatMode){this.enable();}},_onTouch:function(e){this._onMouseMove(e);this._onClick();},_fireCreatedEvent:function(){var marker=new BM.Marker.Touch(this._marker.getLatLng(),{icon:this.options.icon});BM.Draw.Feature.prototype._fireCreatedEvent.call(this,marker);}});BM.Draw.CircleMarker=BM.Draw.Marker.extend({statics:{TYPE:'circlemarker'},options:{stroke:true,color:'#3388ff',weight:4,opacity:0.5,fill:true,fillColor:null,fillOpacity:0.2,clickable:true,zIndexOffset:2000},initialize:function(map,options){this.type=BM.Draw.CircleMarker.TYPE;this._initialLabelText=BM.drawLocal.draw.handlers.circlemarker.tooltip.start;BM.Draw.Feature.prototype.initialize.call(this,map,options);},_fireCreatedEvent:function(){var circleMarker=new BM.CircleMarker(this._marker.getLatLng(),this.options);BM.Draw.Feature.prototype._fireCreatedEvent.call(this,circleMarker);},_createMarker:function(latlng){return new BM.CircleMarker(latlng,this.options);}});BM.Edit=BM.Edit||{};BM.Edit.Poly=BM.Handler.extend({initialize:function(poly){this.latlngs=[poly._latlngs];if(poly._holes){this.latlngs=this.latlngs.concat(poly._holes);}
52
+ this._poly=poly;this._poly.on('revert-edited',this._updateLatLngs,this);},_defaultShape:function(){if(!BM.Polyline._flat){return this._poly._latlngs;}
53
+ return BM.Polyline._flat(this._poly._latlngs)?this._poly._latlngs:this._poly._latlngs[0];},_eachVertexHandler:function(callback){for(var i=0;i<this._verticesHandlers.length;i++){callback(this._verticesHandlers[i]);}},addHooks:function(){this._initHandlers();this._eachVertexHandler(function(handler){handler.addHooks();});},removeHooks:function(){this._eachVertexHandler(function(handler){handler.removeHooks();});},updateMarkers:function(){this._eachVertexHandler(function(handler){handler.updateMarkers();});},_initHandlers:function(){this._verticesHandlers=[];for(var i=0;i<this.latlngs.length;i++){this._verticesHandlers.push(new BM.Edit.PolyVerticesEdit(this._poly,this.latlngs[i],this._poly.options.poly));}},_updateLatLngs:function(e){this.latlngs=[e.layer._latlngs];if(e.layer._holes){this.latlngs=this.latlngs.concat(e.layer._holes);}}});BM.Edit.PolyVerticesEdit=BM.Handler.extend({options:{icon:new BM.DivIcon({iconSize:new BM.Point(8,8),className:'bigemap-div-icon leaflet-editing-icon'}),touchIcon:new BM.DivIcon({iconSize:new BM.Point(8,8),className:'bigemap-draw-drag-icon',}),drawError:{color:'#b00b00',timeout:1000}},initialize:function(poly,latlngs,options){if(BM.Browser.touch){this.options.icon=this.options.touchIcon;}
54
+ this._poly=poly;if(options&&options.drawError){options.drawError=BM.Util.extend({},this.options.drawError,options.drawError);}
55
+ this._latlngs=latlngs;BM.setOptions(this,options);},_defaultShape:function(){if(!BM.Polyline._flat){return this._latlngs;}
56
+ return BM.Polyline._flat(this._latlngs)?this._latlngs:this._latlngs[0];},addHooks:function(){var poly=this._poly;var path=poly._path;if(!(poly instanceof BM.Polygon)){poly.options.fill=false;if(poly.options.editing){poly.options.editing.fill=false;}}
57
+ if(path){if(poly.options.editing&&poly.options.editing.className){if(poly.options.original.className){poly.options.original.className.split(' ').forEach(function(className){BM.DomUtil.removeClass(path,className);});}
58
+ poly.options.editing.className.split(' ').forEach(function(className){BM.DomUtil.addClass(path,className);});}}
59
+ poly.setStyle(poly.options.editing);if(this._poly._map){this._map=this._poly._map;if(!this._markerGroup){this._initMarkers();}
60
+ this._poly._map.addLayer(this._markerGroup);}},removeHooks:function(){var poly=this._poly;var path=poly._path;if(path){if(poly.options.editing&&poly.options.editing.className){poly.options.editing.className.split(' ').forEach(function(className){BM.DomUtil.removeClass(path,className);});if(poly.options.original.className){poly.options.original.className.split(' ').forEach(function(className){BM.DomUtil.addClass(path,className);});}}}
61
+ poly.setStyle(poly.options.original);if(poly._map){poly._map.removeLayer(this._markerGroup);delete this._markerGroup;delete this._markers;}},updateMarkers:function(){this._markerGroup.clearLayers();this._initMarkers();},_initMarkers:function(){if(!this._markerGroup){this._markerGroup=new BM.LayerGroup();}
62
+ this._markers=[];var latlngs=this._defaultShape(),i,j,len,marker;for(i=0,len=latlngs.length;i<len;i++){marker=this._createMarker(latlngs[i],i);marker.on('click',this._onMarkerClick,this);marker.on('contextmenu',this._onContextMenu,this);this._markers.push(marker);}
63
+ var markerLeft,markerRight;for(i=0,j=len-1;i<len;j=i++){if(i===0&&!(BM.Polygon&&(this._poly instanceof BM.Polygon))){continue;}
64
+ markerLeft=this._markers[j];markerRight=this._markers[i];this._createMiddleMarker(markerLeft,markerRight);this._updatePrevNext(markerLeft,markerRight);}},_createMarker:function(latlng,index){var marker=new BM.Marker.Touch(latlng,{draggable:true,icon:this.options.icon,});marker._origLatLng=latlng;marker._index=index;marker.on('dragstart',this._onMarkerDragStart,this).on('drag',this._onMarkerDrag,this).on('dragend',this._fireEdit,this).on('touchmove',this._onTouchMove,this).on('touchend',this._fireEdit,this).on('MSPointerMove',this._onTouchMove,this).on('MSPointerUp',this._fireEdit,this);this._markerGroup.addLayer(marker);return marker;},_onMarkerDragStart:function(){this._poly.fire('editstart');},_spliceLatLngs:function(){var latlngs=this._defaultShape();var removed=[].splice.apply(latlngs,arguments);this._poly._convertLatLngs(latlngs,true);this._poly.redraw();return removed;},_removeMarker:function(marker){var i=marker._index;this._markerGroup.removeLayer(marker);this._markers.splice(i,1);this._spliceLatLngs(i,1);this._updateIndexes(i,-1);marker.off('dragstart',this._onMarkerDragStart,this).off('drag',this._onMarkerDrag,this).off('dragend',this._fireEdit,this).off('touchmove',this._onMarkerDrag,this).off('touchend',this._fireEdit,this).off('click',this._onMarkerClick,this).off('MSPointerMove',this._onTouchMove,this).off('MSPointerUp',this._fireEdit,this);},_fireEdit:function(){this._poly.edited=true;this._poly.fire('edit');this._poly._map.fire(BM.Draw.Event.EDITVERTEX,{layers:this._markerGroup,poly:this._poly});},_onMarkerDrag:function(e){var marker=e.target;var poly=this._poly;var oldOrigLatLng=BM.LatLngUtil.cloneLatLng(marker._origLatLng);BM.extend(marker._origLatLng,marker._latlng);if(poly.options.poly){var tooltip=poly._map._editTooltip;if(!poly.options.poly.allowIntersection&&poly.intersects()){BM.extend(marker._origLatLng,oldOrigLatLng);marker.setLatLng(oldOrigLatLng);var originalColor=poly.options.color;poly.setStyle({color:this.options.drawError.color});if(tooltip){tooltip.updateContent({text:BM.drawLocal.draw.handlers.polyline.error});}
65
+ setTimeout(function(){poly.setStyle({color:originalColor});if(tooltip){tooltip.updateContent({text:BM.drawLocal.edit.handlers.edit.tooltip.text,subtext:BM.drawLocal.edit.handlers.edit.tooltip.subtext});}},1000);}}
66
+ if(marker._middleLeft){marker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev,marker));}
67
+ if(marker._middleRight){marker._middleRight.setLatLng(this._getMiddleLatLng(marker,marker._next));}
68
+ this._poly._bounds._southWest=BM.latLng(Infinity,Infinity);this._poly._bounds._northEast=BM.latLng(-Infinity,-Infinity);var latlngs=this._poly.getLatLngs();this._poly._convertLatLngs(latlngs,true);this._poly.redraw();this._poly.fire('editdrag');},_onMarkerClick:function(e){var minPoints=BM.Polygon&&(this._poly instanceof BM.Polygon)?4:3,marker=e.target;if(this._defaultShape().length<minPoints){return;}
69
+ this._removeMarker(marker);this._updatePrevNext(marker._prev,marker._next);if(marker._middleLeft){this._markerGroup.removeLayer(marker._middleLeft);}
70
+ if(marker._middleRight){this._markerGroup.removeLayer(marker._middleRight);}
71
+ if(marker._prev&&marker._next){this._createMiddleMarker(marker._prev,marker._next);}else if(!marker._prev){marker._next._middleLeft=null;}else if(!marker._next){marker._prev._middleRight=null;}
72
+ this._fireEdit();},_onContextMenu:function(e){var marker=e.target;var poly=this._poly;this._poly._map.fire(BM.Draw.Event.MARKERCONTEXT,{marker:marker,layers:this._markerGroup,poly:this._poly});BM.DomEvent.stopPropagation;},_onTouchMove:function(e){var layerPoint=this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]),latlng=this._map.layerPointToLatLng(layerPoint),marker=e.target;BM.extend(marker._origLatLng,latlng);if(marker._middleLeft){marker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev,marker));}
73
+ if(marker._middleRight){marker._middleRight.setLatLng(this._getMiddleLatLng(marker,marker._next));}
74
+ this._poly.redraw();this.updateMarkers();},_updateIndexes:function(index,delta){this._markerGroup.eachLayer(function(marker){if(marker._index>index){marker._index+=delta;}});},_createMiddleMarker:function(marker1,marker2){var latlng=this._getMiddleLatLng(marker1,marker2),marker=this._createMarker(latlng),onClick,onDragStart,onDragEnd;marker.setOpacity(0.6);marker1._middleRight=marker2._middleLeft=marker;onDragStart=function(){marker.off('touchmove',onDragStart,this);var i=marker2._index;marker._index=i;marker.off('click',onClick,this).on('click',this._onMarkerClick,this);latlng.lat=marker.getLatLng().lat;latlng.lng=marker.getLatLng().lng;this._spliceLatLngs(i,0,latlng);this._markers.splice(i,0,marker);marker.setOpacity(1);this._updateIndexes(i,1);marker2._index++;this._updatePrevNext(marker1,marker);this._updatePrevNext(marker,marker2);this._poly.fire('editstart');};onDragEnd=function(){marker.off('dragstart',onDragStart,this);marker.off('dragend',onDragEnd,this);marker.off('touchmove',onDragStart,this);this._createMiddleMarker(marker1,marker);this._createMiddleMarker(marker,marker2);};onClick=function(){onDragStart.call(this);onDragEnd.call(this);this._fireEdit();};marker.on('click',onClick,this).on('dragstart',onDragStart,this).on('dragend',onDragEnd,this).on('touchmove',onDragStart,this);this._markerGroup.addLayer(marker);},_updatePrevNext:function(marker1,marker2){if(marker1){marker1._next=marker2;}
75
+ if(marker2){marker2._prev=marker1;}},_getMiddleLatLng:function(marker1,marker2){var map=this._poly._map,p1=map.project(marker1.getLatLng()),p2=map.project(marker2.getLatLng());return map.unproject(p1._add(p2)._divideBy(2));}});BM.Polyline.addInitHook(function(){if(this.editing){return;}
76
+ if(BM.Edit.Poly){this.editing=new BM.Edit.Poly(this);if(this.options.editable){this.editing.enable();}}
77
+ this.on('add',function(){if(this.editing&&this.editing.enabled()){this.editing.addHooks();}});this.on('remove',function(){if(this.editing&&this.editing.enabled()){this.editing.removeHooks();}});});BM.Edit=BM.Edit||{};BM.Edit.SimpleShape=BM.Handler.extend({options:{moveIcon:new BM.DivIcon({iconSize:new BM.Point(8,8),className:'bigemap-div-icon bigemap-editing-icon bigemap-edit-move'}),resizeIcon:new BM.DivIcon({iconSize:new BM.Point(8,8),className:'bigemap-div-icon bigemap-editing-icon bigemap-edit-resize'}),touchMoveIcon:new BM.DivIcon({iconSize:new BM.Point(15,15),className:'bigemap-div-icon bigemap-editing-icon bigemap-edit-move bigemap-touch-icon'}),touchResizeIcon:new BM.DivIcon({iconSize:new BM.Point(15,15),className:'bigemap-div-icon bigemap-editing-icon bigemap-edit-resize bigemap-touch-icon'}),},initialize:function(shape,options){if(BM.Browser.touch){this.options.moveIcon=this.options.touchMoveIcon;this.options.resizeIcon=this.options.touchResizeIcon;}
78
+ this._shape=shape;BM.Util.setOptions(this,options);},addHooks:function(){var shape=this._shape;if(this._shape._map){this._map=this._shape._map;shape.setStyle(shape.options.editing);if(shape._map){this._map=shape._map;if(!this._markerGroup){this._initMarkers();}
79
+ this._map.addLayer(this._markerGroup);}}},removeHooks:function(){var shape=this._shape;shape.setStyle(shape.options.original);if(shape._map){this._unbindMarker(this._moveMarker);for(var i=0,l=this._resizeMarkers.length;i<l;i++){this._unbindMarker(this._resizeMarkers[i]);}
80
+ this._resizeMarkers=null;this._map.removeLayer(this._markerGroup);delete this._markerGroup;}
81
+ this._map=null;},updateMarkers:function(){this._markerGroup.clearLayers();this._initMarkers();},_initMarkers:function(){if(!this._markerGroup){this._markerGroup=new BM.LayerGroup();}
82
+ this._createMoveMarker();this._createResizeMarker();},_createMoveMarker:function(){},_createResizeMarker:function(){},_createMarker:function(latlng,icon){var marker=new BM.Marker.Touch(latlng,{draggable:true,icon:icon,zIndexOffset:10});this._bindMarker(marker);this._markerGroup.addLayer(marker);return marker;},_bindMarker:function(marker){marker.on('dragstart',this._onMarkerDragStart,this).on('drag',this._onMarkerDrag,this).on('dragend',this._onMarkerDragEnd,this).on('touchstart',this._onTouchStart,this).on('touchmove',this._onTouchMove,this).on('MSPointerMove',this._onTouchMove,this).on('touchend',this._onTouchEnd,this).on('MSPointerUp',this._onTouchEnd,this);},_unbindMarker:function(marker){marker.off('dragstart',this._onMarkerDragStart,this).off('drag',this._onMarkerDrag,this).off('dragend',this._onMarkerDragEnd,this).off('touchstart',this._onTouchStart,this).off('touchmove',this._onTouchMove,this).off('MSPointerMove',this._onTouchMove,this).off('touchend',this._onTouchEnd,this).off('MSPointerUp',this._onTouchEnd,this);},_onMarkerDragStart:function(e){var marker=e.target;marker.setOpacity(0);this._shape.fire('editstart');},_fireEdit:function(){this._shape.edited=true;this._shape.fire('edit');},_onMarkerDrag:function(e){var marker=e.target,latlng=marker.getLatLng();if(marker===this._moveMarker){this._move(latlng);}else{this._resize(latlng);}
83
+ this._shape.redraw();this._shape.fire('editdrag');},_onMarkerDragEnd:function(e){var marker=e.target;marker.setOpacity(1);this._fireEdit();},_onTouchStart:function(e){BM.Edit.SimpleShape.prototype._onMarkerDragStart.call(this,e);if(typeof(this._getCorners)==='function'){var corners=this._getCorners(),marker=e.target,currentCornerIndex=marker._cornerIndex;marker.setOpacity(0);this._oppositeCorner=corners[(currentCornerIndex+2)%4];this._toggleCornerMarkers(0,currentCornerIndex);}
84
+ this._shape.fire('editstart');},_onTouchMove:function(e){var layerPoint=this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]),latlng=this._map.layerPointToLatLng(layerPoint),marker=e.target;if(marker===this._moveMarker){this._move(latlng);}else{this._resize(latlng);}
85
+ this._shape.redraw();return false;},_onTouchEnd:function(e){var marker=e.target;marker.setOpacity(1);this.updateMarkers();this._fireEdit();},_move:function(){},_resize:function(){}});BM.Edit=BM.Edit||{};BM.Edit.Rectangle=BM.Edit.SimpleShape.extend({_createMoveMarker:function(){var bounds=this._shape.getBounds(),center=bounds.getCenter();this._moveMarker=this._createMarker(center,this.options.moveIcon);},_createResizeMarker:function(){var corners=this._getCorners();this._resizeMarkers=[];for(var i=0,l=corners.length;i<l;i++){this._resizeMarkers.push(this._createMarker(corners[i],this.options.resizeIcon));this._resizeMarkers[i]._cornerIndex=i;}},_onMarkerDragStart:function(e){BM.Edit.SimpleShape.prototype._onMarkerDragStart.call(this,e);var corners=this._getCorners(),marker=e.target,currentCornerIndex=marker._cornerIndex;this._oppositeCorner=corners[(currentCornerIndex+2)%4];this._toggleCornerMarkers(0,currentCornerIndex);},_onMarkerDragEnd:function(e){var marker=e.target,bounds,center;if(marker===this._moveMarker){bounds=this._shape.getBounds();center=bounds.getCenter();marker.setLatLng(center);}
86
+ this._toggleCornerMarkers(1);this._repositionCornerMarkers();BM.Edit.SimpleShape.prototype._onMarkerDragEnd.call(this,e);},_move:function(newCenter){var latlngs=this._shape._defaultShape?this._shape._defaultShape():this._shape.getLatLngs(),bounds=this._shape.getBounds(),center=bounds.getCenter(),offset,newLatLngs=[];for(var i=0,l=latlngs.length;i<l;i++){offset=[latlngs[i].lat-center.lat,latlngs[i].lng-center.lng];newLatLngs.push([newCenter.lat+offset[0],newCenter.lng+offset[1]]);}
87
+ this._shape.setLatLngs(newLatLngs);this._repositionCornerMarkers();this._map.fire(BM.Draw.Event.EDITMOVE,{layer:this._shape});},_resize:function(latlng){var bounds;this._shape.setBounds(BM.latLngBounds(latlng,this._oppositeCorner));bounds=this._shape.getBounds();this._moveMarker.setLatLng(bounds.getCenter());this._map.fire(BM.Draw.Event.EDITRESIZE,{layer:this._shape});},_getCorners:function(){var bounds=this._shape.getBounds(),nw=bounds.getNorthWest(),ne=bounds.getNorthEast(),se=bounds.getSouthEast(),sw=bounds.getSouthWest();return[nw,ne,se,sw];},_toggleCornerMarkers:function(opacity){for(var i=0,l=this._resizeMarkers.length;i<l;i++){this._resizeMarkers[i].setOpacity(opacity);}},_repositionCornerMarkers:function(){var corners=this._getCorners();for(var i=0,l=this._resizeMarkers.length;i<l;i++){this._resizeMarkers[i].setLatLng(corners[i]);}}});BM.Rectangle.addInitHook(function(){if(BM.Edit.Rectangle){this.editing=new BM.Edit.Rectangle(this);if(this.options.editable){this.editing.enable();}}});BM.Edit=BM.Edit||{};BM.Edit.Marker=BM.Handler.extend({initialize:function(marker,options){this._marker=marker;BM.setOptions(this,options);},addHooks:function(){var marker=this._marker;marker.dragging.enable();marker.on('dragend',this._onDragEnd,marker);this._toggleMarkerHighlight();},removeHooks:function(){var marker=this._marker;marker.dragging.disable();marker.off('dragend',this._onDragEnd,marker);this._toggleMarkerHighlight();},_onDragEnd:function(e){var layer=e.target;layer.edited=true;this._map.fire(BM.Draw.Event.EDITMOVE,{layer:layer});},_toggleMarkerHighlight:function(){var icon=this._marker._icon;if(!icon){return;}
88
+ icon.style.display='none';if(BM.DomUtil.hasClass(icon,'leaflet-edit-marker-selected')){BM.DomUtil.removeClass(icon,'leaflet-edit-marker-selected');this._offsetMarker(icon,-4);}else{BM.DomUtil.addClass(icon,'leaflet-edit-marker-selected');this._offsetMarker(icon,4);}
89
+ icon.style.display='';},_offsetMarker:function(icon,offset){var iconMarginTop=parseInt(icon.style.marginTop,10)-offset,iconMarginLeft=parseInt(icon.style.marginLeft,10)-offset;icon.style.marginTop=iconMarginTop+'px';icon.style.marginLeft=iconMarginLeft+'px';}});BM.Marker.addInitHook(function(){if(BM.Edit.Marker){this.editing=new BM.Edit.Marker(this);if(this.options.editable){this.editing.enable();}}});BM.Edit=BM.Edit||{};BM.Edit.CircleMarker=BM.Edit.SimpleShape.extend({_createMoveMarker:function(){var center=this._shape.getLatLng();this._moveMarker=this._createMarker(center,this.options.moveIcon);},_createResizeMarker:function(){this._resizeMarkers=[];},_move:function(latlng){if(this._resizeMarkers.length){var resizemarkerPoint=this._getResizeMarkerPoint(latlng);this._resizeMarkers[0].setLatLng(resizemarkerPoint);}
90
+ this._shape.setLatLng(latlng);this._map.fire(BM.Draw.Event.EDITMOVE,{layer:this._shape});},});BM.CircleMarker.addInitHook(function(){if(BM.Edit.CircleMarker){this.editing=new BM.Edit.CircleMarker(this);if(this.options.editable){this.editing.enable();}}
91
+ this.on('add',function(){if(this.editing&&this.editing.enabled()){this.editing.addHooks();}});this.on('remove',function(){if(this.editing&&this.editing.enabled()){this.editing.removeHooks();}});});BM.Edit=BM.Edit||{};BM.Edit.Circle=BM.Edit.CircleMarker.extend({_createResizeMarker:function(){var center=this._shape.getLatLng(),resizemarkerPoint=this._getResizeMarkerPoint(center);this._resizeMarkers=[];this._resizeMarkers.push(this._createMarker(resizemarkerPoint,this.options.resizeIcon));},_getResizeMarkerPoint:function(latlng){var delta=this._shape._radius*Math.cos(Math.PI/4),point=this._map.project(latlng);return this._map.unproject([point.x+delta,point.y-delta]);},_resize:function(latlng){var moveLatLng=this._moveMarker.getLatLng();if(BM.GeometryUtil.isVersion07x()){radius=moveLatLng.distanceTo(latlng);}else{radius=this._map.distance(moveLatLng,latlng);}
92
+ this._shape.setRadius(radius);if(this._map.editTooltip){this._map._editTooltip.updateContent({text:BM.drawLocal.edit.handlers.edit.tooltip.subtext+'<br />'+BM.drawLocal.edit.handlers.edit.tooltip.text,subtext:BM.drawLocal.draw.handlers.circle.radius+': '+
93
+ BM.GeometryUtil.readableDistance(radius,true,this.options.feet,this.options.nautic)});}
94
+ this._shape.setRadius(radius);this._map.fire(BM.Draw.Event.EDITRESIZE,{layer:this._shape});}});BM.Circle.addInitHook(function(){if(BM.Edit.Circle){this.editing=new BM.Edit.Circle(this);if(this.options.editable){this.editing.enable();}}});BM.Map.mergeOptions({touchExtend:true});BM.Map.TouchExtend=BM.Handler.extend({initialize:function(map){this._map=map;this._container=map._container;this._pane=map._panes.overlayPane;},addHooks:function(){BM.DomEvent.on(this._container,'touchstart',this._onTouchStart,this);BM.DomEvent.on(this._container,'touchend',this._onTouchEnd,this);BM.DomEvent.on(this._container,'touchmove',this._onTouchMove,this);if(this._detectIE()){BM.DomEvent.on(this._container,'MSPointerDown',this._onTouchStart,this);BM.DomEvent.on(this._container,'MSPointerUp',this._onTouchEnd,this);BM.DomEvent.on(this._container,'MSPointerMove',this._onTouchMove,this);BM.DomEvent.on(this._container,'MSPointerCancel',this._onTouchCancel,this);}else{BM.DomEvent.on(this._container,'touchcancel',this._onTouchCancel,this);BM.DomEvent.on(this._container,'touchleave',this._onTouchLeave,this);}},removeHooks:function(){BM.DomEvent.off(this._container,'touchstart',this._onTouchStart,this);BM.DomEvent.off(this._container,'touchend',this._onTouchEnd,this);BM.DomEvent.off(this._container,'touchmove',this._onTouchMove,this);if(this._detectIE()){BM.DomEvent.off(this._container,'MSPointerDown',this._onTouchStart,this);BM.DomEvent.off(this._container,'MSPointerUp',this._onTouchEnd,this);BM.DomEvent.off(this._container,'MSPointerMove',this._onTouchMove,this);BM.DomEvent.off(this._container,'MSPointerCancel',this._onTouchCancel,this);}else{BM.DomEvent.off(this._container,'touchcancel',this._onTouchCancel,this);BM.DomEvent.off(this._container,'touchleave',this._onTouchLeave,this);}},_touchEvent:function(e,type){var touchEvent={};if(typeof e.touches!=='undefined'){if(!e.touches.length){return;}
95
+ touchEvent=e.touches[0];}else if(e.pointerType==='touch'){touchEvent=e;if(!this._filterClick(e)){return;}}else{return;}
96
+ var containerPoint=this._map.mouseEventToContainerPoint(touchEvent),layerPoint=this._map.mouseEventToLayerPoint(touchEvent),latlng=this._map.layerPointToLatLng(layerPoint);this._map.fire(type,{latlng:latlng,layerPoint:layerPoint,containerPoint:containerPoint,pageX:touchEvent.pageX,pageY:touchEvent.pageY,originalEvent:e});},_filterClick:function(e){var timeStamp=(e.timeStamp||e.originalEvent.timeStamp),elapsed=BM.DomEvent._lastClick&&(timeStamp-BM.DomEvent._lastClick);if((elapsed&&elapsed>100&&elapsed<500)||(e.target._simulatedClick&&!e._simulated)){BM.DomEvent.stop(e);return false;}
97
+ BM.DomEvent._lastClick=timeStamp;return true;},_onTouchStart:function(e){if(!this._map._loaded){return;}
98
+ var type='touchstart';this._touchEvent(e,type);},_onTouchEnd:function(e){if(!this._map._loaded){return;}
99
+ var type='touchend';this._touchEvent(e,type);},_onTouchCancel:function(e){if(!this._map._loaded){return;}
100
+ var type='touchcancel';if(this._detectIE()){type='pointercancel';}
101
+ this._touchEvent(e,type);},_onTouchLeave:function(e){if(!this._map._loaded){return;}
102
+ var type='touchleave';this._touchEvent(e,type);},_onTouchMove:function(e){if(!this._map._loaded){return;}
103
+ var type='touchmove';this._touchEvent(e,type);},_detectIE:function(){var ua=window.navigator.userAgent;var msie=ua.indexOf('MSIE ');if(msie>0){return parseInt(ua.substring(msie+5,ua.indexOf('.',msie)),10);}
104
+ var trident=ua.indexOf('Trident/');if(trident>0){var rv=ua.indexOf('rv:');return parseInt(ua.substring(rv+3,ua.indexOf('.',rv)),10);}
105
+ var edge=ua.indexOf('Edge/');if(edge>0){return parseInt(ua.substring(edge+5,ua.indexOf('.',edge)),10);}
106
+ return false;}});BM.Map.addInitHook('addHandler','touchExtend',BM.Map.TouchExtend);BM.Marker.Touch=BM.Marker.extend({_initInteraction:function(){if(!this.addInteractiveTarget){return this._initInteractionLegacy();}
107
+ return BM.Marker.prototype._initInteraction.apply(this);},_initInteractionLegacy:function(){if(!this.options.clickable){return;}
108
+ var icon=this._icon,events=['dblclick','mousedown','mouseover','mouseout','contextmenu','touchstart','touchend','touchmove'];if(this._detectIE){events.concat(['MSPointerDown','MSPointerUp','MSPointerMove','MSPointerCancel']);}else{events.concat(['touchcancel']);}
109
+ BM.DomUtil.addClass(icon,'bigemap-clickable');BM.DomEvent.on(icon,'click',this._onMouseClick,this);BM.DomEvent.on(icon,'keypress',this._onKeyPress,this);for(var i=0;i<events.length;i++){BM.DomEvent.on(icon,events[i],this._fireMouseEvent,this);}
110
+ if(BM.Handler.MarkerDrag){this.dragging=new BM.Handler.MarkerDrag(this);if(this.options.draggable){this.dragging.enable();}}},_detectIE:function(){var ua=window.navigator.userAgent;var msie=ua.indexOf('MSIE ');if(msie>0){return parseInt(ua.substring(msie+5,ua.indexOf('.',msie)),10);}
111
+ var trident=ua.indexOf('Trident/');if(trident>0){var rv=ua.indexOf('rv:');return parseInt(ua.substring(rv+3,ua.indexOf('.',rv)),10);}
112
+ var edge=ua.indexOf('Edge/');if(edge>0){return parseInt(ua.substring(edge+5,ua.indexOf('.',edge)),10);}
113
+ return false;}});BM.LatLngUtil={cloneLatLngs:function(latlngs){var clone=[];for(var i=0,l=latlngs.length;i<l;i++){if(Array.isArray(latlngs[i])){clone.push(BM.LatLngUtil.cloneLatLngs(latlngs[i]));}else{clone.push(this.cloneLatLng(latlngs[i]));}}
114
+ return clone;},cloneLatLng:function(latlng){return BM.latLng(latlng.lat,latlng.lng);}};(function(){var defaultPrecision={km:2,ha:2,m:0,mi:2,ac:2,yd:0,ft:0,nm:2};BM.GeometryUtil=BM.extend(BM.GeometryUtil||{},{geodesicArea:function(latLngs){var pointsCount=latLngs.length,area=0.0,d2r=Math.PI/180,p1,p2;if(pointsCount>2){for(var i=0;i<pointsCount;i++){p1=latLngs[i];p2=latLngs[(i+1)%pointsCount];area+=((p2.lng-p1.lng)*d2r)*(2+Math.sin(p1.lat*d2r)+Math.sin(p2.lat*d2r));}
115
+ area=area*6378137.0*6378137.0/2.0;}
116
+ return Math.abs(area);},formattedNumber:function(n,precision){var formatted=parseFloat(n).toFixed(precision),format=BM.drawLocal.format&&BM.drawLocal.format.numeric,delimiters=format&&format.delimiters,thousands=delimiters&&delimiters.thousands,decimal=delimiters&&delimiters.decimal;if(thousands||decimal){var splitValue=formatted.split('.');formatted=thousands?splitValue[0].replace(/(\d)(?=(\d{3})+(?!\d))/g,'$1'+thousands):splitValue[0];decimal=decimal||'.';if(splitValue.length>1){formatted=formatted+decimal+splitValue[1];}}
117
+ return formatted;},readableArea:function(area,isMetric,precision){var areaStr,units,precision=BM.Util.extend({},defaultPrecision,precision);if(isMetric){units=['ha','m'];type=typeof isMetric;if(type==='string'){units=[isMetric];}else if(type!=='boolean'){units=isMetric;}
118
+ if(area>=1000000&&units.indexOf('km')!==-1){areaStr=BM.GeometryUtil.formattedNumber(area*0.000001,precision['km'])+' km²';}else if(area>=10000&&units.indexOf('ha')!==-1){areaStr=BM.GeometryUtil.formattedNumber(area*0.0001,precision['ha'])+' ha';}else{areaStr=BM.GeometryUtil.formattedNumber(area,precision['m'])+' m²';}}else{area/=0.836127;if(area>=3097600){areaStr=BM.GeometryUtil.formattedNumber(area/3097600,precision['mi'])+' mi²';}else if(area>=4840){areaStr=BM.GeometryUtil.formattedNumber(area/4840,precision['ac'])+' acres';}else{areaStr=BM.GeometryUtil.formattedNumber(area,precision['yd'])+' yd²';}}
119
+ return areaStr;},readableDistance:function(distance,isMetric,isFeet,isNauticalMile,precision){var distanceStr,units,precision=BM.Util.extend({},defaultPrecision,precision);if(isMetric){units=typeof isMetric=='string'?isMetric:'metric';}else if(isFeet){units='feet';}else if(isNauticalMile){units='nauticalMile';}else{units='yards';}
120
+ switch(units){case'metric':if(distance>1000){distanceStr=BM.GeometryUtil.formattedNumber(distance/1000,precision['km'])+' km';}else{distanceStr=BM.GeometryUtil.formattedNumber(distance,precision['m'])+' m';}
121
+ break;case'feet':distance*=1.09361*3;distanceStr=BM.GeometryUtil.formattedNumber(distance,precision['ft'])+' ft';break;case'nauticalMile':distance*=0.53996;distanceStr=BM.GeometryUtil.formattedNumber(distance/1000,precision['nm'])+' nm';break;case'yards':default:distance*=1.09361;if(distance>1760){distanceStr=BM.GeometryUtil.formattedNumber(distance/1760,precision['mi'])+' miles';}else{distanceStr=BM.GeometryUtil.formattedNumber(distance,precision['yd'])+' yd';}
122
+ break;}
123
+ return distanceStr;},isVersion07x:function(){var version=BM.version.split('.');return parseInt(version[0],10)===0&&parseInt(version[1],10)===7;},});})();BM.Util.extend(BM.LineUtil,{segmentsIntersect:function(p,p1,p2,p3){return this._checkCounterclockwise(p,p2,p3)!==this._checkCounterclockwise(p1,p2,p3)&&this._checkCounterclockwise(p,p1,p2)!==this._checkCounterclockwise(p,p1,p3);},_checkCounterclockwise:function(p,p1,p2){return(p2.y-p.y)*(p1.x-p.x)>(p1.y-p.y)*(p2.x-p.x);}});BM.Polyline.include({intersects:function(){var points=this._getProjectedPoints(),len=points?points.length:0,i,p,p1;if(this._tooFewPointsForIntersection()){return false;}
124
+ for(i=len-1;i>=3;i--){p=points[i-1];p1=points[i];if(this._lineSegmentsIntersectsRange(p,p1,i-2)){return true;}}
125
+ return false;},newLatLngIntersects:function(latlng,skipFirst){if(!this._map){return false;}
126
+ return this.newPointIntersects(this._map.latLngToLayerPoint(latlng),skipFirst);},newPointIntersects:function(newPoint,skipFirst){var points=this._getProjectedPoints(),len=points?points.length:0,lastPoint=points?points[len-1]:null,maxIndex=len-2;if(this._tooFewPointsForIntersection(1)){return false;}
127
+ return this._lineSegmentsIntersectsRange(lastPoint,newPoint,maxIndex,skipFirst?1:0);},_tooFewPointsForIntersection:function(extraPoints){var points=this._getProjectedPoints(),len=points?points.length:0;len+=extraPoints||0;return!points||len<=3;},_lineSegmentsIntersectsRange:function(p,p1,maxIndex,minIndex){var points=this._getProjectedPoints(),p2,p3;minIndex=minIndex||0;for(var j=maxIndex;j>minIndex;j--){p2=points[j-1];p3=points[j];if(BM.LineUtil.segmentsIntersect(p,p1,p2,p3)){return true;}}
128
+ return false;},_getProjectedPoints:function(){if(!this._defaultShape){return this._originalPoints;}
129
+ var points=[],_shape=this._defaultShape();for(var i=0;i<_shape.length;i++){points.push(this._map.latLngToLayerPoint(_shape[i]));}
130
+ return points;}});BM.Polygon.include({intersects:function(){var polylineIntersects,points=this._getProjectedPoints(),len,firstPoint,lastPoint,maxIndex;if(this._tooFewPointsForIntersection()){return false;}
131
+ polylineIntersects=BM.Polyline.prototype.intersects.call(this);if(polylineIntersects){return true;}
132
+ len=points.length;firstPoint=points[0];lastPoint=points[len-1];maxIndex=len-2;return this._lineSegmentsIntersectsRange(lastPoint,firstPoint,maxIndex,1);}});BM.Control.Draw=BM.Control.extend({options:{position:'topleft',draw:{},edit:false},initialize:function(options){if(BM.version<'0.7'){throw new Error('Leaflet.draw 0.2.3+ requires Leaflet 0.7.0+. Download latest from https://github.com/Leaflet/Leaflet/');}
133
+ BM.Control.prototype.initialize.call(this,options);var toolbar;this._toolbars={};if(BM.DrawToolbar&&this.options.draw){toolbar=new BM.DrawToolbar(this.options.draw);this._toolbars[BM.DrawToolbar.TYPE]=toolbar;this._toolbars[BM.DrawToolbar.TYPE].on('enable',this._toolbarEnabled,this);}
134
+ if(BM.EditToolbar&&this.options.edit){toolbar=new BM.EditToolbar(this.options.edit);this._toolbars[BM.EditToolbar.TYPE]=toolbar;this._toolbars[BM.EditToolbar.TYPE].on('enable',this._toolbarEnabled,this);}
135
+ BM.toolbar=this;},onAdd:function(map){var container=BM.DomUtil.create('div','bigemap-draw'),addedTopClass=false,topClassName='bigemap-draw-toolbar-top',toolbarContainer;for(var toolbarId in this._toolbars){if(this._toolbars.hasOwnProperty(toolbarId)){toolbarContainer=this._toolbars[toolbarId].addToolbar(map);if(toolbarContainer){if(!addedTopClass){if(!BM.DomUtil.hasClass(toolbarContainer,topClassName)){BM.DomUtil.addClass(toolbarContainer.childNodes[0],topClassName);}
136
+ addedTopClass=true;}
137
+ container.appendChild(toolbarContainer);}}}
138
+ return container;},onRemove:function(){for(var toolbarId in this._toolbars){if(this._toolbars.hasOwnProperty(toolbarId)){this._toolbars[toolbarId].removeToolbar();}}},setDrawingOptions:function(options){for(var toolbarId in this._toolbars){if(this._toolbars[toolbarId]instanceof BM.DrawToolbar){this._toolbars[toolbarId].setOptions(options);}}},_toolbarEnabled:function(e){var enabledToolbar=e.target;for(var toolbarId in this._toolbars){if(this._toolbars[toolbarId]!==enabledToolbar){this._toolbars[toolbarId].disable();}}}});BM.Map.mergeOptions({drawControlTooltips:true,drawControl:false});BM.Map.addInitHook(function(){if(this.options.drawControl){this.drawControl=new BM.Control.Draw();this.addControl(this.drawControl);}});BM.Draw=BM.Draw||{};BM.Draw.Tooltip=BM.Class.extend({initialize:function(map){this._map=map;this._popupPane=map._panes.popupPane;this._visible=false;this._container=map.options.drawControlTooltips?BM.DomUtil.create('div','bigemap-draw-tooltip',this._popupPane):null;this._singleLineLabel=false;this._map.on('mouseout',this._onMouseOut,this);},dispose:function(){this._map.off('mouseout',this._onMouseOut,this);if(this._container){this._popupPane.removeChild(this._container);this._container=null;}},updateContent:function(labelText){if(!this._container){return this;}
139
+ labelText.subtext=labelText.subtext||'';if(labelText.subtext.length===0&&!this._singleLineLabel){BM.DomUtil.addClass(this._container,'bigemap-draw-tooltip-single');this._singleLineLabel=true;}
140
+ else if(labelText.subtext.length>0&&this._singleLineLabel){BM.DomUtil.removeClass(this._container,'bigemap-draw-tooltip-single');this._singleLineLabel=false;}
141
+ this._container.innerHTML=(labelText.subtext.length>0?'<span class="bigemap-draw-tooltip-subtext">'+labelText.subtext+'</span>'+'<br />':'')+'<span>'+labelText.text+'</span>';if(!labelText.text&&!labelText.subtext){this._visible=false;this._container.style.visibility='hidden';}else{this._visible=true;this._container.style.visibility='inherit';}
142
+ return this;},updatePosition:function(latlng){var pos=this._map.latLngToLayerPoint(latlng),tooltipContainer=this._container;if(this._container){if(this._visible){tooltipContainer.style.visibility='inherit';}
143
+ BM.DomUtil.setPosition(tooltipContainer,pos);}
144
+ return this;},showAsError:function(){if(this._container){BM.DomUtil.addClass(this._container,'bigemap-error-draw-tooltip');}
145
+ return this;},removeError:function(){if(this._container){BM.DomUtil.removeClass(this._container,'bigemap-error-draw-tooltip');}
146
+ return this;},_onMouseOut:function(){if(this._container){this._container.style.visibility='hidden';}}});BM.Toolbar=BM.Class.extend({initialize:function(options){BM.setOptions(this,options);this._modes={};this._actionButtons=[];this._activeMode=null;var version=BM.version.split('.');if(parseInt(version[0],10)===1&&parseInt(version[1],10)>=2){BM.Toolbar.include(BM.Evented.prototype);}else{BM.Toolbar.include(BM.Mixin.Events);}},enabled:function(){return this._activeMode!==null;},disable:function(){if(!this.enabled()){return;}
147
+ this._activeMode.handler.disable();},addToolbar:function(map){var container=BM.DomUtil.create('div','bigemap-draw-section'),buttonIndex=0,buttonClassPrefix=this._toolbarClass||'',modeHandlers=this.getModeHandlers(map),i;this._toolbarContainer=BM.DomUtil.create('div','bigemap-draw-toolbar bigemap-bar');this._map=map;for(i=0;i<modeHandlers.length;i++){if(modeHandlers[i].enabled){this._initModeHandler(modeHandlers[i].handler,this._toolbarContainer,buttonIndex++,buttonClassPrefix,modeHandlers[i].title);}}
148
+ if(!buttonIndex){return;}
149
+ this._lastButtonIndex=--buttonIndex;this._actionsContainer=BM.DomUtil.create('ul','bigemap-draw-actions');container.appendChild(this._toolbarContainer);container.appendChild(this._actionsContainer);return container;},removeToolbar:function(){for(var handlerId in this._modes){if(this._modes.hasOwnProperty(handlerId)){this._disposeButton(this._modes[handlerId].button,this._modes[handlerId].handler.enable,this._modes[handlerId].handler);this._modes[handlerId].handler.disable();this._modes[handlerId].handler.off('enabled',this._handlerActivated,this).off('disabled',this._handlerDeactivated,this);}}
150
+ this._modes={};for(var i=0,l=this._actionButtons.length;i<l;i++){this._disposeButton(this._actionButtons[i].button,this._actionButtons[i].callback,this);}
151
+ this._actionButtons=[];this._actionsContainer=null;},_initModeHandler:function(handler,container,buttonIndex,classNamePredix,buttonTitle){var type=handler.type;this._modes[type]={};this._modes[type].handler=handler;this._modes[type].button=this._createButton({type:type,title:buttonTitle,className:classNamePredix+'-'+type,container:container,callback:this._modes[type].handler.enable,context:this._modes[type].handler});this._modes[type].buttonIndex=buttonIndex;this._modes[type].handler.on('enabled',this._handlerActivated,this).on('disabled',this._handlerDeactivated,this);},_detectIOS:function(){var iOS=(/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream);return iOS;},_createButton:function(options){var link=BM.DomUtil.create('a',options.className||'',options.container);var sr=BM.DomUtil.create('span','sr-only',options.container);link.href='#';link.appendChild(sr);if(options.title){link.title=options.title;sr.innerHTML=options.title;}
152
+ if(options.text){link.innerHTML=options.text;sr.innerHTML=options.text;}
153
+ var buttonEvent=this._detectIOS()?'touchstart':'click';BM.DomEvent.on(link,'click',BM.DomEvent.stopPropagation).on(link,'mousedown',BM.DomEvent.stopPropagation).on(link,'dblclick',BM.DomEvent.stopPropagation).on(link,'touchstart',BM.DomEvent.stopPropagation).on(link,'click',BM.DomEvent.preventDefault).on(link,buttonEvent,options.callback,options.context);return link;},_disposeButton:function(button,callback){var buttonEvent=this._detectIOS()?'touchstart':'click';BM.DomEvent.off(button,'click',BM.DomEvent.stopPropagation).off(button,'mousedown',BM.DomEvent.stopPropagation).off(button,'dblclick',BM.DomEvent.stopPropagation).off(button,'touchstart',BM.DomEvent.stopPropagation).off(button,'click',BM.DomEvent.preventDefault).off(button,buttonEvent,callback);},_handlerActivated:function(e){this.disable();this._activeMode=this._modes[e.handler];BM.DomUtil.addClass(this._activeMode.button,'bigemap-draw-toolbar-button-enabled');this._showActionsToolbar();this.fire('enable');},_handlerDeactivated:function(){this._hideActionsToolbar();BM.DomUtil.removeClass(this._activeMode.button,'bigemap-draw-toolbar-button-enabled');this._activeMode=null;this.fire('disable');},_createActions:function(handler){var container=this._actionsContainer,buttons=this.getActions(handler),l=buttons.length,li,di,dl,button;for(di=0,dl=this._actionButtons.length;di<dl;di++){this._disposeButton(this._actionButtons[di].button,this._actionButtons[di].callback);}
154
+ this._actionButtons=[];while(container.firstChild){container.removeChild(container.firstChild);}
155
+ for(var i=0;i<l;i++){if('enabled'in buttons[i]&&!buttons[i].enabled){continue;}
156
+ li=BM.DomUtil.create('li','',container);button=this._createButton({title:buttons[i].title,text:buttons[i].text,container:li,callback:buttons[i].callback,context:buttons[i].context});this._actionButtons.push({button:button,callback:buttons[i].callback});}},_showActionsToolbar:function(){var buttonIndex=this._activeMode.buttonIndex,lastButtonIndex=this._lastButtonIndex,toolbarPosition=this._activeMode.button.offsetTop-1;this._createActions(this._activeMode.handler);this._actionsContainer.style.top=toolbarPosition+'px';if(buttonIndex===0){BM.DomUtil.addClass(this._toolbarContainer,'bigemap-draw-toolbar-notop');BM.DomUtil.addClass(this._actionsContainer,'bigemap-draw-actions-top');}
157
+ if(buttonIndex===lastButtonIndex){BM.DomUtil.addClass(this._toolbarContainer,'bigemap-draw-toolbar-nobottom');BM.DomUtil.addClass(this._actionsContainer,'bigemap-draw-actions-bottom');}
158
+ this._actionsContainer.style.display='block';this._map.fire(BM.Draw.Event.TOOLBAROPENED);},_hideActionsToolbar:function(){this._actionsContainer.style.display='none';BM.DomUtil.removeClass(this._toolbarContainer,'bigemap-draw-toolbar-notop');BM.DomUtil.removeClass(this._toolbarContainer,'bigemap-draw-toolbar-nobottom');BM.DomUtil.removeClass(this._actionsContainer,'bigemap-draw-actions-top');BM.DomUtil.removeClass(this._actionsContainer,'bigemap-draw-actions-bottom');this._map.fire(BM.Draw.Event.TOOLBARCLOSED);}});BM.DrawToolbar=BM.Toolbar.extend({statics:{TYPE:'draw'},options:{polyline:{},polygon:{},rectangle:{},circle:{},marker:{},circlemarker:{}},initialize:function(options){for(var type in this.options){if(this.options.hasOwnProperty(type)){if(options[type]){options[type]=BM.extend({},this.options[type],options[type]);}}}
159
+ this._toolbarClass='bigemap-draw-draw';BM.Toolbar.prototype.initialize.call(this,options);},getModeHandlers:function(map){return[{enabled:this.options.polyline,handler:new BM.Draw.Polyline(map,this.options.polyline),title:BM.drawLocal.draw.toolbar.buttons.polyline},{enabled:this.options.polygon,handler:new BM.Draw.Polygon(map,this.options.polygon),title:BM.drawLocal.draw.toolbar.buttons.polygon},{enabled:this.options.rectangle,handler:new BM.Draw.Rectangle(map,this.options.rectangle),title:BM.drawLocal.draw.toolbar.buttons.rectangle},{enabled:this.options.circle,handler:new BM.Draw.Circle(map,this.options.circle),title:BM.drawLocal.draw.toolbar.buttons.circle},{enabled:this.options.marker,handler:new BM.Draw.Marker(map,this.options.marker),title:BM.drawLocal.draw.toolbar.buttons.marker},{enabled:this.options.circlemarker,handler:new BM.Draw.CircleMarker(map,this.options.circlemarker),title:BM.drawLocal.draw.toolbar.buttons.circlemarker}];},getActions:function(handler){return[{enabled:handler.completeShape,title:BM.drawLocal.draw.toolbar.finish.title,text:BM.drawLocal.draw.toolbar.finish.text,callback:handler.completeShape,context:handler},{enabled:handler.deleteLastVertex,title:BM.drawLocal.draw.toolbar.undo.title,text:BM.drawLocal.draw.toolbar.undo.text,callback:handler.deleteLastVertex,context:handler},{title:BM.drawLocal.draw.toolbar.actions.title,text:BM.drawLocal.draw.toolbar.actions.text,callback:this.disable,context:this}];},setOptions:function(options){BM.setOptions(this,options);for(var type in this._modes){if(this._modes.hasOwnProperty(type)&&options.hasOwnProperty(type)){this._modes[type].handler.setOptions(options[type]);}}}});BM.EditToolbar=BM.Toolbar.extend({statics:{TYPE:'edit'},options:{edit:{selectedPathOptions:{dashArray:'10, 10',fill:true,fillColor:'#fe57a1',fillOpacity:0.1,maintainColor:false}},remove:{},poly:null,featureGroup:null},initialize:function(options){if(options.edit){if(typeof options.edit.selectedPathOptions==='undefined'){options.edit.selectedPathOptions=this.options.edit.selectedPathOptions;}
160
+ options.edit.selectedPathOptions=BM.extend({},this.options.edit.selectedPathOptions,options.edit.selectedPathOptions);}
161
+ if(options.remove){options.remove=BM.extend({},this.options.remove,options.remove);}
162
+ if(options.poly){options.poly=BM.extend({},this.options.poly,options.poly);}
163
+ this._toolbarClass='bigemap-draw-edit';BM.Toolbar.prototype.initialize.call(this,options);this._selectedFeatureCount=0;},getModeHandlers:function(map){var featureGroup=this.options.featureGroup;return[{enabled:this.options.edit,handler:new BM.EditToolbar.Edit(map,{featureGroup:featureGroup,selectedPathOptions:this.options.edit.selectedPathOptions,poly:this.options.poly}),title:BM.drawLocal.edit.toolbar.buttons.edit},{enabled:this.options.remove,handler:new BM.EditToolbar.Delete(map,{featureGroup:featureGroup}),title:BM.drawLocal.edit.toolbar.buttons.remove}];},getActions:function(handler){var actions=[{title:BM.drawLocal.edit.toolbar.actions.save.title,text:BM.drawLocal.edit.toolbar.actions.save.text,callback:this._save,context:this},{title:BM.drawLocal.edit.toolbar.actions.cancel.title,text:BM.drawLocal.edit.toolbar.actions.cancel.text,callback:this.disable,context:this}];if(handler.removeAllLayers){actions.push({title:BM.drawLocal.edit.toolbar.actions.clearAll.title,text:BM.drawLocal.edit.toolbar.actions.clearAll.text,callback:this._clearAllLayers,context:this});}
164
+ return actions;},addToolbar:function(map){var container=BM.Toolbar.prototype.addToolbar.call(this,map);this._checkDisabled();this.options.featureGroup.on('layeradd layerremove',this._checkDisabled,this);return container;},removeToolbar:function(){this.options.featureGroup.off('layeradd layerremove',this._checkDisabled,this);BM.Toolbar.prototype.removeToolbar.call(this);},disable:function(){if(!this.enabled()){return;}
165
+ this._activeMode.handler.revertLayers();BM.Toolbar.prototype.disable.call(this);},_save:function(){this._activeMode.handler.save();if(this._activeMode){this._activeMode.handler.disable();}},_clearAllLayers:function(){this._activeMode.handler.removeAllLayers();if(this._activeMode){this._activeMode.handler.disable();}},_checkDisabled:function(){var featureGroup=this.options.featureGroup,hasLayers=featureGroup.getLayers().length!==0,button;if(this.options.edit){button=this._modes[BM.EditToolbar.Edit.TYPE].button;if(hasLayers){BM.DomUtil.removeClass(button,'bigemap-disabled');}else{BM.DomUtil.addClass(button,'bigemap-disabled');}
166
+ button.setAttribute('title',hasLayers?BM.drawLocal.edit.toolbar.buttons.edit:BM.drawLocal.edit.toolbar.buttons.editDisabled);}
167
+ if(this.options.remove){button=this._modes[BM.EditToolbar.Delete.TYPE].button;if(hasLayers){BM.DomUtil.removeClass(button,'bigemap-disabled');}else{BM.DomUtil.addClass(button,'bigemap-disabled');}
168
+ button.setAttribute('title',hasLayers?BM.drawLocal.edit.toolbar.buttons.remove:BM.drawLocal.edit.toolbar.buttons.removeDisabled);}}});BM.EditToolbar.Edit=BM.Handler.extend({statics:{TYPE:'edit'},initialize:function(map,options){BM.Handler.prototype.initialize.call(this,map);BM.setOptions(this,options);this._featureGroup=options.featureGroup;if(!(this._featureGroup instanceof BM.FeatureGroup)){throw new Error('options.featureGroup must be a BM.FeatureGroup');}
169
+ this._uneditedLayerProps={};this.type=BM.EditToolbar.Edit.TYPE;var version=BM.version.split('.');if(parseInt(version[0],10)===1&&parseInt(version[1],10)>=2){BM.EditToolbar.Edit.include(BM.Evented.prototype);}else{BM.EditToolbar.Edit.include(BM.Mixin.Events);}},enable:function(){if(this._enabled||!this._hasAvailableLayers()){return;}
170
+ this.fire('enabled',{handler:this.type});this._map.fire(BM.Draw.Event.EDITSTART,{handler:this.type});BM.Handler.prototype.enable.call(this);this._featureGroup.on('layeradd',this._enableLayerEdit,this).on('layerremove',this._disableLayerEdit,this);},disable:function(){if(!this._enabled){return;}
171
+ this._featureGroup.off('layeradd',this._enableLayerEdit,this).off('layerremove',this._disableLayerEdit,this);BM.Handler.prototype.disable.call(this);this._map.fire(BM.Draw.Event.EDITSTOP,{handler:this.type});this.fire('disabled',{handler:this.type});},addHooks:function(){var map=this._map;if(map){map.getContainer().focus();this._featureGroup.eachLayer(this._enableLayerEdit,this);this._tooltip=new BM.Draw.Tooltip(this._map);this._tooltip.updateContent({text:BM.drawLocal.edit.handlers.edit.tooltip.text,subtext:BM.drawLocal.edit.handlers.edit.tooltip.subtext});map._editTooltip=this._tooltip;this._updateTooltip();this._map.on('mousemove',this._onMouseMove,this).on('touchmove',this._onMouseMove,this).on('MSPointerMove',this._onMouseMove,this).on(BM.Draw.Event.EDITVERTEX,this._updateTooltip,this);}},removeHooks:function(){if(this._map){this._featureGroup.eachLayer(this._disableLayerEdit,this);this._uneditedLayerProps={};this._tooltip.dispose();this._tooltip=null;this._map.off('mousemove',this._onMouseMove,this).off('touchmove',this._onMouseMove,this).off('MSPointerMove',this._onMouseMove,this).off(BM.Draw.Event.EDITVERTEX,this._updateTooltip,this);}},revertLayers:function(){this._featureGroup.eachLayer(function(layer){this._revertLayer(layer);},this);},save:function(){var editedLayers=new BM.LayerGroup();this._featureGroup.eachLayer(function(layer){if(layer.edited){editedLayers.addLayer(layer);layer.edited=false;}});this._map.fire(BM.Draw.Event.EDITED,{layers:editedLayers});},_backupLayer:function(layer){var id=BM.Util.stamp(layer);if(!this._uneditedLayerProps[id]){if(layer instanceof BM.Polyline||layer instanceof BM.Polygon||layer instanceof BM.Rectangle){this._uneditedLayerProps[id]={latlngs:BM.LatLngUtil.cloneLatLngs(layer.getLatLngs())};}else if(layer instanceof BM.Circle){this._uneditedLayerProps[id]={latlng:BM.LatLngUtil.cloneLatLng(layer.getLatLng()),radius:layer.getRadius()};}else if(layer instanceof BM.Marker||layer instanceof BM.CircleMarker){this._uneditedLayerProps[id]={latlng:BM.LatLngUtil.cloneLatLng(layer.getLatLng())};}}},_getTooltipText:function(){return({text:BM.drawLocal.edit.handlers.edit.tooltip.text,subtext:BM.drawLocal.edit.handlers.edit.tooltip.subtext});},_updateTooltip:function(){this._tooltip.updateContent(this._getTooltipText());},_revertLayer:function(layer){var id=BM.Util.stamp(layer);layer.edited=false;if(this._uneditedLayerProps.hasOwnProperty(id)){if(layer instanceof BM.Polyline||layer instanceof BM.Polygon||layer instanceof BM.Rectangle){layer.setLatLngs(this._uneditedLayerProps[id].latlngs);}else if(layer instanceof BM.Circle){layer.setLatLng(this._uneditedLayerProps[id].latlng);layer.setRadius(this._uneditedLayerProps[id].radius);}else if(layer instanceof BM.Marker||layer instanceof BM.CircleMarker){layer.setLatLng(this._uneditedLayerProps[id].latlng);}
172
+ layer.fire('revert-edited',{layer:layer});}},_enableLayerEdit:function(e){var layer=e.layer||e.target||e,pathOptions,poly;this._backupLayer(layer);if(this.options.poly){poly=BM.Util.extend({},this.options.poly);layer.options.poly=poly;}
173
+ if(this.options.selectedPathOptions){pathOptions=BM.Util.extend({},this.options.selectedPathOptions);if(pathOptions.maintainColor){pathOptions.color=layer.options.color;pathOptions.fillColor=layer.options.fillColor;}
174
+ layer.options.original=BM.extend({},layer.options);layer.options.editing=pathOptions;}
175
+ if(layer instanceof BM.Marker){if(layer.editing){layer.editing.enable();}
176
+ layer.dragging.enable();layer.on('dragend',this._onMarkerDragEnd).on('touchmove',this._onTouchMove,this).on('MSPointerMove',this._onTouchMove,this).on('touchend',this._onMarkerDragEnd,this).on('MSPointerUp',this._onMarkerDragEnd,this);}else{layer.editing.enable();}},_disableLayerEdit:function(e){var layer=e.layer||e.target||e;layer.edited=false;if(layer.editing){layer.editing.disable();}
177
+ delete layer.options.editing;delete layer.options.original;if(this._selectedPathOptions){if(layer instanceof BM.Marker){this._toggleMarkerHighlight(layer);}else{layer.setStyle(layer.options.previousOptions);delete layer.options.previousOptions;}}
178
+ if(layer instanceof BM.Marker){layer.dragging.disable();layer.off('dragend',this._onMarkerDragEnd,this).off('touchmove',this._onTouchMove,this).off('MSPointerMove',this._onTouchMove,this).off('touchend',this._onMarkerDragEnd,this).off('MSPointerUp',this._onMarkerDragEnd,this);}else{layer.editing.disable();}},_onMouseMove:function(e){this._tooltip.updatePosition(e.latlng);},_onMarkerDragEnd:function(e){var layer=e.target;layer.edited=true;this._map.fire(BM.Draw.Event.EDITMOVE,{layer:layer});},_onTouchMove:function(e){var touchEvent=e.originalEvent.changedTouches[0],layerPoint=this._map.mouseEventToLayerPoint(touchEvent),latlng=this._map.layerPointToLatLng(layerPoint);e.target.setLatLng(latlng);},_hasAvailableLayers:function(){return this._featureGroup.getLayers().length!==0;}});BM.EditToolbar.Delete=BM.Handler.extend({statics:{TYPE:'remove'},initialize:function(map,options){BM.Handler.prototype.initialize.call(this,map);BM.Util.setOptions(this,options);this._deletableLayers=this.options.featureGroup;if(!(this._deletableLayers instanceof BM.FeatureGroup)){throw new Error('options.featureGroup must be a BM.FeatureGroup');}
179
+ this.type=BM.EditToolbar.Delete.TYPE;var version=BM.version.split('.');if(parseInt(version[0],10)===1&&parseInt(version[1],10)>=2){BM.EditToolbar.Delete.include(BM.Evented.prototype);}else{BM.EditToolbar.Delete.include(BM.Mixin.Events);}},enable:function(){if(this._enabled||!this._hasAvailableLayers()){return;}
180
+ this.fire('enabled',{handler:this.type});this._map.fire(BM.Draw.Event.DELETESTART,{handler:this.type});BM.Handler.prototype.enable.call(this);this._deletableLayers.on('layeradd',this._enableLayerDelete,this).on('layerremove',this._disableLayerDelete,this);},disable:function(){if(!this._enabled){return;}
181
+ this._deletableLayers.off('layeradd',this._enableLayerDelete,this).off('layerremove',this._disableLayerDelete,this);BM.Handler.prototype.disable.call(this);this._map.fire(BM.Draw.Event.DELETESTOP,{handler:this.type});this.fire('disabled',{handler:this.type});},addHooks:function(){var map=this._map;if(map){map.getContainer().focus();this._deletableLayers.eachLayer(this._enableLayerDelete,this);this._deletedLayers=new BM.LayerGroup();this._tooltip=new BM.Draw.Tooltip(this._map);this._tooltip.updateContent({text:BM.drawLocal.edit.handlers.remove.tooltip.text});this._map.on('mousemove',this._onMouseMove,this);}},removeHooks:function(){if(this._map){this._deletableLayers.eachLayer(this._disableLayerDelete,this);this._deletedLayers=null;this._tooltip.dispose();this._tooltip=null;this._map.off('mousemove',this._onMouseMove,this);}},revertLayers:function(){this._deletedLayers.eachLayer(function(layer){this._deletableLayers.addLayer(layer);layer.fire('revert-deleted',{layer:layer});},this);},save:function(){this._map.fire(BM.Draw.Event.DELETED,{layers:this._deletedLayers});},removeAllLayers:function(){this._deletableLayers.eachLayer(function(layer){this._removeLayer({layer:layer});},this);this.save();},_enableLayerDelete:function(e){var layer=e.layer||e.target||e;layer.on('click',this._removeLayer,this);},_disableLayerDelete:function(e){var layer=e.layer||e.target||e;layer.off('click',this._removeLayer,this);this._deletedLayers.removeLayer(layer);},_removeLayer:function(e){var layer=e.layer||e.target||e;this._deletableLayers.removeLayer(layer);this._deletedLayers.addLayer(layer);layer.fire('deleted');},_onMouseMove:function(e){this._tooltip.updatePosition(e.latlng);},_hasAvailableLayers:function(){return this._deletableLayers.getLayers().length!==0;}});
Binary file