you can't draw that!\" // Message that will show when intersect\n\n },\n shapeOptions: {\n color: \"#bada55\"\n }\n },\n circle: false,\n // Turns off this drawing tool\n rectangle: {\n shapeOptions: {\n clickable: false\n }\n },\n marker: {\n icon: icon(next, zoom)\n }\n },\n position: \"topright\",\n count: next,\n onCreated: e => {\n console.log({\n next,\n e\n });\n onCreated(next);\n },\n allowIntersection: false\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 236,\n columnNumber: 11\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 235,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(LayerGroup, {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 273,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(ScaleControl, {\n position: \"topleft\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 274,\n columnNumber: 9\n }, this), /*#__PURE__*/_jsxDEV(ZoomControl, {\n position: \"topleft\"\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 275,\n columnNumber: 9\n }, this)]\n }, void 0, true, {\n fileName: _jsxFileName,\n lineNumber: 198,\n columnNumber: 7\n }, this)\n }, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 197,\n columnNumber: 5\n }, this);\n};\n\n_s2(LeafletMap, \"7uRv2Jzz6xIjgQx6GjFUEg2wnP4=\");\n\n_c2 = LeafletMap;\nexport default LeafletMap;\n\nvar _c, _c2;\n\n$RefreshReg$(_c, \"MyComponent\");\n$RefreshReg$(_c2, \"LeafletMap\");","map":{"version":3,"names":["React","useState","useRef","useMemo","MapContainer","TileLayer","FeatureGroup","Rectangle","useMap","Popup","Marker","LayerGroup","ZoomControl","ScaleControl","EditControl","L","bedNumb","pinMB","icon","iconUrl","iconSize","iconAnchor","popupAnchor","shadowUrl","shadowSize","shadowAnchor","drawLocal","draw","toolbar","actions","title","text","finish","undo","buttons","polyline","polygon","rectangle","circle","marker","circlemarker","handlers","tooltip","start","radius","cont","end","error","simpleshape","edit","save","cancel","clearAll","editDisabled","remove","removeDisabled","subtext","val","zoom","divIcon","className","html","Math","pow","MyComponent","setZoom","map","LeafletMap","outerBounds","leafEl","mapRef","onCreated","console","log","next","add","floor","random","location","current","direction","mapInstance","on","_zoom","height","shapeOptions","color","weight","allowIntersection","drawError","message","clickable","e"],"sources":["/Users/mahdi/Documents/work/programming/barnameNegar/arbaeenWebApp/src/components/LeafletMap/index.js"],"sourcesContent":["// it has style inside index.scss ---> // Start LeafletMap && end LeafletMap\n\nimport React, { useState, useRef, useMemo } from \"react\";\n\nimport {\n MapContainer,\n TileLayer,\n FeatureGroup,\n Rectangle,\n useMap,\n Popup,\n Marker,\n LayerGroup,\n ZoomControl,\n ScaleControl,\n} from \"react-leaflet\";\n\nimport \"leaflet/dist/leaflet.css\";\nimport \"leaflet-draw/dist/leaflet.draw.css\";\n\nimport { EditControl } from \"react-leaflet-draw\";\n\nimport \"leaflet-draw\";\n\nimport * as L from \"leaflet\";\n\nconst bedNumb = \"تخت شماره 33\";\n\nconst pinMB = L.icon({\n iconUrl: \"images/LeafletMapplaceholder.png\",\n iconSize: [24, 41],\n iconAnchor: [0, 44],\n popupAnchor: [12, -40],\n shadowUrl: null,\n shadowSize: null,\n shadowAnchor: null,\n});\n\n// const MyCustomMarker = L.icon({\n// iconUrl: placeholder,\n// iconSize: [24, 41],\n// iconAnchor: [0, 44],\n// popupAnchor: [12, -40],\n// shadowUrl: null,\n// shadowSize: null,\n// shadowAnchor: null,\n// });\n\nL.drawLocal = {\n draw: {\n toolbar: {\n actions: {\n title: \"لغو کردن رسم\",\n text: \"لغو\",\n },\n finish: {\n title: \"پایان رسم\",\n text: \"پایان رسم\",\n },\n undo: {\n title: \"پاک کردن آخرین نقطه رسم شده\",\n text: \"پاک کردن آخرین نقطه رسم شده\",\n },\n buttons: {\n polyline: \"موکب مورد نظر خود را رسم نمایید\",\n polygon: \"رسم پولیگان\",\n rectangle: \"رسم جای خواب\",\n circle: \"رسم دایره\",\n marker: \"رسم مارکر\",\n circlemarker: \"رسم دایره مارکر\",\n },\n },\n handlers: {\n circle: {\n tooltip: {\n start: \"کلیک کنید و سپس درگ کنید تا یک دایره بکشید.\",\n },\n radius: \"ردیوس\",\n },\n circlemarker: {\n tooltip: {\n start: \"با کلیک بر روی نقشه یک مارکر رسم کنید.\",\n },\n },\n marker: {\n icon: \"images/LeafletMapplaceholder.png\",\n tooltip: {\n start: \"با کلیک بر روی نقشه یک مارکر رسم کنید.\",\n },\n },\n polygon: {\n tooltip: {\n start: \"یک شکل رسم کنید.\",\n cont: \"ادامه رسم شکل.\",\n end: \"برای پایان رسم بر روی اولین نقظه کلیک کنید.\",\n },\n },\n polyline: {\n error: \"Error: shape edges cannot cross!\",\n tooltip: {\n start: \"با کلیک کردن یک خط رسم کنید.\",\n cont: \"با کلیک به رسم خود ادامه دهید.\",\n end: \"برای پایان رسم بر روی آخرین نقظ رسم شده کلیک کنید.\",\n },\n },\n rectangle: {\n tooltip: {\n start: \"با کلیک و درگ کردن یک جای خواب رسم کنید.\",\n },\n },\n simpleshape: {\n tooltip: {\n end: \"ماوس را رها کنید تا رسم تمام شود.\",\n },\n },\n },\n },\n edit: {\n toolbar: {\n actions: {\n save: {\n title: \"ذخیره تنظیمات\",\n text: \"ذخیره\",\n },\n cancel: {\n title: \"لغو کردن، ویرایش تمام تغییرات نادیده گرفته خواهند شد\",\n text: \"لغو\",\n },\n clearAll: {\n title: \"پاک کردن تمام لایه ها\",\n text: \"پاک کردن لایه ها\",\n },\n },\n buttons: {\n edit: \"ویرایش لایه ها\",\n editDisabled: \"لایه ای برای ویرایش وجود ندارد\",\n remove: \"پاک کردن لایه ها\",\n removeDisabled: \"لایه ای برای پاک کردن وجود ندارد\",\n },\n },\n handlers: {\n edit: {\n tooltip: {\n text: \"Drag handles or markers to edit features.\",\n subtext: \"با کلیک بر روی لغو تغییرات اعمال نخواهند شد.\",\n },\n },\n remove: {\n tooltip: {\n text: \"Click on a feature to remove.\",\n },\n },\n },\n },\n};\n\nconst icon = (val, zoom) =>\n L.divIcon({\n className: \"my-div-icon\",\n html: ``,\n });\n\nfunction MyComponent({ setZoom }) {\n const map = useMap();\n\n return null;\n}\n\nconst LeafletMap = () => {\n // const map =\n const [zoom, setZoom] = useState(22);\n const outerBounds = [\n [50.505, -29.09],\n [52.505, 29.09],\n ];\n\n const leafEl = useRef(null);\n const mapRef = useRef(null);\n const onCreated = () => {\n console.log({ next, add });\n add(Math.floor(Math.random() * 10));\n // const drawnItems = leafEl.current._layers;\n // console.log({ drawnItems });\n };\n const [next, add] = useState(1);\n const location = [38.9072, -77.0369];\n console.log({ mapRef });\n if (mapRef.current) {\n console.log(mapRef.current);\n }\n return (\n \n
{\n mapInstance.on(\"zoomend\", function () {\n console.log(mapRef.current);\n setZoom(mapRef.current._zoom);\n });\n mapRef.current = mapInstance;\n }}\n center={[49.505, -2.09]}\n zoom={zoom}\n maxZoom={24}\n minZoom={18}\n maxNativeZoom={22}\n style={{ height: \"100vh\" }}\n zoomControl={false}\n bounds={outerBounds}\n >\n {/* */}\n \n \n \n {/* */}\n {bedNumb} \n \n \n Oh snap! you can't draw that!\", // Message that will show when intersect\n },\n shapeOptions: {\n color: \"#bada55\",\n },\n },\n circle: false, // Turns off this drawing tool\n rectangle: {\n shapeOptions: {\n clickable: false,\n },\n },\n marker: {\n icon: icon(next, zoom),\n },\n }}\n position=\"topright\"\n count={next}\n onCreated={(e) => {\n console.log({ next, e });\n onCreated(next);\n }}\n allowIntersection={false}\n />\n \n \n \n \n \n
\n );\n};\n\nexport default LeafletMap;\n"],"mappings":";;;;AAAA;AAEA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,MAA1B,EAAkCC,OAAlC,QAAiD,OAAjD;AAEA,SACEC,YADF,EAEEC,SAFF,EAGEC,YAHF,EAIEC,SAJF,EAKEC,MALF,EAMEC,KANF,EAOEC,MAPF,EAQEC,UARF,EASEC,WATF,EAUEC,YAVF,QAWO,eAXP;AAaA,OAAO,0BAAP;AACA,OAAO,oCAAP;AAEA,SAASC,WAAT,QAA4B,oBAA5B;AAEA,OAAO,cAAP;AAEA,OAAO,KAAKC,CAAZ,MAAmB,SAAnB;;AAEA,MAAMC,OAAO,GAAG,cAAhB;AAEA,MAAMC,KAAK,GAAGF,CAAC,CAACG,IAAF,CAAO;EACnBC,OAAO,EAAE,kCADU;EAEnBC,QAAQ,EAAE,CAAC,EAAD,EAAK,EAAL,CAFS;EAGnBC,UAAU,EAAE,CAAC,CAAD,EAAI,EAAJ,CAHO;EAInBC,WAAW,EAAE,CAAC,EAAD,EAAK,CAAC,EAAN,CAJM;EAKnBC,SAAS,EAAE,IALQ;EAMnBC,UAAU,EAAE,IANO;EAOnBC,YAAY,EAAE;AAPK,CAAP,CAAd,C,CAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEAV,CAAC,CAACW,SAAF,GAAc;EACZC,IAAI,EAAE;IACJC,OAAO,EAAE;MACPC,OAAO,EAAE;QACPC,KAAK,EAAE,cADA;QAEPC,IAAI,EAAE;MAFC,CADF;MAKPC,MAAM,EAAE;QACNF,KAAK,EAAE,WADD;QAENC,IAAI,EAAE;MAFA,CALD;MASPE,IAAI,EAAE;QACJH,KAAK,EAAE,6BADH;QAEJC,IAAI,EAAE;MAFF,CATC;MAaPG,OAAO,EAAE;QACPC,QAAQ,EAAE,iCADH;QAEPC,OAAO,EAAE,aAFF;QAGPC,SAAS,EAAE,cAHJ;QAIPC,MAAM,EAAE,WAJD;QAKPC,MAAM,EAAE,WALD;QAMPC,YAAY,EAAE;MANP;IAbF,CADL;IAuBJC,QAAQ,EAAE;MACRH,MAAM,EAAE;QACNI,OAAO,EAAE;UACPC,KAAK,EAAE;QADA,CADH;QAINC,MAAM,EAAE;MAJF,CADA;MAORJ,YAAY,EAAE;QACZE,OAAO,EAAE;UACPC,KAAK,EAAE;QADA;MADG,CAPN;MAYRJ,MAAM,EAAE;QACNrB,IAAI,EAAE,kCADA;QAENwB,OAAO,EAAE;UACPC,KAAK,EAAE;QADA;MAFH,CAZA;MAkBRP,OAAO,EAAE;QACPM,OAAO,EAAE;UACPC,KAAK,EAAE,kBADA;UAEPE,IAAI,EAAE,gBAFC;UAGPC,GAAG,EAAE;QAHE;MADF,CAlBD;MAyBRX,QAAQ,EAAE;QACRY,KAAK,EAAE,mDADC;QAERL,OAAO,EAAE;UACPC,KAAK,EAAE,8BADA;UAEPE,IAAI,EAAE,gCAFC;UAGPC,GAAG,EAAE;QAHE;MAFD,CAzBF;MAiCRT,SAAS,EAAE;QACTK,OAAO,EAAE;UACPC,KAAK,EAAE;QADA;MADA,CAjCH;MAsCRK,WAAW,EAAE;QACXN,OAAO,EAAE;UACPI,GAAG,EAAE;QADE;MADE;IAtCL;EAvBN,CADM;EAqEZG,IAAI,EAAE;IACJrB,OAAO,EAAE;MACPC,OAAO,EAAE;QACPqB,IAAI,EAAE;UACJpB,KAAK,EAAE,eADH;UAEJC,IAAI,EAAE;QAFF,CADC;QAKPoB,MAAM,EAAE;UACNrB,KAAK,EAAE,sDADD;UAENC,IAAI,EAAE;QAFA,CALD;QASPqB,QAAQ,EAAE;UACRtB,KAAK,EAAE,uBADC;UAERC,IAAI,EAAE;QAFE;MATH,CADF;MAePG,OAAO,EAAE;QACPe,IAAI,EAAE,gBADC;QAEPI,YAAY,EAAE,gCAFP;QAGPC,MAAM,EAAE,kBAHD;QAIPC,cAAc,EAAE;MAJT;IAfF,CADL;IAuBJd,QAAQ,EAAE;MACRQ,IAAI,EAAE;QACJP,OAAO,EAAE;UACPX,IAAI,EAAE,2CADC;UAEPyB,OAAO,EAAE;QAFF;MADL,CADE;MAORF,MAAM,EAAE;QACNZ,OAAO,EAAE;UACPX,IAAI,EAAE;QADC;MADH;IAPA;EAvBN;AArEM,CAAd;;AA4GA,MAAMb,IAAI,GAAG,CAACuC,GAAD,EAAMC,IAAN,KACX3C,CAAC,CAAC4C,OAAF,CAAU;EACRC,SAAS,EAAE,aADH;EAERC,IAAI,EAAG;AACX,gCAAgCC,IAAI,CAACC,GAAL,CAAS,CAAT,EAAYL,IAAI,GAAG,EAAnB,CAAuB;AACvD;AACA;AACA,eAAeD,GAAG,IAAI,CAAE;AACxB;AAPY,CAAV,CADF;;AAWA,SAASO,WAAT,OAAkC;EAAA;;EAAA,IAAb;IAAEC;EAAF,CAAa;EAChC,MAAMC,GAAG,GAAG1D,MAAM,EAAlB;EAEA,OAAO,IAAP;AACD;;GAJQwD,W;UACKxD,M;;;KADLwD,W;;AAMT,MAAMG,UAAU,GAAG,MAAM;EAAA;;EACvB;EACA,MAAM,CAACT,IAAD,EAAOO,OAAP,IAAkBhE,QAAQ,CAAC,EAAD,CAAhC;EACA,MAAMmE,WAAW,GAAG,CAClB,CAAC,MAAD,EAAS,CAAC,KAAV,CADkB,EAElB,CAAC,MAAD,EAAS,KAAT,CAFkB,CAApB;EAKA,MAAMC,MAAM,GAAGnE,MAAM,CAAC,IAAD,CAArB;EACA,MAAMoE,MAAM,GAAGpE,MAAM,CAAC,IAAD,CAArB;;EACA,MAAMqE,SAAS,GAAG,MAAM;IACtBC,OAAO,CAACC,GAAR,CAAY;MAAEC,IAAF;MAAQC;IAAR,CAAZ;IACAA,GAAG,CAACb,IAAI,CAACc,KAAL,CAAWd,IAAI,CAACe,MAAL,KAAgB,EAA3B,CAAD,CAAH,CAFsB,CAGtB;IACA;EACD,CALD;;EAMA,MAAM,CAACH,IAAD,EAAOC,GAAP,IAAc1E,QAAQ,CAAC,CAAD,CAA5B;EACA,MAAM6E,QAAQ,GAAG,CAAC,OAAD,EAAU,CAAC,OAAX,CAAjB;EACAN,OAAO,CAACC,GAAR,CAAY;IAAEH;EAAF,CAAZ;;EACA,IAAIA,MAAM,CAACS,OAAX,EAAoB;IAClBP,OAAO,CAACC,GAAR,CAAYH,MAAM,CAACS,OAAnB;EACD;;EACD,oBACE;IAAK,KAAK,EAAE;MAAEC,SAAS,EAAE;IAAb,CAAZ;IAAA,uBACE,QAAC,YAAD;MACE,WAAW,EAAGC,WAAD,IAAiB;QAC5BA,WAAW,CAACC,EAAZ,CAAe,SAAf,EAA0B,YAAY;UACpCV,OAAO,CAACC,GAAR,CAAYH,MAAM,CAACS,OAAnB;UACAd,OAAO,CAACK,MAAM,CAACS,OAAP,CAAeI,KAAhB,CAAP;QACD,CAHD;QAIAb,MAAM,CAACS,OAAP,GAAiBE,WAAjB;MACD,CAPH;MAQE,MAAM,EAAE,CAAC,MAAD,EAAS,CAAC,IAAV,CARV;MASE,IAAI,EAAEvB,IATR;MAUE,OAAO,EAAE,EAVX;MAWE,OAAO,EAAE,EAXX;MAYE,aAAa,EAAE,EAZjB;MAaE,KAAK,EAAE;QAAE0B,MAAM,EAAE;MAAV,CAbT;MAcE,WAAW,EAAE,KAdf;MAeE,MAAM,EAAEhB,WAfV;MAAA,wBAkBE,QAAC,SAAD;QACE,WAAW,EAAC,0EADd;QAEE,GAAG,EAAC,6EAFN;QAGE,MAAM,EAAC,kCAHT;QAIE,OAAO,EAAE,EAJX;QAKE,aAAa,EAAE,EALjB;QAME,OAAO,EAAE;MANX;QAAA;QAAA;QAAA;MAAA,QAlBF,eA0BE,QAAC,SAAD;QACE,GAAG,EAAC,iBADN;QAEE,MAAM,EAAC,kCAFT;QAGE,OAAO,EAAE,EAHX;QAIE,aAAa,EAAE,EAJjB;QAKE,OAAO,EAAE;MALX;QAAA;QAAA;QAAA;MAAA,QA1BF,eAiCE,QAAC,MAAD;QAAQ,IAAI,EAAElD,IAAI,CAAC,EAAD,EAAKwC,IAAL,CAAlB;QAA8B,QAAQ,EAAE,CAAC,MAAD,EAAS,CAAC,IAAV,CAAxC;QAAA,uBAEE,QAAC,KAAD;UAAA,UAAQ1C;QAAR;UAAA;UAAA;UAAA;QAAA;MAFF;QAAA;QAAA;QAAA;MAAA,QAjCF,eAqCE,QAAC,YAAD;QAAc,GAAG,EAAEqD,MAAnB;QAAA,uBACE,QAAC,WAAD;UACE,IAAI,EAAE;YACJlC,QAAQ,EAAE;cACRkD,YAAY,EAAE;gBACZC,KAAK,EAAE,SADK;gBAEZC,MAAM,EAAE;cAFI;YADN,CADN;YAOJnD,OAAO,EAAE;cACPoD,iBAAiB,EAAE,KADZ;cACmB;cAC1BC,SAAS,EAAE;gBACTH,KAAK,EAAE,SADE;gBACS;gBAClBI,OAAO,EAAE,+CAFA,CAEiD;;cAFjD,CAFJ;cAMPL,YAAY,EAAE;gBACZC,KAAK,EAAE;cADK;YANP,CAPL;YAiBJhD,MAAM,EAAE,KAjBJ;YAiBW;YACfD,SAAS,EAAE;cACTgD,YAAY,EAAE;gBACZM,SAAS,EAAE;cADC;YADL,CAlBP;YAuBJpD,MAAM,EAAE;cACNrB,IAAI,EAAEA,IAAI,CAACwD,IAAD,EAAOhB,IAAP;YADJ;UAvBJ,CADR;UA4BE,QAAQ,EAAC,UA5BX;UA6BE,KAAK,EAAEgB,IA7BT;UA8BE,SAAS,EAAGkB,CAAD,IAAO;YAChBpB,OAAO,CAACC,GAAR,CAAY;cAAEC,IAAF;cAAQkB;YAAR,CAAZ;YACArB,SAAS,CAACG,IAAD,CAAT;UACD,CAjCH;UAkCE,iBAAiB,EAAE;QAlCrB;UAAA;UAAA;UAAA;QAAA;MADF;QAAA;QAAA;QAAA;MAAA,QArCF,eA2EE,QAAC,UAAD;QAAA;QAAA;QAAA;MAAA,QA3EF,eA4EE,QAAC,YAAD;QAAc,QAAQ,EAAC;MAAvB;QAAA;QAAA;QAAA;MAAA,QA5EF,eA6EE,QAAC,WAAD;QAAa,QAAQ,EAAC;MAAtB;QAAA;QAAA;QAAA;MAAA,QA7EF;IAAA;MAAA;MAAA;MAAA;IAAA;EADF;IAAA;IAAA;IAAA;EAAA,QADF;AAmFD,CAzGD;;IAAMP,U;;MAAAA,U;AA2GN,eAAeA,UAAf"},"metadata":{},"sourceType":"module"}
\ No newline at end of file
diff --git a/node_modules/.cache/babel-loader/f2132439917fe62a65d1b8567c17a9be.json b/node_modules/.cache/babel-loader/f2132439917fe62a65d1b8567c17a9be.json
new file mode 100644
index 00000000..edb2dfbc
--- /dev/null
+++ b/node_modules/.cache/babel-loader/f2132439917fe62a65d1b8567c17a9be.json
@@ -0,0 +1 @@
+{"ast":null,"code":"export { default as EditControl } from './EditControl';","map":{"version":3,"names":["default","EditControl"],"sources":["/Users/mahdi/Documents/work/programming/barnameNegar/arbaeenWebApp/node_modules/react-leaflet-draw/dist/esm/index.js"],"sourcesContent":["export { default as EditControl } from './EditControl';"],"mappings":"AAAA,SAASA,OAAO,IAAIC,WAApB,QAAuC,eAAvC"},"metadata":{},"sourceType":"module"}
\ No newline at end of file
diff --git a/node_modules/.cache/babel-loader/f2bfb5419b3d67c4b78ae947097d7d3c.json b/node_modules/.cache/babel-loader/f2bfb5419b3d67c4b78ae947097d7d3c.json
new file mode 100644
index 00000000..3b54a22e
--- /dev/null
+++ b/node_modules/.cache/babel-loader/f2bfb5419b3d67c4b78ae947097d7d3c.json
@@ -0,0 +1 @@
+{"ast":null,"code":"import { useEffect, useRef } from 'react';\nexport function createElementObject(instance, context, container) {\n return Object.freeze({\n instance,\n context,\n container\n });\n}\nexport function createElementHook(createElement, updateElement) {\n if (updateElement == null) {\n return function useImmutableLeafletElement(props, context) {\n return useRef(createElement(props, context));\n };\n }\n\n return function useMutableLeafletElement(props, context) {\n const elementRef = useRef(createElement(props, context));\n const propsRef = useRef(props);\n const {\n instance\n } = elementRef.current;\n useEffect(function updateElementProps() {\n if (propsRef.current !== props) {\n updateElement(instance, props, propsRef.current);\n propsRef.current = props;\n }\n }, [instance, props, context]);\n return elementRef;\n };\n}","map":{"version":3,"names":["useEffect","useRef","createElementObject","instance","context","container","Object","freeze","createElementHook","createElement","updateElement","useImmutableLeafletElement","props","useMutableLeafletElement","elementRef","propsRef","current","updateElementProps"],"sources":["/Users/mahdi/Documents/work/programming/barnameNegar/arbaeenWebApp/node_modules/@react-leaflet/core/lib/element.js"],"sourcesContent":["import { useEffect, useRef } from 'react';\nexport function createElementObject(instance, context, container) {\n return Object.freeze({\n instance,\n context,\n container\n });\n}\nexport function createElementHook(createElement, updateElement) {\n if (updateElement == null) {\n return function useImmutableLeafletElement(props, context) {\n return useRef(createElement(props, context));\n };\n }\n return function useMutableLeafletElement(props, context) {\n const elementRef = useRef(createElement(props, context));\n const propsRef = useRef(props);\n const { instance } = elementRef.current;\n useEffect(function updateElementProps() {\n if (propsRef.current !== props) {\n updateElement(instance, props, propsRef.current);\n propsRef.current = props;\n }\n }, [\n instance,\n props,\n context\n ]);\n return elementRef;\n };\n}\n"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,OAAlC;AACA,OAAO,SAASC,mBAAT,CAA6BC,QAA7B,EAAuCC,OAAvC,EAAgDC,SAAhD,EAA2D;EAC9D,OAAOC,MAAM,CAACC,MAAP,CAAc;IACjBJ,QADiB;IAEjBC,OAFiB;IAGjBC;EAHiB,CAAd,CAAP;AAKH;AACD,OAAO,SAASG,iBAAT,CAA2BC,aAA3B,EAA0CC,aAA1C,EAAyD;EAC5D,IAAIA,aAAa,IAAI,IAArB,EAA2B;IACvB,OAAO,SAASC,0BAAT,CAAoCC,KAApC,EAA2CR,OAA3C,EAAoD;MACvD,OAAOH,MAAM,CAACQ,aAAa,CAACG,KAAD,EAAQR,OAAR,CAAd,CAAb;IACH,CAFD;EAGH;;EACD,OAAO,SAASS,wBAAT,CAAkCD,KAAlC,EAAyCR,OAAzC,EAAkD;IACrD,MAAMU,UAAU,GAAGb,MAAM,CAACQ,aAAa,CAACG,KAAD,EAAQR,OAAR,CAAd,CAAzB;IACA,MAAMW,QAAQ,GAAGd,MAAM,CAACW,KAAD,CAAvB;IACA,MAAM;MAAET;IAAF,IAAgBW,UAAU,CAACE,OAAjC;IACAhB,SAAS,CAAC,SAASiB,kBAAT,GAA8B;MACpC,IAAIF,QAAQ,CAACC,OAAT,KAAqBJ,KAAzB,EAAgC;QAC5BF,aAAa,CAACP,QAAD,EAAWS,KAAX,EAAkBG,QAAQ,CAACC,OAA3B,CAAb;QACAD,QAAQ,CAACC,OAAT,GAAmBJ,KAAnB;MACH;IACJ,CALQ,EAKN,CACCT,QADD,EAECS,KAFD,EAGCR,OAHD,CALM,CAAT;IAUA,OAAOU,UAAP;EACH,CAfD;AAgBH"},"metadata":{},"sourceType":"module"}
\ No newline at end of file
diff --git a/node_modules/.cache/babel-loader/fa29c242d8305a358ece90e78a17ad70.json b/node_modules/.cache/babel-loader/fa29c242d8305a358ece90e78a17ad70.json
new file mode 100644
index 00000000..2a742e7f
--- /dev/null
+++ b/node_modules/.cache/babel-loader/fa29c242d8305a358ece90e78a17ad70.json
@@ -0,0 +1 @@
+{"ast":null,"code":"export function updateGridLayer(layer, props, prevProps) {\n const {\n opacity,\n zIndex\n } = props;\n\n if (opacity != null && opacity !== prevProps.opacity) {\n layer.setOpacity(opacity);\n }\n\n if (zIndex != null && zIndex !== prevProps.zIndex) {\n layer.setZIndex(zIndex);\n }\n}","map":{"version":3,"names":["updateGridLayer","layer","props","prevProps","opacity","zIndex","setOpacity","setZIndex"],"sources":["/Users/mahdi/Documents/work/programming/barnameNegar/arbaeenWebApp/node_modules/@react-leaflet/core/lib/grid-layer.js"],"sourcesContent":["export function updateGridLayer(layer, props, prevProps) {\n const { opacity , zIndex } = props;\n if (opacity != null && opacity !== prevProps.opacity) {\n layer.setOpacity(opacity);\n }\n if (zIndex != null && zIndex !== prevProps.zIndex) {\n layer.setZIndex(zIndex);\n }\n}\n"],"mappings":"AAAA,OAAO,SAASA,eAAT,CAAyBC,KAAzB,EAAgCC,KAAhC,EAAuCC,SAAvC,EAAkD;EACrD,MAAM;IAAEC,OAAF;IAAYC;EAAZ,IAAwBH,KAA9B;;EACA,IAAIE,OAAO,IAAI,IAAX,IAAmBA,OAAO,KAAKD,SAAS,CAACC,OAA7C,EAAsD;IAClDH,KAAK,CAACK,UAAN,CAAiBF,OAAjB;EACH;;EACD,IAAIC,MAAM,IAAI,IAAV,IAAkBA,MAAM,KAAKF,SAAS,CAACE,MAA3C,EAAmD;IAC/CJ,KAAK,CAACM,SAAN,CAAgBF,MAAhB;EACH;AACJ"},"metadata":{},"sourceType":"module"}
\ No newline at end of file
diff --git a/node_modules/.cache/babel-loader/fd074045c4c008550886c8b686a07102.json b/node_modules/.cache/babel-loader/fd074045c4c008550886c8b686a07102.json
new file mode 100644
index 00000000..0867d11a
--- /dev/null
+++ b/node_modules/.cache/babel-loader/fd074045c4c008550886c8b686a07102.json
@@ -0,0 +1 @@
+{"ast":null,"code":"import { useEffect, useRef } from 'react';\nimport { useLeafletContext } from './context.js';\nexport function createControlHook(useElement) {\n return function useLeafletControl(props) {\n const context = useLeafletContext();\n const elementRef = useElement(props, context);\n const {\n instance\n } = elementRef.current;\n const positionRef = useRef(props.position);\n const {\n position\n } = props;\n useEffect(function addControl() {\n instance.addTo(context.map);\n return function removeControl() {\n instance.remove();\n };\n }, [context.map, instance]);\n useEffect(function updateControl() {\n if (position != null && position !== positionRef.current) {\n instance.setPosition(position);\n positionRef.current = position;\n }\n }, [instance, position]);\n return elementRef;\n };\n}","map":{"version":3,"names":["useEffect","useRef","useLeafletContext","createControlHook","useElement","useLeafletControl","props","context","elementRef","instance","current","positionRef","position","addControl","addTo","map","removeControl","remove","updateControl","setPosition"],"sources":["/Users/mahdi/Documents/work/programming/barnameNegar/arbaeenWebApp/node_modules/@react-leaflet/core/lib/control.js"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport { useLeafletContext } from './context.js';\nexport function createControlHook(useElement) {\n return function useLeafletControl(props) {\n const context = useLeafletContext();\n const elementRef = useElement(props, context);\n const { instance } = elementRef.current;\n const positionRef = useRef(props.position);\n const { position } = props;\n useEffect(function addControl() {\n instance.addTo(context.map);\n return function removeControl() {\n instance.remove();\n };\n }, [\n context.map,\n instance\n ]);\n useEffect(function updateControl() {\n if (position != null && position !== positionRef.current) {\n instance.setPosition(position);\n positionRef.current = position;\n }\n }, [\n instance,\n position\n ]);\n return elementRef;\n };\n}\n"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,OAAlC;AACA,SAASC,iBAAT,QAAkC,cAAlC;AACA,OAAO,SAASC,iBAAT,CAA2BC,UAA3B,EAAuC;EAC1C,OAAO,SAASC,iBAAT,CAA2BC,KAA3B,EAAkC;IACrC,MAAMC,OAAO,GAAGL,iBAAiB,EAAjC;IACA,MAAMM,UAAU,GAAGJ,UAAU,CAACE,KAAD,EAAQC,OAAR,CAA7B;IACA,MAAM;MAAEE;IAAF,IAAgBD,UAAU,CAACE,OAAjC;IACA,MAAMC,WAAW,GAAGV,MAAM,CAACK,KAAK,CAACM,QAAP,CAA1B;IACA,MAAM;MAAEA;IAAF,IAAgBN,KAAtB;IACAN,SAAS,CAAC,SAASa,UAAT,GAAsB;MAC5BJ,QAAQ,CAACK,KAAT,CAAeP,OAAO,CAACQ,GAAvB;MACA,OAAO,SAASC,aAAT,GAAyB;QAC5BP,QAAQ,CAACQ,MAAT;MACH,CAFD;IAGH,CALQ,EAKN,CACCV,OAAO,CAACQ,GADT,EAECN,QAFD,CALM,CAAT;IASAT,SAAS,CAAC,SAASkB,aAAT,GAAyB;MAC/B,IAAIN,QAAQ,IAAI,IAAZ,IAAoBA,QAAQ,KAAKD,WAAW,CAACD,OAAjD,EAA0D;QACtDD,QAAQ,CAACU,WAAT,CAAqBP,QAArB;QACAD,WAAW,CAACD,OAAZ,GAAsBE,QAAtB;MACH;IACJ,CALQ,EAKN,CACCH,QADD,EAECG,QAFD,CALM,CAAT;IASA,OAAOJ,UAAP;EACH,CAzBD;AA0BH"},"metadata":{},"sourceType":"module"}
\ No newline at end of file
diff --git a/node_modules/.cache/babel-loader/fde76a7fd88c676dfdc665fe6fbb3b0a.json b/node_modules/.cache/babel-loader/fde76a7fd88c676dfdc665fe6fbb3b0a.json
new file mode 100644
index 00000000..d9d49ac8
--- /dev/null
+++ b/node_modules/.cache/babel-loader/fde76a7fd88c676dfdc665fe6fbb3b0a.json
@@ -0,0 +1 @@
+{"ast":null,"code":"var _jsxFileName = \"/Users/mahdi/Documents/work/programming/barnameNegar/arbaeenWebApp/src/App.js\";\nimport \"./App.scss\";\nimport Homepage from \"./components/Homepage\";\nimport ContactUs from \"./components/ContactUs\";\nimport LeafletMap from \"./components/LeafletMap\"; // import { Provider } from \"react-redux\";\n// import store from \"./redux/store\";\n\nimport { jsxDEV as _jsxDEV } from \"react/jsx-dev-runtime\";\nimport { Fragment as _Fragment } from \"react/jsx-dev-runtime\";\n\nfunction App() {\n return (\n /*#__PURE__*/\n // \n // \n // \n _jsxDEV(_Fragment, {\n children: /*#__PURE__*/_jsxDEV(Homepage, {}, void 0, false, {\n fileName: _jsxFileName,\n lineNumber: 14,\n columnNumber: 7\n }, this)\n }, void 0, false)\n );\n}\n\n_c = App;\nexport default App;\n\nvar _c;\n\n$RefreshReg$(_c, \"App\");","map":{"version":3,"names":["Homepage","ContactUs","LeafletMap","App"],"sources":["/Users/mahdi/Documents/work/programming/barnameNegar/arbaeenWebApp/src/App.js"],"sourcesContent":["import \"./App.scss\";\nimport Homepage from \"./components/Homepage\";\nimport ContactUs from \"./components/ContactUs\";\nimport LeafletMap from \"./components/LeafletMap\";\n// import { Provider } from \"react-redux\";\n// import store from \"./redux/store\";\n\nfunction App() {\n return (\n // \n // \n // \n <>\n \n {/* */}\n >\n );\n}\n\nexport default App;\n"],"mappings":";AAAA,OAAO,YAAP;AACA,OAAOA,QAAP,MAAqB,uBAArB;AACA,OAAOC,SAAP,MAAsB,wBAAtB;AACA,OAAOC,UAAP,MAAuB,yBAAvB,C,CACA;AACA;;;;;AAEA,SAASC,GAAT,GAAe;EACb;IAAA;IACE;IACA;IACA;IACA;MAAA,uBACE,QAAC,QAAD;QAAA;QAAA;QAAA;MAAA;IADF;EAJF;AASD;;KAVQA,G;AAYT,eAAeA,GAAf"},"metadata":{},"sourceType":"module"}
\ No newline at end of file
diff --git a/node_modules/.cache/default-development/0.pack b/node_modules/.cache/default-development/0.pack
index 90a3e544..1f243c71 100644
Binary files a/node_modules/.cache/default-development/0.pack and b/node_modules/.cache/default-development/0.pack differ
diff --git a/node_modules/.cache/default-development/1.pack b/node_modules/.cache/default-development/1.pack
index 630a0b6b..6f0082ba 100644
Binary files a/node_modules/.cache/default-development/1.pack and b/node_modules/.cache/default-development/1.pack differ
diff --git a/node_modules/.cache/default-development/2.pack b/node_modules/.cache/default-development/2.pack
index 4685b93b..5d2e9d23 100644
Binary files a/node_modules/.cache/default-development/2.pack and b/node_modules/.cache/default-development/2.pack differ
diff --git a/node_modules/.cache/default-development/3.pack b/node_modules/.cache/default-development/3.pack
index 07136714..a287e639 100644
Binary files a/node_modules/.cache/default-development/3.pack and b/node_modules/.cache/default-development/3.pack differ
diff --git a/node_modules/.cache/default-development/4.pack b/node_modules/.cache/default-development/4.pack
index 88e800ec..d034ce8d 100644
Binary files a/node_modules/.cache/default-development/4.pack and b/node_modules/.cache/default-development/4.pack differ
diff --git a/node_modules/.cache/default-development/5.pack b/node_modules/.cache/default-development/5.pack
index c04f3a23..0ca48521 100644
Binary files a/node_modules/.cache/default-development/5.pack and b/node_modules/.cache/default-development/5.pack differ
diff --git a/node_modules/.cache/default-development/index.pack b/node_modules/.cache/default-development/index.pack
index a869f82b..74d8a543 100644
Binary files a/node_modules/.cache/default-development/index.pack and b/node_modules/.cache/default-development/index.pack differ
diff --git a/node_modules/.cache/default-development/index.pack.old b/node_modules/.cache/default-development/index.pack.old
index a0b69e5f..406e02c0 100644
Binary files a/node_modules/.cache/default-development/index.pack.old and b/node_modules/.cache/default-development/index.pack.old differ
diff --git a/node_modules/.yarn-integrity b/node_modules/.yarn-integrity
index 7e100d6d..8b5aca88 100644
--- a/node_modules/.yarn-integrity
+++ b/node_modules/.yarn-integrity
@@ -10,10 +10,14 @@
"@testing-library/react@^13.3.0",
"@testing-library/user-event@^13.5.0",
"autoprefixer@^10.4.7",
+ "leaflet-draw@^1.0.4",
+ "leaflet@^1.8.0",
"node-sass@^7.0.1",
"postcss@^8.4.14",
"react-dom@^18.2.0",
"react-hook-form@^7.33.1",
+ "react-leaflet-draw@^0.20.1",
+ "react-leaflet@^4.0.1",
"react-multi-date-picker@^3.3.0",
"react-qr-code@^2.0.7",
"react-scripts@5.0.1",
@@ -253,6 +257,7 @@
"@npmcli/fs@^1.0.0": "https://registry.yarnpkg.com/@npmcli/fs/-/fs-1.1.1.tgz#72f719fe935e687c56a4faecf3c03d06ba593257",
"@npmcli/move-file@^1.0.1": "https://registry.yarnpkg.com/@npmcli/move-file/-/move-file-1.1.2.tgz#1a82c3e372f7cae9253eb66d72543d6b8685c674",
"@pmmmwh/react-refresh-webpack-plugin@^0.5.3": "https://registry.yarnpkg.com/@pmmmwh/react-refresh-webpack-plugin/-/react-refresh-webpack-plugin-0.5.7.tgz#58f8217ba70069cc6a73f5d7e05e85b458c150e2",
+ "@react-leaflet/core@^2.0.0": "https://registry.yarnpkg.com/@react-leaflet/core/-/core-2.0.0.tgz#212f4d87dc7681f40ca0e47d99672676c20c8ef6",
"@rollup/plugin-babel@^5.2.0": "https://registry.yarnpkg.com/@rollup/plugin-babel/-/plugin-babel-5.3.1.tgz#04bc0608f4aa4b2e4b1aebf284344d0f68fda283",
"@rollup/plugin-node-resolve@^11.2.1": "https://registry.yarnpkg.com/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.1.tgz#82aa59397a29cd4e13248b106e6a4a1880362a60",
"@rollup/plugin-replace@^2.4.1": "https://registry.yarnpkg.com/@rollup/plugin-replace/-/plugin-replace-2.4.2.tgz#a2d539314fbc77c244858faa523012825068510a",
@@ -1024,6 +1029,8 @@
"klona@^2.0.5": "https://registry.yarnpkg.com/klona/-/klona-2.0.5.tgz#d166574d90076395d9963aa7a928fabb8d76afbc",
"language-subtag-registry@~0.3.2": "https://registry.yarnpkg.com/language-subtag-registry/-/language-subtag-registry-0.3.21.tgz#04ac218bea46f04cb039084602c6da9e788dd45a",
"language-tags@^1.0.5": "https://registry.yarnpkg.com/language-tags/-/language-tags-1.0.5.tgz#d321dbc4da30ba8bf3024e040fa5c14661f9193a",
+ "leaflet-draw@^1.0.4": "https://registry.yarnpkg.com/leaflet-draw/-/leaflet-draw-1.0.4.tgz#45be92f378ed253e7202fdeda1fcc71885198d46",
+ "leaflet@^1.8.0": "https://registry.yarnpkg.com/leaflet/-/leaflet-1.8.0.tgz#4615db4a22a304e8e692cae9270b983b38a2055e",
"leven@^3.1.0": "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2",
"levn@^0.4.1": "https://registry.yarnpkg.com/levn/-/levn-0.4.1.tgz#ae4562c007473b932a6200d403268dd2fffc6ade",
"levn@~0.3.0": "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee",
@@ -1037,6 +1044,7 @@
"locate-path@^3.0.0": "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e",
"locate-path@^5.0.0": "https://registry.yarnpkg.com/locate-path/-/locate-path-5.0.0.tgz#1afba396afd676a6d42504d0a67a3a7eb9f62aa0",
"locate-path@^6.0.0": "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286",
+ "lodash-es@^4.17.15": "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.21.tgz#43e626c46e6591b7750beb2b50117390c609e3ee",
"lodash.debounce@^4.0.8": "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af",
"lodash.memoize@^4.1.2": "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe",
"lodash.merge@^4.6.2": "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a",
@@ -1335,6 +1343,8 @@
"react-is@^16.13.1": "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4",
"react-is@^17.0.1": "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0",
"react-is@^18.0.0": "https://registry.yarnpkg.com/react-is/-/react-is-18.2.0.tgz#199431eeaaa2e09f86427efbb4f1473edb47609b",
+ "react-leaflet-draw@^0.20.1": "https://registry.yarnpkg.com/react-leaflet-draw/-/react-leaflet-draw-0.20.1.tgz#f0d119c2b2d413f04e79eb278befcab233935889",
+ "react-leaflet@^4.0.1": "https://registry.yarnpkg.com/react-leaflet/-/react-leaflet-4.0.1.tgz#84f085241c741b43184808c2038642e88de7655e",
"react-multi-date-picker@^3.3.0": "https://registry.yarnpkg.com/react-multi-date-picker/-/react-multi-date-picker-3.3.0.tgz#89036a1bf013fc65bc12dda640d5a979a640b453",
"react-qr-code@^2.0.7": "https://registry.yarnpkg.com/react-qr-code/-/react-qr-code-2.0.7.tgz#508304e031e82426a044f5e9490aca87d7c3de38",
"react-refresh@^0.11.0": "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.11.0.tgz#77198b944733f0f1f1a90e791de4541f9f074046",
diff --git a/node_modules/@react-leaflet/core/LICENSE.md b/node_modules/@react-leaflet/core/LICENSE.md
new file mode 100644
index 00000000..e5faf967
--- /dev/null
+++ b/node_modules/@react-leaflet/core/LICENSE.md
@@ -0,0 +1,33 @@
+@react-leaflet/core Copyright 2020 Paul Le Cam and contributors (“Licensor”)
+
+Hippocratic License Version Number: 2.1.
+
+Purpose. The purpose of this License is for the Licensor named above to permit the Licensee (as defined below) broad permission, if consistent with Human Rights Laws and Human Rights Principles (as each is defined below), to use and work with the Software (as defined below) within the full scope of Licensor’s copyright and patent rights, if any, in the Software, while ensuring attribution and protecting the Licensor from liability.
+
+Permission and Conditions. The Licensor grants permission by this license (“License”), free of charge, to the extent of Licensor’s rights under applicable copyright and patent law, to any person or entity (the “Licensee”) obtaining a copy of this software and associated documentation files (the “Software”), to do everything with the Software that would otherwise infringe (i) the Licensor’s copyright in the Software or (ii) any patent claims to the Software that the Licensor can license or becomes able to license, subject to all of the following terms and conditions:
+
+- Acceptance. This License is automatically offered to every person and entity subject to its terms and conditions. Licensee accepts this License and agrees to its terms and conditions by taking any action with the Software that, absent this License, would infringe any intellectual property right held by Licensor.
+
+- Notice. Licensee must ensure that everyone who gets a copy of any part of this Software from Licensee, with or without changes, also receives the License and the above copyright notice (and if included by the Licensor, patent, trademark and attribution notice). Licensee must cause any modified versions of the Software to carry prominent notices stating that Licensee changed the Software. For clarity, although Licensee is free to create modifications of the Software and distribute only the modified portion created by Licensee with additional or different terms, the portion of the Software not modified must be distributed pursuant to this License. If anyone notifies Licensee in writing that Licensee has not complied with this Notice section, Licensee can keep this License by taking all practical steps to comply within 30 days after the notice. If Licensee does not do so, Licensee’s License (and all rights licensed hereunder) shall end immediately.
+
+- Compliance with Human Rights Principles and Human Rights Laws.
+
+ 1. Human Rights Principles.
+
+ (a) Licensee is advised to consult the articles of the United Nations Universal Declaration of Human Rights and the United Nations Global Compact that define recognized principles of international human rights (the “Human Rights Principles”). Licensee shall use the Software in a manner consistent with Human Rights Principles.
+
+ (b) Unless the Licensor and Licensee agree otherwise, any dispute, controversy, or claim arising out of or relating to (i) Section 1(a) regarding Human Rights Principles, including the breach of Section 1(a), termination of this License for breach of the Human Rights Principles, or invalidity of Section 1(a) or (ii) a determination of whether any Law is consistent or in conflict with Human Rights Principles pursuant to Section 2, below, shall be settled by arbitration in accordance with the Hague Rules on Business and Human Rights Arbitration (the “Rules”); provided, however, that Licensee may elect not to participate in such arbitration, in which event this License (and all rights licensed hereunder) shall end immediately. The number of arbitrators shall be one unless the Rules require otherwise.
+
+ Unless both the Licensor and Licensee agree to the contrary: (1) All documents and information concerning the arbitration shall be public and may be disclosed by any party; (2) The repository referred to under Article 43 of the Rules shall make available to the public in a timely manner all documents concerning the arbitration which are communicated to it, including all submissions of the parties, all evidence admitted into the record of the proceedings, all transcripts or other recordings of hearings and all orders, decisions and awards of the arbitral tribunal, subject only to the arbitral tribunal's powers to take such measures as may be necessary to safeguard the integrity of the arbitral process pursuant to Articles 18, 33, 41 and 42 of the Rules; and (3) Article 26(6) of the Rules shall not apply.
+
+ 2. Human Rights Laws. The Software shall not be used by any person or entity for any systems, activities, or other uses that violate any Human Rights Laws. “Human Rights Laws” means any applicable laws, regulations, or rules (collectively, “Laws”) that protect human, civil, labor, privacy, political, environmental, security, economic, due process, or similar rights; provided, however, that such Laws are consistent and not in conflict with Human Rights Principles (a dispute over the consistency or a conflict between Laws and Human Rights Principles shall be determined by arbitration as stated above). Where the Human Rights Laws of more than one jurisdiction are applicable or in conflict with respect to the use of the Software, the Human Rights Laws that are most protective of the individuals or groups harmed shall apply.
+
+ 3. Indemnity. Licensee shall hold harmless and indemnify Licensor (and any other contributor) against all losses, damages, liabilities, deficiencies, claims, actions, judgments, settlements, interest, awards, penalties, fines, costs, or expenses of whatever kind, including Licensor’s reasonable attorneys’ fees, arising out of or relating to Licensee’s use of the Software in violation of Human Rights Laws or Human Rights Principles.
+
+- Failure to Comply. Any failure of Licensee to act according to the terms and conditions of this License is both a breach of the License and an infringement of the intellectual property rights of the Licensor (subject to exceptions under Laws, e.g., fair use). In the event of a breach or infringement, the terms and conditions of this License may be enforced by Licensor under the Laws of any jurisdiction to which Licensee is subject. Licensee also agrees that the Licensor may enforce the terms and conditions of this License against Licensee through specific performance (or similar remedy under Laws) to the extent permitted by Laws. For clarity, except in the event of a breach of this License, infringement, or as otherwise stated in this License, Licensor may not terminate this License with Licensee.
+
+- Enforceability and Interpretation. If any term or provision of this License is determined to be invalid, illegal, or unenforceable by a court of competent jurisdiction, then such invalidity, illegality, or unenforceability shall not affect any other term or provision of this License or invalidate or render unenforceable such term or provision in any other jurisdiction; provided, however, subject to a court modification pursuant to the immediately following sentence, if any term or provision of this License pertaining to Human Rights Laws or Human Rights Principles is deemed invalid, illegal, or unenforceable against Licensee by a court of competent jurisdiction, all rights in the Software granted to Licensee shall be deemed null and void as between Licensor and Licensee. Upon a determination that any term or provision is invalid, illegal, or unenforceable, to the extent permitted by Laws, the court may modify this License to affect the original purpose that the Software be used in compliance with Human Rights Principles and Human Rights Laws as closely as possible. The language in this License shall be interpreted as to its fair meaning and not strictly for or against any party.
+
+- Disclaimer. TO THE FULL EXTENT ALLOWED BY LAW, THIS SOFTWARE COMES “AS IS,” WITHOUT ANY WARRANTY, EXPRESS OR IMPLIED, AND LICENSOR AND ANY OTHER CONTRIBUTOR SHALL NOT BE LIABLE TO ANYONE FOR ANY DAMAGES OR OTHER LIABILITY ARISING FROM, OUT OF, OR IN CONNECTION WITH THE SOFTWARE OR THIS LICENSE, UNDER ANY KIND OF LEGAL CLAIM.
+
+This Hippocratic License is an Ethical Source license (https://ethicalsource.dev) and is offered for use by licensors and licensees at their own risk, on an “AS IS” basis, and with no warranties express or implied, to the maximum extent permitted by Laws.
diff --git a/node_modules/@react-leaflet/core/README.md b/node_modules/@react-leaflet/core/README.md
new file mode 100644
index 00000000..2c689b30
--- /dev/null
+++ b/node_modules/@react-leaflet/core/README.md
@@ -0,0 +1,3 @@
+# React Leaflet core
+
+[Documentation](https://react-leaflet.js.org/docs/core-introduction)
diff --git a/node_modules/@react-leaflet/core/lib/attribution.d.ts b/node_modules/@react-leaflet/core/lib/attribution.d.ts
new file mode 100644
index 00000000..8907251f
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/attribution.d.ts
@@ -0,0 +1,2 @@
+import type { Map } from 'leaflet';
+export declare function useAttribution(map: Map, attribution: string | null | undefined): void;
diff --git a/node_modules/@react-leaflet/core/lib/attribution.js b/node_modules/@react-leaflet/core/lib/attribution.js
new file mode 100644
index 00000000..bce46abd
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/attribution.js
@@ -0,0 +1,18 @@
+import { useEffect, useRef } from 'react';
+export function useAttribution(map, attribution) {
+ const attributionRef = useRef(attribution);
+ useEffect(function updateAttribution() {
+ if (attribution !== attributionRef.current && map.attributionControl != null) {
+ if (attributionRef.current != null) {
+ map.attributionControl.removeAttribution(attributionRef.current);
+ }
+ if (attribution != null) {
+ map.attributionControl.addAttribution(attribution);
+ }
+ }
+ attributionRef.current = attribution;
+ }, [
+ map,
+ attribution
+ ]);
+}
diff --git a/node_modules/@react-leaflet/core/lib/circle.d.ts b/node_modules/@react-leaflet/core/lib/circle.d.ts
new file mode 100644
index 00000000..81eac064
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/circle.d.ts
@@ -0,0 +1,8 @@
+import type { CircleMarker as LeafletCircleMarker, CircleMarkerOptions, LatLngExpression } from 'leaflet';
+import type { ReactNode } from 'react';
+import type { PathProps } from './path.js';
+export interface CircleMarkerProps extends CircleMarkerOptions, PathProps {
+ center: LatLngExpression;
+ children?: ReactNode;
+}
+export declare function updateCircle(layer: LeafletCircleMarker, props: P, prevProps: P): void;
diff --git a/node_modules/@react-leaflet/core/lib/circle.js b/node_modules/@react-leaflet/core/lib/circle.js
new file mode 100644
index 00000000..f5e20aeb
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/circle.js
@@ -0,0 +1,8 @@
+export function updateCircle(layer, props, prevProps) {
+ if (props.center !== prevProps.center) {
+ layer.setLatLng(props.center);
+ }
+ if (props.radius != null && props.radius !== prevProps.radius) {
+ layer.setRadius(props.radius);
+ }
+}
diff --git a/node_modules/@react-leaflet/core/lib/component.d.ts b/node_modules/@react-leaflet/core/lib/component.d.ts
new file mode 100644
index 00000000..c67a8708
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/component.d.ts
@@ -0,0 +1,11 @@
+import React, { type MutableRefObject, type ReactNode } from 'react';
+import type { DivOverlay, DivOverlayHook } from './div-overlay.js';
+import type { LeafletElement } from './element.js';
+declare type ElementHook = (props: P) => MutableRefObject>;
+export declare type PropsWithChildren = {
+ children?: ReactNode;
+};
+export declare function createContainerComponent(useElement: ElementHook): React.ForwardRefExoticComponent & React.RefAttributes>;
+export declare function createDivOverlayComponent(useElement: ReturnType>): React.ForwardRefExoticComponent & React.RefAttributes>;
+export declare function createLeafComponent(useElement: ElementHook): React.ForwardRefExoticComponent & React.RefAttributes>;
+export {};
diff --git a/node_modules/@react-leaflet/core/lib/component.js b/node_modules/@react-leaflet/core/lib/component.js
new file mode 100644
index 00000000..9463d0de
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/component.js
@@ -0,0 +1,44 @@
+import React, { forwardRef, useEffect, useImperativeHandle, useState } from 'react';
+import { createPortal } from 'react-dom';
+import { LeafletProvider } from './context.js';
+export function createContainerComponent(useElement) {
+ function ContainerComponent(props, forwardedRef) {
+ const { instance , context } = useElement(props).current;
+ useImperativeHandle(forwardedRef, ()=>instance
+ );
+ return props.children == null ? null : /*#__PURE__*/ React.createElement(LeafletProvider, {
+ value: context
+ }, props.children);
+ }
+ return /*#__PURE__*/ forwardRef(ContainerComponent);
+}
+export function createDivOverlayComponent(useElement) {
+ function OverlayComponent(props, forwardedRef) {
+ const [isOpen, setOpen] = useState(false);
+ const { instance } = useElement(props, setOpen).current;
+ useImperativeHandle(forwardedRef, ()=>instance
+ );
+ useEffect(function updateOverlay() {
+ if (isOpen) {
+ instance.update();
+ }
+ }, [
+ instance,
+ isOpen,
+ props.children
+ ]);
+ // @ts-ignore _contentNode missing in type definition
+ const contentNode = instance._contentNode;
+ return contentNode ? /*#__PURE__*/ createPortal(props.children, contentNode) : null;
+ }
+ return /*#__PURE__*/ forwardRef(OverlayComponent);
+}
+export function createLeafComponent(useElement) {
+ function LeafComponent(props, forwardedRef) {
+ const { instance } = useElement(props).current;
+ useImperativeHandle(forwardedRef, ()=>instance
+ );
+ return null;
+ }
+ return /*#__PURE__*/ forwardRef(LeafComponent);
+}
diff --git a/node_modules/@react-leaflet/core/lib/context.d.ts b/node_modules/@react-leaflet/core/lib/context.d.ts
new file mode 100644
index 00000000..fb7c50df
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/context.d.ts
@@ -0,0 +1,33 @@
+import type { Control, Layer, LayerGroup, Map } from 'leaflet';
+export declare const CONTEXT_VERSION = 1;
+export declare type ControlledLayer = {
+ addLayer(layer: Layer): void;
+ removeLayer(layer: Layer): void;
+};
+export declare type LeafletContextInterface = Readonly<{
+ __version: number;
+ map: Map;
+ layerContainer?: ControlledLayer | LayerGroup;
+ layersControl?: Control.Layers;
+ overlayContainer?: Layer;
+ pane?: string;
+}>;
+export declare function createLeafletContext(map: Map): LeafletContextInterface;
+export declare function extendContext(source: LeafletContextInterface, extra: Partial): LeafletContextInterface;
+export declare const LeafletContext: import("react").Context | ControlledLayer | undefined;
+ layersControl?: Control.Layers | undefined;
+ overlayContainer?: Layer | undefined;
+ pane?: string | undefined;
+}> | null>;
+export declare const LeafletProvider: import("react").Provider | ControlledLayer | undefined;
+ layersControl?: Control.Layers | undefined;
+ overlayContainer?: Layer | undefined;
+ pane?: string | undefined;
+}> | null>;
+export declare function useLeafletContext(): LeafletContextInterface;
diff --git a/node_modules/@react-leaflet/core/lib/context.js b/node_modules/@react-leaflet/core/lib/context.js
new file mode 100644
index 00000000..cf4d48e7
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/context.js
@@ -0,0 +1,23 @@
+import { createContext, useContext } from 'react';
+export const CONTEXT_VERSION = 1;
+export function createLeafletContext(map) {
+ return Object.freeze({
+ __version: CONTEXT_VERSION,
+ map
+ });
+}
+export function extendContext(source, extra) {
+ return Object.freeze({
+ ...source,
+ ...extra
+ });
+}
+export const LeafletContext = createContext(null);
+export const LeafletProvider = LeafletContext.Provider;
+export function useLeafletContext() {
+ const context = useContext(LeafletContext);
+ if (context == null) {
+ throw new Error('No context provided: useLeafletContext() can only be used in a descendant of ');
+ }
+ return context;
+}
diff --git a/node_modules/@react-leaflet/core/lib/control.d.ts b/node_modules/@react-leaflet/core/lib/control.d.ts
new file mode 100644
index 00000000..8a3cd3c7
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/control.d.ts
@@ -0,0 +1,3 @@
+import { Control, type ControlOptions } from 'leaflet';
+import type { ElementHook } from './element.js';
+export declare function createControlHook(useElement: ElementHook): (props: P) => ReturnType>;
diff --git a/node_modules/@react-leaflet/core/lib/control.js b/node_modules/@react-leaflet/core/lib/control.js
new file mode 100644
index 00000000..4452b59b
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/control.js
@@ -0,0 +1,30 @@
+import { useEffect, useRef } from 'react';
+import { useLeafletContext } from './context.js';
+export function createControlHook(useElement) {
+ return function useLeafletControl(props) {
+ const context = useLeafletContext();
+ const elementRef = useElement(props, context);
+ const { instance } = elementRef.current;
+ const positionRef = useRef(props.position);
+ const { position } = props;
+ useEffect(function addControl() {
+ instance.addTo(context.map);
+ return function removeControl() {
+ instance.remove();
+ };
+ }, [
+ context.map,
+ instance
+ ]);
+ useEffect(function updateControl() {
+ if (position != null && position !== positionRef.current) {
+ instance.setPosition(position);
+ positionRef.current = position;
+ }
+ }, [
+ instance,
+ position
+ ]);
+ return elementRef;
+ };
+}
diff --git a/node_modules/@react-leaflet/core/lib/div-overlay.d.ts b/node_modules/@react-leaflet/core/lib/div-overlay.d.ts
new file mode 100644
index 00000000..acae67c4
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/div-overlay.d.ts
@@ -0,0 +1,9 @@
+import type { Popup, Tooltip } from 'leaflet';
+import { type LeafletContextInterface } from './context.js';
+import type { LeafletElement, ElementHook } from './element.js';
+import type { LayerProps } from './layer.js';
+export declare type DivOverlay = Popup | Tooltip;
+export declare type SetOpenFunc = (open: boolean) => void;
+export declare type DivOverlayLifecycleHook = (element: LeafletElement, context: LeafletContextInterface, props: P, setOpen: SetOpenFunc) => void;
+export declare type DivOverlayHook = (useElement: ElementHook, useLifecycle: DivOverlayLifecycleHook) => (props: P, setOpen: SetOpenFunc) => ReturnType>;
+export declare function createDivOverlayHook(useElement: ElementHook, useLifecycle: DivOverlayLifecycleHook): (props: P, setOpen: SetOpenFunc) => ReturnType>;
diff --git a/node_modules/@react-leaflet/core/lib/div-overlay.js b/node_modules/@react-leaflet/core/lib/div-overlay.js
new file mode 100644
index 00000000..96595113
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/div-overlay.js
@@ -0,0 +1,14 @@
+import { useAttribution } from './attribution.js';
+import { useLeafletContext } from './context.js';
+import { useEventHandlers } from './events.js';
+import { withPane } from './pane.js';
+export function createDivOverlayHook(useElement, useLifecycle) {
+ return function useDivOverlay(props, setOpen) {
+ const context = useLeafletContext();
+ const elementRef = useElement(withPane(props, context), context);
+ useAttribution(context.map, props.attribution);
+ useEventHandlers(elementRef.current, props.eventHandlers);
+ useLifecycle(elementRef.current, context, props, setOpen);
+ return elementRef;
+ };
+}
diff --git a/node_modules/@react-leaflet/core/lib/dom.d.ts b/node_modules/@react-leaflet/core/lib/dom.d.ts
new file mode 100644
index 00000000..25a720f9
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/dom.d.ts
@@ -0,0 +1,3 @@
+export declare function addClassName(element: HTMLElement, className: string): void;
+export declare function removeClassName(element: HTMLElement, className: string): void;
+export declare function updateClassName(element?: HTMLElement, prevClassName?: string, nextClassName?: string): void;
diff --git a/node_modules/@react-leaflet/core/lib/dom.js b/node_modules/@react-leaflet/core/lib/dom.js
new file mode 100644
index 00000000..e41c0e84
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/dom.js
@@ -0,0 +1,24 @@
+import { DomUtil } from 'leaflet';
+function splitClassName(className) {
+ return className.split(' ').filter(Boolean);
+}
+export function addClassName(element, className) {
+ splitClassName(className).forEach((cls)=>{
+ DomUtil.addClass(element, cls);
+ });
+}
+export function removeClassName(element, className) {
+ splitClassName(className).forEach((cls)=>{
+ DomUtil.removeClass(element, cls);
+ });
+}
+export function updateClassName(element, prevClassName, nextClassName) {
+ if (element != null && nextClassName !== prevClassName) {
+ if (prevClassName != null && prevClassName.length > 0) {
+ removeClassName(element, prevClassName);
+ }
+ if (nextClassName != null && nextClassName.length > 0) {
+ addClassName(element, nextClassName);
+ }
+ }
+}
diff --git a/node_modules/@react-leaflet/core/lib/element.d.ts b/node_modules/@react-leaflet/core/lib/element.d.ts
new file mode 100644
index 00000000..88ffea7a
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/element.d.ts
@@ -0,0 +1,10 @@
+import { type MutableRefObject } from 'react';
+import type { LeafletContextInterface } from './context.js';
+export declare type LeafletElement = Readonly<{
+ instance: T;
+ context: LeafletContextInterface;
+ container?: C | null;
+}>;
+export declare function createElementObject(instance: T, context: LeafletContextInterface, container?: C | null): LeafletElement;
+export declare type ElementHook = (props: P, context: LeafletContextInterface) => MutableRefObject>;
+export declare function createElementHook(createElement: (props: P, context: LeafletContextInterface) => LeafletElement, updateElement?: (instance: E, props: P, prevProps: P) => void): (props: P, context: LeafletContextInterface) => ReturnType>;
diff --git a/node_modules/@react-leaflet/core/lib/element.js b/node_modules/@react-leaflet/core/lib/element.js
new file mode 100644
index 00000000..976f5f7f
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/element.js
@@ -0,0 +1,31 @@
+import { useEffect, useRef } from 'react';
+export function createElementObject(instance, context, container) {
+ return Object.freeze({
+ instance,
+ context,
+ container
+ });
+}
+export function createElementHook(createElement, updateElement) {
+ if (updateElement == null) {
+ return function useImmutableLeafletElement(props, context) {
+ return useRef(createElement(props, context));
+ };
+ }
+ return function useMutableLeafletElement(props, context) {
+ const elementRef = useRef(createElement(props, context));
+ const propsRef = useRef(props);
+ const { instance } = elementRef.current;
+ useEffect(function updateElementProps() {
+ if (propsRef.current !== props) {
+ updateElement(instance, props, propsRef.current);
+ propsRef.current = props;
+ }
+ }, [
+ instance,
+ props,
+ context
+ ]);
+ return elementRef;
+ };
+}
diff --git a/node_modules/@react-leaflet/core/lib/events.d.ts b/node_modules/@react-leaflet/core/lib/events.d.ts
new file mode 100644
index 00000000..cc9421d6
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/events.d.ts
@@ -0,0 +1,6 @@
+import type { Evented, LeafletEventHandlerFnMap } from 'leaflet';
+import type { LeafletElement } from './element.js';
+export declare type EventedProps = {
+ eventHandlers?: LeafletEventHandlerFnMap;
+};
+export declare function useEventHandlers(element: LeafletElement, eventHandlers: LeafletEventHandlerFnMap | null | undefined): void;
diff --git a/node_modules/@react-leaflet/core/lib/events.js b/node_modules/@react-leaflet/core/lib/events.js
new file mode 100644
index 00000000..79a61ccc
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/events.js
@@ -0,0 +1,19 @@
+import { useEffect, useRef } from 'react';
+export function useEventHandlers(element, eventHandlers) {
+ const eventHandlersRef = useRef();
+ useEffect(function addEventHandlers() {
+ if (eventHandlers != null) {
+ element.instance.on(eventHandlers);
+ }
+ eventHandlersRef.current = eventHandlers;
+ return function removeEventHandlers() {
+ if (eventHandlersRef.current != null) {
+ element.instance.off(eventHandlersRef.current);
+ }
+ eventHandlersRef.current = null;
+ };
+ }, [
+ element,
+ eventHandlers
+ ]);
+}
diff --git a/node_modules/@react-leaflet/core/lib/generic.d.ts b/node_modules/@react-leaflet/core/lib/generic.d.ts
new file mode 100644
index 00000000..d20e8ecf
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/generic.d.ts
@@ -0,0 +1,17 @@
+import type { Control, ControlOptions, FeatureGroup, Layer, Path } from 'leaflet';
+import { type PropsWithChildren } from './component.js';
+import type { LeafletContextInterface } from './context.js';
+import { type LeafletElement } from './element.js';
+import { type LayerProps } from './layer.js';
+import { type DivOverlay, type DivOverlayLifecycleHook } from './div-overlay.js';
+import { type PathProps } from './path.js';
+interface LayerWithChildrenProps extends LayerProps, PropsWithChildren {
+}
+interface PathWithChildrenProps extends PathProps, PropsWithChildren {
+}
+export declare function createControlComponent(createInstance: (props: P) => E): import("react").ForwardRefExoticComponent & import("react").RefAttributes>;
+export declare function createLayerComponent(createElement: (props: P, context: LeafletContextInterface) => LeafletElement, updateElement?: (instance: E, props: P, prevProps: P) => void): import("react").ForwardRefExoticComponent & import("react").RefAttributes>;
+export declare function createOverlayComponent(createElement: (props: P, context: LeafletContextInterface) => LeafletElement, useLifecycle: DivOverlayLifecycleHook): import("react").ForwardRefExoticComponent & import("react").RefAttributes>;
+export declare function createPathComponent(createElement: (props: P, context: LeafletContextInterface) => LeafletElement, updateElement?: (instance: E, props: P, prevProps: P) => void): import("react").ForwardRefExoticComponent & import("react").RefAttributes>;
+export declare function createTileLayerComponent(createElement: (props: P, context: LeafletContextInterface) => LeafletElement, updateElement?: (instance: E, props: P, prevProps: P) => void): import("react").ForwardRefExoticComponent & import("react").RefAttributes>;
+export {};
diff --git a/node_modules/@react-leaflet/core/lib/generic.js b/node_modules/@react-leaflet/core/lib/generic.js
new file mode 100644
index 00000000..e8930665
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/generic.js
@@ -0,0 +1,34 @@
+import { createContainerComponent, createDivOverlayComponent, createLeafComponent } from './component.js';
+import { createControlHook } from './control.js';
+import { createElementHook, createElementObject } from './element.js';
+import { createLayerHook } from './layer.js';
+import { createDivOverlayHook } from './div-overlay.js';
+import { createPathHook } from './path.js';
+export function createControlComponent(createInstance) {
+ function createElement(props, context) {
+ return createElementObject(createInstance(props), context);
+ }
+ const useElement = createElementHook(createElement);
+ const useControl = createControlHook(useElement);
+ return createLeafComponent(useControl);
+}
+export function createLayerComponent(createElement, updateElement) {
+ const useElement = createElementHook(createElement, updateElement);
+ const useLayer = createLayerHook(useElement);
+ return createContainerComponent(useLayer);
+}
+export function createOverlayComponent(createElement, useLifecycle) {
+ const useElement = createElementHook(createElement);
+ const useOverlay = createDivOverlayHook(useElement, useLifecycle);
+ return createDivOverlayComponent(useOverlay);
+}
+export function createPathComponent(createElement, updateElement) {
+ const useElement = createElementHook(createElement, updateElement);
+ const usePath = createPathHook(useElement);
+ return createContainerComponent(usePath);
+}
+export function createTileLayerComponent(createElement, updateElement) {
+ const useElement = createElementHook(createElement, updateElement);
+ const useLayer = createLayerHook(useElement);
+ return createLeafComponent(useLayer);
+}
diff --git a/node_modules/@react-leaflet/core/lib/grid-layer.d.ts b/node_modules/@react-leaflet/core/lib/grid-layer.d.ts
new file mode 100644
index 00000000..b676e902
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/grid-layer.d.ts
@@ -0,0 +1,2 @@
+import type { GridLayer, GridLayerOptions } from 'leaflet';
+export declare function updateGridLayer(layer: E, props: P, prevProps: P): void;
diff --git a/node_modules/@react-leaflet/core/lib/grid-layer.js b/node_modules/@react-leaflet/core/lib/grid-layer.js
new file mode 100644
index 00000000..81526cd7
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/grid-layer.js
@@ -0,0 +1,9 @@
+export function updateGridLayer(layer, props, prevProps) {
+ const { opacity , zIndex } = props;
+ if (opacity != null && opacity !== prevProps.opacity) {
+ layer.setOpacity(opacity);
+ }
+ if (zIndex != null && zIndex !== prevProps.zIndex) {
+ layer.setZIndex(zIndex);
+ }
+}
diff --git a/node_modules/@react-leaflet/core/lib/index.d.ts b/node_modules/@react-leaflet/core/lib/index.d.ts
new file mode 100644
index 00000000..e34faac0
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/index.d.ts
@@ -0,0 +1,15 @@
+export { useAttribution } from './attribution.js';
+export { type CircleMarkerProps, updateCircle } from './circle.js';
+export { createContainerComponent, createDivOverlayComponent, createLeafComponent, } from './component.js';
+export { CONTEXT_VERSION, type LeafletContextInterface, LeafletContext, LeafletProvider, createLeafletContext, extendContext, useLeafletContext, } from './context.js';
+export { createControlHook } from './control.js';
+export { type DivOverlayHook, type DivOverlayLifecycleHook, type SetOpenFunc, createDivOverlayHook, } from './div-overlay.js';
+export { addClassName, removeClassName, updateClassName } from './dom.js';
+export { type ElementHook, type LeafletElement, createElementHook, createElementObject, } from './element.js';
+export { type EventedProps, useEventHandlers } from './events.js';
+export { createControlComponent, createLayerComponent, createOverlayComponent, createPathComponent, createTileLayerComponent, } from './generic.js';
+export { updateGridLayer } from './grid-layer.js';
+export { type InteractiveLayerProps, type LayerProps, createLayerHook, useLayerLifecycle, } from './layer.js';
+export { type MediaOverlayProps, updateMediaOverlay } from './media-overlay.js';
+export { withPane } from './pane.js';
+export { type PathProps, createPathHook, usePathOptions } from './path.js';
diff --git a/node_modules/@react-leaflet/core/lib/index.js b/node_modules/@react-leaflet/core/lib/index.js
new file mode 100644
index 00000000..69dff411
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/index.js
@@ -0,0 +1,15 @@
+export { useAttribution } from './attribution.js';
+export { updateCircle } from './circle.js';
+export { createContainerComponent, createDivOverlayComponent, createLeafComponent } from './component.js';
+export { CONTEXT_VERSION, LeafletContext, LeafletProvider, createLeafletContext, extendContext, useLeafletContext } from './context.js';
+export { createControlHook } from './control.js';
+export { createDivOverlayHook } from './div-overlay.js';
+export { addClassName, removeClassName, updateClassName } from './dom.js';
+export { createElementHook, createElementObject } from './element.js';
+export { useEventHandlers } from './events.js';
+export { createControlComponent, createLayerComponent, createOverlayComponent, createPathComponent, createTileLayerComponent } from './generic.js';
+export { updateGridLayer } from './grid-layer.js';
+export { createLayerHook, useLayerLifecycle } from './layer.js';
+export { updateMediaOverlay } from './media-overlay.js';
+export { withPane } from './pane.js';
+export { createPathHook, usePathOptions } from './path.js';
diff --git a/node_modules/@react-leaflet/core/lib/layer.d.ts b/node_modules/@react-leaflet/core/lib/layer.d.ts
new file mode 100644
index 00000000..148bc6a3
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/layer.d.ts
@@ -0,0 +1,10 @@
+import type { InteractiveLayerOptions, Layer, LayerOptions } from 'leaflet';
+import { type LeafletContextInterface } from './context.js';
+import type { LeafletElement, ElementHook } from './element.js';
+import { type EventedProps } from './events.js';
+export interface LayerProps extends EventedProps, LayerOptions {
+}
+export interface InteractiveLayerProps extends LayerProps, InteractiveLayerOptions {
+}
+export declare function useLayerLifecycle(element: LeafletElement, context: LeafletContextInterface): void;
+export declare function createLayerHook(useElement: ElementHook): (props: P) => ReturnType>;
diff --git a/node_modules/@react-leaflet/core/lib/layer.js b/node_modules/@react-leaflet/core/lib/layer.js
new file mode 100644
index 00000000..6364b3ad
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/layer.js
@@ -0,0 +1,28 @@
+import { useEffect } from 'react';
+import { useAttribution } from './attribution.js';
+import { useLeafletContext } from './context.js';
+import { useEventHandlers } from './events.js';
+import { withPane } from './pane.js';
+export function useLayerLifecycle(element, context) {
+ useEffect(function addLayer() {
+ const container = context.layerContainer ?? context.map;
+ container.addLayer(element.instance);
+ return function removeLayer() {
+ context.layerContainer?.removeLayer(element.instance);
+ context.map.removeLayer(element.instance);
+ };
+ }, [
+ context,
+ element
+ ]);
+}
+export function createLayerHook(useElement) {
+ return function useLayer(props) {
+ const context = useLeafletContext();
+ const elementRef = useElement(withPane(props, context), context);
+ useAttribution(context.map, props.attribution);
+ useEventHandlers(elementRef.current, props.eventHandlers);
+ useLayerLifecycle(elementRef.current, context);
+ return elementRef;
+ };
+}
diff --git a/node_modules/@react-leaflet/core/lib/media-overlay.d.ts b/node_modules/@react-leaflet/core/lib/media-overlay.d.ts
new file mode 100644
index 00000000..636962f2
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/media-overlay.d.ts
@@ -0,0 +1,6 @@
+import { type LatLngBoundsExpression, type ImageOverlay as LeafletImageOverlay, type ImageOverlayOptions, type SVGOverlay as LeafletSVGOverlay, type VideoOverlay as LeafletVideoOverlay } from 'leaflet';
+import type { InteractiveLayerProps } from './layer.js';
+export interface MediaOverlayProps extends ImageOverlayOptions, InteractiveLayerProps {
+ bounds: LatLngBoundsExpression;
+}
+export declare function updateMediaOverlay(overlay: E, props: P, prevProps: P): void;
diff --git a/node_modules/@react-leaflet/core/lib/media-overlay.js b/node_modules/@react-leaflet/core/lib/media-overlay.js
new file mode 100644
index 00000000..fc03a12e
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/media-overlay.js
@@ -0,0 +1,13 @@
+import { LatLngBounds } from 'leaflet';
+export function updateMediaOverlay(overlay, props, prevProps) {
+ if (props.bounds instanceof LatLngBounds && props.bounds !== prevProps.bounds) {
+ overlay.setBounds(props.bounds);
+ }
+ if (props.opacity != null && props.opacity !== prevProps.opacity) {
+ overlay.setOpacity(props.opacity);
+ }
+ if (props.zIndex != null && props.zIndex !== prevProps.zIndex) {
+ // @ts-ignore missing in definition but inherited from ImageOverlay
+ overlay.setZIndex(props.zIndex);
+ }
+}
diff --git a/node_modules/@react-leaflet/core/lib/pane.d.ts b/node_modules/@react-leaflet/core/lib/pane.d.ts
new file mode 100644
index 00000000..a8946ea1
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/pane.d.ts
@@ -0,0 +1,3 @@
+import type { LayerOptions } from 'leaflet';
+import type { LeafletContextInterface } from './context.js';
+export declare function withPane(props: P, context: LeafletContextInterface): P;
diff --git a/node_modules/@react-leaflet/core/lib/pane.js b/node_modules/@react-leaflet/core/lib/pane.js
new file mode 100644
index 00000000..5673a2cf
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/pane.js
@@ -0,0 +1,7 @@
+export function withPane(props, context) {
+ const pane = props.pane ?? context.pane;
+ return pane ? {
+ ...props,
+ pane
+ } : props;
+}
diff --git a/node_modules/@react-leaflet/core/lib/path.d.ts b/node_modules/@react-leaflet/core/lib/path.d.ts
new file mode 100644
index 00000000..17d66adb
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/path.d.ts
@@ -0,0 +1,8 @@
+import type { FeatureGroup, Path, PathOptions } from 'leaflet';
+import type { LeafletElement, ElementHook } from './element.js';
+import { type InteractiveLayerProps } from './layer.js';
+export interface PathProps extends InteractiveLayerProps {
+ pathOptions?: PathOptions;
+}
+export declare function usePathOptions(element: LeafletElement, props: PathProps): void;
+export declare function createPathHook(useElement: ElementHook): (props: P) => ReturnType>;
diff --git a/node_modules/@react-leaflet/core/lib/path.js b/node_modules/@react-leaflet/core/lib/path.js
new file mode 100644
index 00000000..636a448a
--- /dev/null
+++ b/node_modules/@react-leaflet/core/lib/path.js
@@ -0,0 +1,28 @@
+import { useEffect, useRef } from 'react';
+import { useLeafletContext } from './context.js';
+import { useEventHandlers } from './events.js';
+import { useLayerLifecycle } from './layer.js';
+import { withPane } from './pane.js';
+export function usePathOptions(element, props) {
+ const optionsRef = useRef();
+ useEffect(function updatePathOptions() {
+ if (props.pathOptions !== optionsRef.current) {
+ const options = props.pathOptions ?? {};
+ element.instance.setStyle(options);
+ optionsRef.current = options;
+ }
+ }, [
+ element,
+ props
+ ]);
+}
+export function createPathHook(useElement) {
+ return function usePath(props) {
+ const context = useLeafletContext();
+ const elementRef = useElement(withPane(props, context), context);
+ useEventHandlers(elementRef.current, props.eventHandlers);
+ useLayerLifecycle(elementRef.current, context);
+ usePathOptions(elementRef.current, props);
+ return elementRef;
+ };
+}
diff --git a/node_modules/@react-leaflet/core/package.json b/node_modules/@react-leaflet/core/package.json
new file mode 100644
index 00000000..226ce7cd
--- /dev/null
+++ b/node_modules/@react-leaflet/core/package.json
@@ -0,0 +1,64 @@
+{
+ "name": "@react-leaflet/core",
+ "version": "2.0.0",
+ "description": "React Leaflet core",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/PaulLeCam/react-leaflet.git"
+ },
+ "keywords": [
+ "react-component",
+ "react",
+ "leaflet",
+ "map"
+ ],
+ "author": "Paul Le Cam ",
+ "license": "Hippocratic-2.1",
+ "bugs": {
+ "url": "https://github.com/PaulLeCam/react-leaflet/issues"
+ },
+ "homepage": "https://react-leaflet.js.org/docs/core-introduction",
+ "type": "module",
+ "main": "lib/index.js",
+ "types": "lib/index.d.ts",
+ "exports": {
+ ".": "./lib/index.js"
+ },
+ "files": [
+ "lib/*"
+ ],
+ "sideEffects": false,
+ "scripts": {
+ "build:clean": "del lib",
+ "build:js": "swc src -d ./lib --config-file ../../.swcrc",
+ "build:types": "tsc --emitDeclarationOnly",
+ "build": "yarn run build:clean && yarn run build:types && yarn run build:js",
+ "test:types": "tsc --noEmit",
+ "test:unit": "cross-env NODE_ENV=test jest",
+ "test": "yarn run test:types && yarn run test:unit",
+ "start": "yarn run test && yarn run build",
+ "prepare": "yarn run build",
+ "prepublishOnly": "package-check"
+ },
+ "peerDependencies": {
+ "leaflet": "^1.8.0",
+ "react": "^18.0.0",
+ "react-dom": "^18.0.0"
+ },
+ "jest": {
+ "extensionsToTreatAsEsm": [
+ ".ts",
+ ".tsx"
+ ],
+ "resolver": "ts-jest-resolver",
+ "testEnvironment": "jsdom",
+ "transform": {
+ "^.+\\.(t|j)sx?$": [
+ "@swc/jest",
+ {
+ "root": "../.."
+ }
+ ]
+ }
+ }
+}
diff --git a/node_modules/leaflet-draw/CHANGELOG.md b/node_modules/leaflet-draw/CHANGELOG.md
new file mode 100644
index 00000000..805d15e9
--- /dev/null
+++ b/node_modules/leaflet-draw/CHANGELOG.md
@@ -0,0 +1,200 @@
+Leaflet.draw Changelog
+======================
+
+## master
+
+An in-progress version being developed on the master branch.
+
+## 0.4.10 (July 3, 2017)
+
+ * Locking Leaflet version to 0.7.x-1.0.x
+ * Polygon line length, square kilometers and configurable precision
+ * fix for _getMeasurementString
+ * Locale number formatting added
+
+## 0.4.2 (November 7, 2016)
+
+### Improvements
+
+ * Documentation is now automatically generated
+ * L.Draw.Event is new, has all events in string format
+
+### Bugfixes
+
+ * Travis tests
+
+## 0.4.1 (October 21, 2016)
+
+### Bugfixes
+
+ * fix markers becomming invisible when in edit mode
+ * Fix linking for EditPolyOptions
+ * Fixes very minor issue in readme with invalid variable name
+
+## 0.4.0 (October 13, 2016)
+
+### Improvements
+
+ * Add support for Leaflet 1.0.0+
+
+### Bugfixes
+
+ * New L.Draw.Tooltip to mitigate L.Tooltip collision
+
+### Potential Issues
+
+ * Several namespace changes, see BREAKINGCHANGES.md
+ * Cross support for both 0.7.0 and 1.0.0
+
+## 0.3.0 (March 09, 2016)
+
+### Improvements
+
+ * Add support for touch devices
+ * Corrected license
+ * Linter
+
+### Bugfixes
+
+ * Added mouse handlers
+ * Fixed event listener leaks in Polyline
+ * Edit vertex event
+
+## 0.2.4 (February 04, 2014)
+
+### Improvements
+
+ * Add support for toolbar touch styles. (by [@alanshaw](https://github.com/alanshaw)). [#269](https://github.com/Leaflet/Leaflet.draw/pull/269 )
+ * Add support for maintaining a layers color when entering edit mode.
+ * Add support for showing area when drawing a rectangle.
+ * Refactor marker editing to bring in line with path editing handlers. Decouple setting editing style from edit toolbar. (by [@manleyjster](https://github.com/manleyjster)). [#323](https://github.com/Leaflet/Leaflet.draw/pull/323)
+ * Prevent skewing on selected edit marker. (by [@kyletolle](https://github.com/kyletolle)). [#341](https://github.com/Leaflet/Leaflet.draw/pull/341)
+ * Add support for changing the 'Radius' label text.
+
+### Bugfixes
+
+ * Fix deleted layers LayerGroup constructor type. (by [@w8r ](https://github.com/w8r )). [#334](https://github.com/Leaflet/Leaflet.draw/pull/334)
+
+## 0.2.3 (January 14, 2014)
+
+### Improvements
+
+ * Restrict editing polygons so that at least 3 points are present. (by [@Zverik](https://github.com/Zverik)). [#200](https://github.com/Leaflet/Leaflet.draw/pull/200)
+ * Tooltips initially start hidden until the mouse has been moved. (by [@Zverik](https://github.com/Zverik)). [#210](https://github.com/Leaflet/Leaflet.draw/pull/210)
+ * Fixup spelling errors. (by [@nexushoratio](https://github.com/nexushoratio)). [#223](https://github.com/Leaflet/Leaflet.draw/pull/223)
+ * Combine ie specific style within leaflet.draw.css stylesheet. (by [@frankrowe](https://github.com/frankrowe)). [#221](https://github.com/Leaflet/Leaflet.draw/pull/221)
+ * Improve my terrible engrish. (by [@erictheise](https://github.com/erictheise)). [#237](https://github.com/Leaflet/Leaflet.draw/pull/237)
+ * Fire `editstart` events when a poly or simple shape is initially edited. (by [@atombender](https://github.com/atombender)). [#245](https://github.com/Leaflet/Leaflet.draw/pull/245)
+ * Add ability to add a new vertex to a polyline or polygon hander.
+ * Added ability to remove/undo the last placed point for polyline or polygons. (by [@Zverik](https://github.com/Zverik)). [#242](https://github.com/Leaflet/Leaflet.draw/pull/242)
+ * Dynamically position the action toolbars. (by [@DevinClark](https://github.com/DevinClark)). [#240](https://github.com/Leaflet/Leaflet.draw/pull/240)
+ * Improve polyline/polygon drawing by accepting some motion on click. (by [@atombender](https://github.com/atombender)). [#249](https://github.com/Leaflet/Leaflet.draw/pull/249)
+ * Only draw a limited number of guide dashes to improve performance in some rare cases. [#254](https://github.com/Leaflet/Leaflet.draw/pull/254)
+
+### Bugfixes
+
+ * Fix edit toolbar so diabled state is represented correctly. (by [@joeybaker](https://github.com/joeybaker)). [#203](https://github.com/Leaflet/Leaflet.draw/pull/203)
+ * Fixed path middle marker positions. (by [@Zverik](https://github.com/Zverik)). [#208](https://github.com/Leaflet/Leaflet.draw/pull/208)
+ * Fix issue where toolbar buttons would have focus after clicked so couldn't use escape to cancel until clicked map at least once.
+ * Fix toolbar icons for retina displays. (by [@dwnoble](https://github.com/dwnoble)). [#217](https://github.com/Leaflet/Leaflet.draw/pull/217)
+ * Ensure that options are not shared between draw handler classes. (by [@yohanboniface](https://github.com/yohanboniface)). [#219](https://github.com/Leaflet/Leaflet.draw/pull/219)
+ * Fix bug where multiple handlers could be active. (by [@manubb](https://github.com/manubb)). [#247](https://github.com/Leaflet/Leaflet.draw/pull/247)
+
+## 0.2.2 (October 4, 2013)
+
+### Improvements
+
+ * Refactored the `L.drawLocal' object to be better structured and use this object whereever text is used. *NOTE: THIS IS A NEW FORMAT, SO WILL BRESK ANY EXISTING CUSTOM `L.drawLocal` SETTINGS*.
+ * Added Imperial measurements to compliment the existing Metric measurements when drawing a polyline or polygon.
+ * Added `draw:editstart` and `draw:editstop` events. (by [@bhell](https://github.com/bhell)). [#175](https://github.com/Leaflet/Leaflet.draw/pull/175)
+ * Added `repeatMode` option that will allow repeated drawing of features. (by [@jayhogan](https://github.com/jayhogan) and [@cscheid](https://github.com/cscheid)). [#178](https://github.com/Leaflet/Leaflet.draw/pull/178)
+ * Added abilit to set circle radius measurement to imperial units.
+ * Added disabled state for edit/delete buttons when no layers present. (inspired by [@snkashis](https://github.com/snkashis)). [#136](https://github.com/Leaflet/Leaflet.draw/pull/136)
+ * Add `showLength` and `showRadius` options to circle and polyline. (by [@Zverik](https://github.com/Zverik)). [#195](https://github.com/Leaflet/Leaflet.draw/pull/195)
+ * Add option to disable tooltips. (by [@Zverik](https://github.com/Zverik)). [#196](https://github.com/Leaflet/Leaflet.draw/pull/196)
+
+### Bugfixes
+
+ * Fixed bug where edit handlers could not be disabled.
+ * Added support for displaying the toolbar on the right hand side of the map. (by [@paulcpederson](https://github.com/paulcpederson)). [#164](https://github.com/Leaflet/Leaflet.draw/pull/164)
+ * Add flexible width action buttons. (by [@Grsmto](https://github.com/Grsmto)). [#181](https://github.com/Leaflet/Leaflet.draw/pull/181)
+ * Check for icon existence before disabling edit state. (by [@tmcw](https://github.com/tmcw)). [#182](https://github.com/Leaflet/Leaflet.draw/pull/182)
+ * Only update guideslines when guidelines are present. (by [@jayhogan](https://github.com/jayhogan)). [#188](https://github.com/Leaflet/Leaflet.draw/pull/188)
+ * Fixes to localization code so it can be correctly set after files have been loaded.
+ * Fix for firing `draw:edit` twice for Draw.SimpleShape. (by [@cazacugmihai](https://github.com/cazacugmihai)). [#192](https://github.com/Leaflet/Leaflet.draw/pull/192)
+ * Fix last edit menu buttons from wrapping. (by [@moiarcsan](https://github.com/moiarcsan)). [#198](https://github.com/Leaflet/Leaflet.draw/pull/198)
+
+## 0.2.1 (July 5, 2013)
+
+### Improvements
+
+ * `draw:edited` now returns a `FeatureGroup` of features edited. (by [@jmkelly](https://github.com/jmkelly)). [#95](https://github.com/Leaflet/Leaflet.draw/pull/95)
+ * Circle tooltip shows the radius (in m) while drawing.
+ * Added Leaflet version check to inform developers that Leaflet 0.6+ is required.
+ * Added ability to finish drawing polygons by double clicking. (inspired by [@snkashis](https://github.com/snkashis)). [#121](https://github.com/Leaflet/Leaflet.label/pull/121)
+ * Added test environment. (by [@iirvine](https://github.com/iirvine)). [#123](https://github.com/Leaflet/Leaflet.draw/pull/123)
+ * Added `L.drawLocal` object to allow users to customize the text used in the plugin. Addresses localization issues. (by [@Starefossen](https://github.com/Starefossen)). [#87](https://github.com/Leaflet/Leaflet.draw/pull/87)
+ * Added ability to disable edit mode path and marker styles. (inspired by [@markgibbons25](https://github.com/markgibbons25)). [#121](https://github.com/Leaflet/Leaflet.label/pull/137)
+ * Added area calculation when drawing a polygon.
+ * Polyline and Polygon tooltips update on click as well as mouse move.
+
+### Bugfixes
+
+ * Fixed issue where removing a vertex or adding a new one via midpoints would not update the edited state for polylines and polygons.
+ * Fixed issue where not passing in the context to `off()` would result in the event from not being unbound.(by [@koppelbakje](https://github.com/koppelbakje)). [#95](https://github.com/Leaflet/Leaflet.draw/pull/112)
+ * Fixed issue where removing the draw control from the map would result in an error.
+ * Fixed bug where removing points created by dragging midpoints would cause the polyline to not reflect any newly created points.
+ * Fixed regression where handlers were not able to be disabled.(by [@yohanboniface](https://github.com/yohanboniface)). [#139](https://github.com/Leaflet/Leaflet.draw/pull/139)
+ * Fixed bug where L.Draw.Polyline would try to remove a non-existant handler if the user cancelled and the polyline only had a single point.
+
+## 0.2.0 (February 20, 2013)
+
+Major new version. Added Edit toolbar which allows editing and deleting shapes.
+
+### Features
+
+ * Consistant event for shape creation. (by [@krikrou](https://github.com/krikrou)). [#58](https://github.com/Leaflet/Leaflet.draw/pull/58)
+
+### Bugfixes
+
+ * Fixed adding markers over vector layers. (by [@Starefossen](https://github.com/Starefossen)). [#82](https://github.com/Leaflet/Leaflet.draw/pull/82)
+
+## 0.1.7 (February 11, 2013)
+
+ * Add sanity check for toolbar buttons when adding top and bottom classes. (by [@yohanboniface](https://github.com/yohanboniface)). [#60](https://github.com/Leaflet/Leaflet.draw/pull/60)
+
+## 0.1.6 (January 17, 2013)
+
+* Updated toolbar styles to be in line with the new Leaflet zoom in/out styles.
+
+## 0.1.5 (December 10, 2012)
+
+### Features
+
+ * Added 'drawing-disabled' event fired on the map when a draw handler is disabled. (by [@ajbeaven](https://github.com/thegreat)). [#35](https://github.com/jacobtoye/Leaflet.draw/pull/35)
+ * Added 'drawing' event fired on the map when a draw handler is actived. (by [@ajbeaven](https://github.com/thegreat)). [#30](https://github.com/jacobtoye/Leaflet.draw/pull/30)
+
+### Bugfixes
+
+ * Stopped L.Control.Draw from storing handlers in it's prototype. (by [@thegreat](https://github.com/thegreat)). [#37](https://github.com/jacobtoye/Leaflet.draw/pull/37)
+
+## 0.1.4 (October 8, 2012)
+
+### Bugfixes
+
+ * Fixed a bug that would cause an error when creating rectangles/circles withought moving the mouse. (by [@inpursuit](https://github.com/inpursuit)). [#25](https://github.com/jacobtoye/Leaflet.draw/pull/25)
+ * Fixed a bug that would cause an error when clicking a different drawing tool while another mode enabled. (by [@thegreat](https://github.com/thegreat)). [#27](https://github.com/jacobtoye/Leaflet.draw/pull/27)
+ * Fixed control buttons breaking plugin in oldIE.
+ * Fixed drawing polylines and polygons in oldIE.
+
+## 0.1.3 (October 3, 2012)
+
+### Bugfixes
+
+ * Tip label will now show over vertex markers.
+ * Added ability to draw on top of existing markers and vector layers.
+ * Clicking on a map object that has a click handler no longer triggers the click event when in drawing mode.
+
+## Pre-0.1.3
+
+Check the commit history for changes previous to 0.1.3.
diff --git a/node_modules/leaflet-draw/README.md b/node_modules/leaflet-draw/README.md
new file mode 100644
index 00000000..30881df5
--- /dev/null
+++ b/node_modules/leaflet-draw/README.md
@@ -0,0 +1,174 @@
+[![GitHub version](https://badge.fury.io/gh/Leaflet%2Fleaflet.draw.svg)](https://badge.fury.io/gh/Leaflet%2Fleaflet.draw)
+[![npm version](https://badge.fury.io/js/leaflet-draw.svg)](https://badge.fury.io/js/leaflet-draw)
+[![NPM Downloads](https://img.shields.io/npm/dt/leaflet-draw.svg)](https://www.npmjs.com/package/leaflet-draw)
+[![Bower version](https://badge.fury.io/bo/leaflet.draw.svg)](https://badge.fury.io/bo/leaflet.draw)
+[![Build Status](https://travis-ci.org/Leaflet/Leaflet.draw.svg?branch=master)](https://travis-ci.org/Leaflet/Leaflet.draw)
+[![Leaflet.draw Chat](https://badges.gitter.im/Leaflet/Leaflet.draw.svg)](https://gitter.im/Leaflet/Leaflet.draw?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
+[![GitHub issues](https://img.shields.io/github/issues/Leaflet/Leaflet.draw.svg)](https://github.com/Leaflet/Leaflet.draw/issues)
+[![GitHub forks](https://img.shields.io/github/forks/Leaflet/Leaflet.draw.svg)](https://github.com/Leaflet/Leaflet.draw/network)
+[![GitHub stars](https://img.shields.io/github/stars/Leaflet/Leaflet.draw.svg)](https://github.com/Leaflet/Leaflet.draw/stargazers)
+[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/Leaflet/Leaflet.draw/master/MIT-LICENSE.md)
+
+# Leaflet.draw
+Adds support for drawing and editing vectors and markers on [Leaflet maps](https://github.com/Leaflet/Leaflet).
+
+Supports [Leaflet](https://github.com/Leaflet/Leaflet/releases) 0.7.x and 1.0.0+ branches.
+
+Please check out our [Api Documentation](https://leaflet.github.io/Leaflet.draw/docs/leaflet-draw-latest.html)
+
+#### Upgrading from Leaflet.draw 0.1
+
+Leaflet.draw 0.2.0 changes a LOT of things from 0.1. Please see [BREAKING CHANGES](https://github.com/Leaflet/Leaflet.draw/blob/master/BREAKINGCHANGES.md) for how to upgrade.
+
+## In this readme
+
+- [Customizing Language](#customizing-language-and-text-in-leafletdraw)
+- [Common tasks](#common-tasks)
+- [Contributing](#contributing)
+- [Thanks](#thanks)
+
+## Customizing language and text in Leaflet.draw
+
+Leaflet.draw uses the `L.drawLocal` configuration object to set any text used in the plugin. Customizing this will allow support for changing the text or supporting another language.
+
+See [Leaflet.draw.js](https://github.com/Leaflet/Leaflet.draw/blob/master/src/Leaflet.draw.js) for the default strings.
+
+E.g.
+
+```js
+ // Set the button title text for the polygon button
+ L.drawLocal.draw.toolbar.buttons.polygon = 'Draw a sexy polygon!';
+
+ // Set the tooltip start text for the rectangle
+ L.drawLocal.draw.handlers.rectangle.tooltip.start = 'Not telling...';
+```
+
+## Common tasks
+
+The following examples outline some common tasks.
+
+### Example Leaflet.draw config
+
+The following example will show you how to:
+
+1. Change the position of the control's toolbar.
+2. Customize the styles of a vector layer.
+3. Use a custom marker.
+4. Disable the delete functionality.
+
+```js
+ var cloudmadeUrl = 'http://{s}.tile.cloudmade.com/BC9A493B41014CAABB98F0471D759707/997/256/{z}/{x}/{y}.png',
+ cloudmade = new L.TileLayer(cloudmadeUrl, {maxZoom: 18}),
+ map = new L.Map('map', {layers: [cloudmade], center: new L.LatLng(-37.7772, 175.2756), zoom: 15 });
+
+ var editableLayers = new L.FeatureGroup();
+ map.addLayer(editableLayers);
+
+ var MyCustomMarker = L.Icon.extend({
+ options: {
+ shadowUrl: null,
+ iconAnchor: new L.Point(12, 12),
+ iconSize: new L.Point(24, 24),
+ iconUrl: 'link/to/image.png'
+ }
+ });
+
+ var options = {
+ position: 'topright',
+ draw: {
+ polyline: {
+ shapeOptions: {
+ color: '#f357a1',
+ weight: 10
+ }
+ },
+ polygon: {
+ allowIntersection: false, // Restricts shapes to simple polygons
+ drawError: {
+ color: '#e1e100', // Color the shape will turn when intersects
+ message: 'Oh snap! you can\'t draw that!' // Message that will show when intersect
+ },
+ shapeOptions: {
+ color: '#bada55'
+ }
+ },
+ circle: false, // Turns off this drawing tool
+ rectangle: {
+ shapeOptions: {
+ clickable: false
+ }
+ },
+ marker: {
+ icon: new MyCustomMarker()
+ }
+ },
+ edit: {
+ featureGroup: editableLayers, //REQUIRED!!
+ remove: false
+ }
+ };
+
+ var drawControl = new L.Control.Draw(options);
+ map.addControl(drawControl);
+
+ map.on(L.Draw.Event.CREATED, function (e) {
+ var type = e.layerType,
+ layer = e.layer;
+
+ if (type === 'marker') {
+ layer.bindPopup('A popup!');
+ }
+
+ editableLayers.addLayer(layer);
+ });
+```
+
+### Changing a drawing handlers options
+
+You can change a draw handlers options after initialisation by using the `setDrawingOptions` method on the Leaflet.draw control.
+
+E.g. to change the colour of the rectangle:
+
+```js
+drawControl.setDrawingOptions({
+ rectangle: {
+ shapeOptions: {
+ color: '#0000FF'
+ }
+ }
+});
+```
+
+# Contributing
+
+## Testing
+
+To test you can install the npm dependencies:
+
+ npm install
+
+and then use:
+
+ jake test
+
+## Documentation
+
+Documentation is build with Leafdoc, to generate the documentation use
+
+ jake docs
+
+and the generated html documentation is saved to `./docs/leaflet-draw-latest.html`
+
+## Thanks
+
+Touch friendly version of Leaflet.draw was created by Michael Guild (https://github.com/michaelguild13).
+
+The touch support was initiated due to a demand for it at National Geographic for their Map Maker Projected (http://mapmaker.education.nationalgeographic.com/) that was created by Michael Guild and Daniel Schep (https://github.com/dschep)
+
+Thanks so much to [@brunob](https://github.com/brunob), [@tnightingale](https://github.com/tnightingale), and [@shramov](https://github.com/shramov). I got a lot of ideas from their Leaflet plugins.
+
+All the [contributors](https://github.com/Leaflet/Leaflet.draw/graphs/contributors) and issue reporters of this plugin rock. Thanks for tidying up my mess and keeping the plugin on track.
+
+The icons used for some of the toolbar buttons are either from http://glyphicons.com/ or inspired by them. <3 Glyphicons!
+
+Finally, [@mourner](https://github.com/mourner) is the man! Thanks for dedicating so much of your time to create the gosh darn best JavaScript mapping library around.
diff --git a/node_modules/leaflet-draw/dist/images/layers-2x.png b/node_modules/leaflet-draw/dist/images/layers-2x.png
new file mode 100644
index 00000000..200c333d
Binary files /dev/null and b/node_modules/leaflet-draw/dist/images/layers-2x.png differ
diff --git a/node_modules/leaflet-draw/dist/images/layers.png b/node_modules/leaflet-draw/dist/images/layers.png
new file mode 100644
index 00000000..1a72e578
Binary files /dev/null and b/node_modules/leaflet-draw/dist/images/layers.png differ
diff --git a/node_modules/leaflet-draw/dist/images/marker-icon-2x.png b/node_modules/leaflet-draw/dist/images/marker-icon-2x.png
new file mode 100644
index 00000000..e4abba3b
Binary files /dev/null and b/node_modules/leaflet-draw/dist/images/marker-icon-2x.png differ
diff --git a/node_modules/leaflet-draw/dist/images/marker-icon.png b/node_modules/leaflet-draw/dist/images/marker-icon.png
new file mode 100644
index 00000000..950edf24
Binary files /dev/null and b/node_modules/leaflet-draw/dist/images/marker-icon.png differ
diff --git a/node_modules/leaflet-draw/dist/images/marker-shadow.png b/node_modules/leaflet-draw/dist/images/marker-shadow.png
new file mode 100644
index 00000000..9fd29795
Binary files /dev/null and b/node_modules/leaflet-draw/dist/images/marker-shadow.png differ
diff --git a/node_modules/leaflet-draw/dist/images/spritesheet-2x.png b/node_modules/leaflet-draw/dist/images/spritesheet-2x.png
new file mode 100644
index 00000000..c45231af
Binary files /dev/null and b/node_modules/leaflet-draw/dist/images/spritesheet-2x.png differ
diff --git a/node_modules/leaflet-draw/dist/images/spritesheet.png b/node_modules/leaflet-draw/dist/images/spritesheet.png
new file mode 100644
index 00000000..97d71c68
Binary files /dev/null and b/node_modules/leaflet-draw/dist/images/spritesheet.png differ
diff --git a/node_modules/leaflet-draw/dist/images/spritesheet.svg b/node_modules/leaflet-draw/dist/images/spritesheet.svg
new file mode 100644
index 00000000..3c00f303
--- /dev/null
+++ b/node_modules/leaflet-draw/dist/images/spritesheet.svg
@@ -0,0 +1,156 @@
+
+
+
+
+
+ image/svg+xml
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/node_modules/leaflet-draw/dist/leaflet.draw-src.css b/node_modules/leaflet-draw/dist/leaflet.draw-src.css
new file mode 100644
index 00000000..dffca06b
--- /dev/null
+++ b/node_modules/leaflet-draw/dist/leaflet.draw-src.css
@@ -0,0 +1,325 @@
+/* ================================================================== */
+/* Toolbars
+/* ================================================================== */
+
+.leaflet-draw-section {
+ position: relative;
+}
+
+.leaflet-draw-toolbar {
+ margin-top: 12px;
+}
+
+.leaflet-draw-toolbar-top {
+ margin-top: 0;
+}
+
+.leaflet-draw-toolbar-notop a:first-child {
+ border-top-right-radius: 0;
+}
+
+.leaflet-draw-toolbar-nobottom a:last-child {
+ border-bottom-right-radius: 0;
+}
+
+.leaflet-draw-toolbar a {
+ background-image: url('images/spritesheet.png');
+ background-image: linear-gradient(transparent, transparent), url('images/spritesheet.svg');
+ background-repeat: no-repeat;
+ background-size: 300px 30px;
+ background-clip: padding-box;
+}
+
+.leaflet-retina .leaflet-draw-toolbar a {
+ background-image: url('images/spritesheet-2x.png');
+ background-image: linear-gradient(transparent, transparent), url('images/spritesheet.svg');
+}
+
+.leaflet-draw a {
+ display: block;
+ text-align: center;
+ text-decoration: none;
+}
+
+.leaflet-draw a .sr-only {
+ position: absolute;
+ width: 1px;
+ height: 1px;
+ padding: 0;
+ margin: -1px;
+ overflow: hidden;
+ clip: rect(0, 0, 0, 0);
+ border: 0;
+}
+
+/* ================================================================== */
+/* Toolbar actions menu
+/* ================================================================== */
+
+.leaflet-draw-actions {
+ display: none;
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ position: absolute;
+ left: 26px; /* leaflet-draw-toolbar.left + leaflet-draw-toolbar.width */
+ top: 0;
+ white-space: nowrap;
+}
+
+.leaflet-touch .leaflet-draw-actions {
+ left: 32px;
+}
+
+.leaflet-right .leaflet-draw-actions {
+ right: 26px;
+ left: auto;
+}
+
+.leaflet-touch .leaflet-right .leaflet-draw-actions {
+ right: 32px;
+ left: auto;
+}
+
+.leaflet-draw-actions li {
+ display: inline-block;
+}
+
+.leaflet-draw-actions li:first-child a {
+ border-left: none;
+}
+
+.leaflet-draw-actions li:last-child a {
+ -webkit-border-radius: 0 4px 4px 0;
+ border-radius: 0 4px 4px 0;
+}
+
+.leaflet-right .leaflet-draw-actions li:last-child a {
+ -webkit-border-radius: 0;
+ border-radius: 0;
+}
+
+.leaflet-right .leaflet-draw-actions li:first-child a {
+ -webkit-border-radius: 4px 0 0 4px;
+ border-radius: 4px 0 0 4px;
+}
+
+.leaflet-draw-actions a {
+ background-color: #919187;
+ border-left: 1px solid #AAA;
+ color: #FFF;
+ font: 11px/19px "Helvetica Neue", Arial, Helvetica, sans-serif;
+ line-height: 28px;
+ text-decoration: none;
+ padding-left: 10px;
+ padding-right: 10px;
+ height: 28px;
+}
+
+.leaflet-touch .leaflet-draw-actions a {
+ font-size: 12px;
+ line-height: 30px;
+ height: 30px;
+}
+
+.leaflet-draw-actions-bottom {
+ margin-top: 0;
+}
+
+.leaflet-draw-actions-top {
+ margin-top: 1px;
+}
+
+.leaflet-draw-actions-top a,
+.leaflet-draw-actions-bottom a {
+ height: 27px;
+ line-height: 27px;
+}
+
+.leaflet-draw-actions a:hover {
+ background-color: #A0A098;
+}
+
+.leaflet-draw-actions-top.leaflet-draw-actions-bottom a {
+ height: 26px;
+ line-height: 26px;
+}
+
+/* ================================================================== */
+/* Draw toolbar
+/* ================================================================== */
+
+.leaflet-draw-toolbar .leaflet-draw-draw-polyline {
+ background-position: -2px -2px;
+}
+
+.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-polyline {
+ background-position: 0 -1px;
+}
+
+.leaflet-draw-toolbar .leaflet-draw-draw-polygon {
+ background-position: -31px -2px;
+}
+
+.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-polygon {
+ background-position: -29px -1px;
+}
+
+.leaflet-draw-toolbar .leaflet-draw-draw-rectangle {
+ background-position: -62px -2px;
+}
+
+.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-rectangle {
+ background-position: -60px -1px;
+}
+
+.leaflet-draw-toolbar .leaflet-draw-draw-circle {
+ background-position: -92px -2px;
+}
+
+.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-circle {
+ background-position: -90px -1px;
+}
+
+.leaflet-draw-toolbar .leaflet-draw-draw-marker {
+ background-position: -122px -2px;
+}
+
+.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-marker {
+ background-position: -120px -1px;
+}
+
+.leaflet-draw-toolbar .leaflet-draw-draw-circlemarker {
+ background-position: -273px -2px;
+}
+
+.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-circlemarker {
+ background-position: -271px -1px;
+}
+
+/* ================================================================== */
+/* Edit toolbar
+/* ================================================================== */
+
+.leaflet-draw-toolbar .leaflet-draw-edit-edit {
+ background-position: -152px -2px;
+}
+
+.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-edit-edit {
+ background-position: -150px -1px;
+}
+
+.leaflet-draw-toolbar .leaflet-draw-edit-remove {
+ background-position: -182px -2px;
+}
+
+.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-edit-remove {
+ background-position: -180px -1px;
+}
+
+.leaflet-draw-toolbar .leaflet-draw-edit-edit.leaflet-disabled {
+ background-position: -212px -2px;
+}
+
+.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-edit-edit.leaflet-disabled {
+ background-position: -210px -1px;
+}
+
+.leaflet-draw-toolbar .leaflet-draw-edit-remove.leaflet-disabled {
+ background-position: -242px -2px;
+}
+
+.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-edit-remove.leaflet-disabled {
+ background-position: -240px -2px;
+}
+
+/* ================================================================== */
+/* Drawing styles
+/* ================================================================== */
+
+.leaflet-mouse-marker {
+ background-color: #fff;
+ cursor: crosshair;
+}
+
+.leaflet-draw-tooltip {
+ background: rgb(54, 54, 54);
+ background: rgba(0, 0, 0, 0.5);
+ border: 1px solid transparent;
+ -webkit-border-radius: 4px;
+ border-radius: 4px;
+ color: #fff;
+ font: 12px/18px "Helvetica Neue", Arial, Helvetica, sans-serif;
+ margin-left: 20px;
+ margin-top: -21px;
+ padding: 4px 8px;
+ position: absolute;
+ visibility: hidden;
+ white-space: nowrap;
+ z-index: 6;
+}
+
+.leaflet-draw-tooltip:before {
+ border-right: 6px solid black;
+ border-right-color: rgba(0, 0, 0, 0.5);
+ border-top: 6px solid transparent;
+ border-bottom: 6px solid transparent;
+ content: "";
+ position: absolute;
+ top: 7px;
+ left: -7px;
+}
+
+.leaflet-error-draw-tooltip {
+ background-color: #F2DEDE;
+ border: 1px solid #E6B6BD;
+ color: #B94A48;
+}
+
+.leaflet-error-draw-tooltip:before {
+ border-right-color: #E6B6BD;
+}
+
+.leaflet-draw-tooltip-single {
+ margin-top: -12px
+}
+
+.leaflet-draw-tooltip-subtext {
+ color: #f8d5e4;
+}
+
+.leaflet-draw-guide-dash {
+ font-size: 1%;
+ opacity: 0.6;
+ position: absolute;
+ width: 5px;
+ height: 5px;
+}
+
+/* ================================================================== */
+/* Edit styles
+/* ================================================================== */
+
+.leaflet-edit-marker-selected {
+ background-color: rgba(254, 87, 161, 0.1);
+ border: 4px dashed rgba(254, 87, 161, 0.6);
+ -webkit-border-radius: 4px;
+ border-radius: 4px;
+ box-sizing: content-box;
+}
+
+.leaflet-edit-move {
+ cursor: move;
+}
+
+.leaflet-edit-resize {
+ cursor: pointer;
+}
+
+/* ================================================================== */
+/* Old IE styles
+/* ================================================================== */
+
+.leaflet-oldie .leaflet-draw-toolbar {
+ border: 1px solid #999;
+}
diff --git a/node_modules/leaflet-draw/dist/leaflet.draw-src.js b/node_modules/leaflet-draw/dist/leaflet.draw-src.js
new file mode 100644
index 00000000..8f427527
--- /dev/null
+++ b/node_modules/leaflet-draw/dist/leaflet.draw-src.js
@@ -0,0 +1,4774 @@
+/*
+ Leaflet.draw 1.0.4, a plugin that adds drawing and editing tools to Leaflet powered maps.
+ (c) 2012-2017, Jacob Toye, Jon West, Smartrak, Leaflet
+
+ https://github.com/Leaflet/Leaflet.draw
+ http://leafletjs.com
+ */
+(function (window, document, undefined) {/**
+ * Leaflet.draw assumes that you have already included the Leaflet library.
+ */
+L.drawVersion = "1.0.4";
+/**
+ * @class L.Draw
+ * @aka Draw
+ *
+ *
+ * To add the draw toolbar set the option drawControl: true in the map options.
+ *
+ * @example
+ * ```js
+ * var map = L.map('map', {drawControl: true}).setView([51.505, -0.09], 13);
+ *
+ * L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
+ * attribution: '© OpenStreetMap contributors'
+ * }).addTo(map);
+ * ```
+ *
+ * ### Adding the edit toolbar
+ * To use the edit toolbar you must initialise the Leaflet.draw control and manually add it to the map.
+ *
+ * ```js
+ * var map = L.map('map').setView([51.505, -0.09], 13);
+ *
+ * L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
+ * attribution: '© OpenStreetMap contributors'
+ * }).addTo(map);
+ *
+ * // FeatureGroup is to store editable layers
+ * var drawnItems = new L.FeatureGroup();
+ * map.addLayer(drawnItems);
+ *
+ * var drawControl = new L.Control.Draw({
+ * edit: {
+ * featureGroup: drawnItems
+ * }
+ * });
+ * map.addControl(drawControl);
+ * ```
+ *
+ * The key here is the featureGroup option. This tells the plugin which FeatureGroup contains the layers that
+ * should be editable. The featureGroup can contain 0 or more features with geometry types Point, LineString, and Polygon.
+ * Leaflet.draw does not work with multigeometry features such as MultiPoint, MultiLineString, MultiPolygon,
+ * or GeometryCollection. If you need to add multigeometry features to the draw plugin, convert them to a
+ * FeatureCollection of non-multigeometries (Points, LineStrings, or Polygons).
+ */
+L.Draw = {};
+
+/**
+ * @class L.drawLocal
+ * @aka L.drawLocal
+ *
+ * The core toolbar class of the API — it is used to create the toolbar ui
+ *
+ * @example
+ * ```js
+ * var modifiedDraw = L.drawLocal.extend({
+ * draw: {
+ * toolbar: {
+ * buttons: {
+ * polygon: 'Draw an awesome polygon'
+ * }
+ * }
+ * }
+ * });
+ * ```
+ *
+ * The default state for the control is the draw toolbar just below the zoom control.
+ * This will allow map users to draw vectors and markers.
+ * **Please note the edit toolbar is not enabled by default.**
+ */
+L.drawLocal = {
+ // format: {
+ // numeric: {
+ // delimiters: {
+ // thousands: ',',
+ // decimal: '.'
+ // }
+ // }
+ // },
+ draw: {
+ toolbar: {
+ // #TODO: this should be reorganized where actions are nested in actions
+ // ex: actions.undo or actions.cancel
+ actions: {
+ title: 'Cancel drawing',
+ text: 'Cancel'
+ },
+ finish: {
+ title: 'Finish drawing',
+ text: 'Finish'
+ },
+ undo: {
+ title: 'Delete last point drawn',
+ text: 'Delete last point'
+ },
+ buttons: {
+ polyline: 'Draw a polyline',
+ polygon: 'Draw a polygon',
+ rectangle: 'Draw a rectangle',
+ circle: 'Draw a circle',
+ marker: 'Draw a marker',
+ circlemarker: 'Draw a circlemarker'
+ }
+ },
+ handlers: {
+ circle: {
+ tooltip: {
+ start: 'Click and drag to draw circle.'
+ },
+ radius: 'Radius'
+ },
+ circlemarker: {
+ tooltip: {
+ start: 'Click map to place circle marker.'
+ }
+ },
+ marker: {
+ tooltip: {
+ start: 'Click map to place marker.'
+ }
+ },
+ polygon: {
+ tooltip: {
+ start: 'Click to start drawing shape.',
+ cont: 'Click to continue drawing shape.',
+ end: 'Click first point to close this shape.'
+ }
+ },
+ polyline: {
+ error: 'Error: shape edges cannot cross!',
+ tooltip: {
+ start: 'Click to start drawing line.',
+ cont: 'Click to continue drawing line.',
+ end: 'Click last point to finish line.'
+ }
+ },
+ rectangle: {
+ tooltip: {
+ start: 'Click and drag to draw rectangle.'
+ }
+ },
+ simpleshape: {
+ tooltip: {
+ end: 'Release mouse to finish drawing.'
+ }
+ }
+ }
+ },
+ edit: {
+ toolbar: {
+ actions: {
+ save: {
+ title: 'Save changes',
+ text: 'Save'
+ },
+ cancel: {
+ title: 'Cancel editing, discards all changes',
+ text: 'Cancel'
+ },
+ clearAll: {
+ title: 'Clear all layers',
+ text: 'Clear All'
+ }
+ },
+ buttons: {
+ edit: 'Edit layers',
+ editDisabled: 'No layers to edit',
+ remove: 'Delete layers',
+ removeDisabled: 'No layers to delete'
+ }
+ },
+ handlers: {
+ edit: {
+ tooltip: {
+ text: 'Drag handles or markers to edit features.',
+ subtext: 'Click cancel to undo changes.'
+ }
+ },
+ remove: {
+ tooltip: {
+ text: 'Click on a feature to remove.'
+ }
+ }
+ }
+ }
+};
+
+
+
+/**
+ * ### Events
+ * Once you have successfully added the Leaflet.draw plugin to your map you will want to respond to the different
+ * actions users can initiate. The following events will be triggered on the map:
+ *
+ * @class L.Draw.Event
+ * @aka Draw.Event
+ *
+ * Use `L.Draw.Event.EVENTNAME` constants to ensure events are correct.
+ *
+ * @example
+ * ```js
+ * map.on(L.Draw.Event.CREATED; function (e) {
+ * var type = e.layerType,
+ * layer = e.layer;
+ *
+ * if (type === 'marker') {
+ * // Do marker specific actions
+ * }
+ *
+ * // Do whatever else you need to. (save to db; add to map etc)
+ * map.addLayer(layer);
+ *});
+ * ```
+ */
+L.Draw.Event = {};
+/**
+ * @event draw:created: PolyLine; Polygon; Rectangle; Circle; Marker | String
+ *
+ * Layer that was just created.
+ * The type of layer this is. One of: `polyline`; `polygon`; `rectangle`; `circle`; `marker`
+ * Triggered when a new vector or marker has been created.
+ *
+ */
+L.Draw.Event.CREATED = 'draw:created';
+
+/**
+ * @event draw:edited: LayerGroup
+ *
+ * List of all layers just edited on the map.
+ *
+ *
+ * Triggered when layers in the FeatureGroup; initialised with the plugin; have been edited and saved.
+ *
+ * @example
+ * ```js
+ * map.on('draw:edited', function (e) {
+ * var layers = e.layers;
+ * layers.eachLayer(function (layer) {
+ * //do whatever you want; most likely save back to db
+ * });
+ * });
+ * ```
+ */
+L.Draw.Event.EDITED = 'draw:edited';
+
+/**
+ * @event draw:deleted: LayerGroup
+ *
+ * List of all layers just removed from the map.
+ *
+ * Triggered when layers have been removed (and saved) from the FeatureGroup.
+ */
+L.Draw.Event.DELETED = 'draw:deleted';
+
+/**
+ * @event draw:drawstart: String
+ *
+ * The type of layer this is. One of:`polyline`; `polygon`; `rectangle`; `circle`; `marker`
+ *
+ * Triggered when the user has chosen to draw a particular vector or marker.
+ */
+L.Draw.Event.DRAWSTART = 'draw:drawstart';
+
+/**
+ * @event draw:drawstop: String
+ *
+ * The type of layer this is. One of: `polyline`; `polygon`; `rectangle`; `circle`; `marker`
+ *
+ * Triggered when the user has finished a particular vector or marker.
+ */
+
+L.Draw.Event.DRAWSTOP = 'draw:drawstop';
+
+/**
+ * @event draw:drawvertex: LayerGroup
+ *
+ * List of all layers just being added from the map.
+ *
+ * Triggered when a vertex is created on a polyline or polygon.
+ */
+L.Draw.Event.DRAWVERTEX = 'draw:drawvertex';
+
+/**
+ * @event draw:editstart: String
+ *
+ * The type of edit this is. One of: `edit`
+ *
+ * Triggered when the user starts edit mode by clicking the edit tool button.
+ */
+
+L.Draw.Event.EDITSTART = 'draw:editstart';
+
+/**
+ * @event draw:editmove: ILayer
+ *
+ * Layer that was just moved.
+ *
+ * Triggered as the user moves a rectangle; circle or marker.
+ */
+L.Draw.Event.EDITMOVE = 'draw:editmove';
+
+/**
+ * @event draw:editresize: ILayer
+ *
+ * Layer that was just moved.
+ *
+ * Triggered as the user resizes a rectangle or circle.
+ */
+L.Draw.Event.EDITRESIZE = 'draw:editresize';
+
+/**
+ * @event draw:editvertex: LayerGroup
+ *
+ * List of all layers just being edited from the map.
+ *
+ * Triggered when a vertex is edited on a polyline or polygon.
+ */
+L.Draw.Event.EDITVERTEX = 'draw:editvertex';
+
+/**
+ * @event draw:editstop: String
+ *
+ * The type of edit this is. One of: `edit`
+ *
+ * Triggered when the user has finshed editing (edit mode) and saves edits.
+ */
+L.Draw.Event.EDITSTOP = 'draw:editstop';
+
+/**
+ * @event draw:deletestart: String
+ *
+ * The type of edit this is. One of: `remove`
+ *
+ * Triggered when the user starts remove mode by clicking the remove tool button.
+ */
+L.Draw.Event.DELETESTART = 'draw:deletestart';
+
+/**
+ * @event draw:deletestop: String
+ *
+ * The type of edit this is. One of: `remove`
+ *
+ * Triggered when the user has finished removing shapes (remove mode) and saves.
+ */
+L.Draw.Event.DELETESTOP = 'draw:deletestop';
+
+/**
+ * @event draw:toolbaropened: String
+ *
+ * Triggered when a toolbar is opened.
+ */
+L.Draw.Event.TOOLBAROPENED = 'draw:toolbaropened';
+
+/**
+ * @event draw:toolbarclosed: String
+ *
+ * Triggered when a toolbar is closed.
+ */
+L.Draw.Event.TOOLBARCLOSED = 'draw:toolbarclosed';
+
+/**
+ * @event draw:markercontext: String
+ *
+ * Triggered when a marker is right clicked.
+ */
+L.Draw.Event.MARKERCONTEXT = 'draw:markercontext';
+
+
+L.Draw = L.Draw || {};
+
+/**
+ * @class L.Draw.Feature
+ * @aka Draw.Feature
+ */
+L.Draw.Feature = L.Handler.extend({
+
+ // @method initialize(): void
+ initialize: function (map, options) {
+ this._map = map;
+ this._container = map._container;
+ this._overlayPane = map._panes.overlayPane;
+ this._popupPane = map._panes.popupPane;
+
+ // Merge default shapeOptions options with custom shapeOptions
+ if (options && options.shapeOptions) {
+ options.shapeOptions = L.Util.extend({}, this.options.shapeOptions, options.shapeOptions);
+ }
+ L.setOptions(this, options);
+
+ var version = L.version.split('.');
+ //If Version is >= 1.2.0
+ if (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {
+ L.Draw.Feature.include(L.Evented.prototype);
+ } else {
+ L.Draw.Feature.include(L.Mixin.Events);
+ }
+ },
+
+ // @method enable(): void
+ // Enables this handler
+ enable: function () {
+ if (this._enabled) {
+ return;
+ }
+
+ L.Handler.prototype.enable.call(this);
+
+ this.fire('enabled', {handler: this.type});
+
+ this._map.fire(L.Draw.Event.DRAWSTART, {layerType: this.type});
+ },
+
+ // @method disable(): void
+ disable: function () {
+ if (!this._enabled) {
+ return;
+ }
+
+ L.Handler.prototype.disable.call(this);
+
+ this._map.fire(L.Draw.Event.DRAWSTOP, {layerType: this.type});
+
+ this.fire('disabled', {handler: this.type});
+ },
+
+ // @method addHooks(): void
+ // Add's event listeners to this handler
+ addHooks: function () {
+ var map = this._map;
+
+ if (map) {
+ L.DomUtil.disableTextSelection();
+
+ map.getContainer().focus();
+
+ this._tooltip = new L.Draw.Tooltip(this._map);
+
+ L.DomEvent.on(this._container, 'keyup', this._cancelDrawing, this);
+ }
+ },
+
+ // @method removeHooks(): void
+ // Removes event listeners from this handler
+ removeHooks: function () {
+ if (this._map) {
+ L.DomUtil.enableTextSelection();
+
+ this._tooltip.dispose();
+ this._tooltip = null;
+
+ L.DomEvent.off(this._container, 'keyup', this._cancelDrawing, this);
+ }
+ },
+
+ // @method setOptions(object): void
+ // Sets new options to this handler
+ setOptions: function (options) {
+ L.setOptions(this, options);
+ },
+
+ _fireCreatedEvent: function (layer) {
+ this._map.fire(L.Draw.Event.CREATED, {layer: layer, layerType: this.type});
+ },
+
+ // Cancel drawing when the escape key is pressed
+ _cancelDrawing: function (e) {
+ if (e.keyCode === 27) {
+ this._map.fire('draw:canceled', {layerType: this.type});
+ this.disable();
+ }
+ }
+});
+
+
+
+/**
+ * @class L.Draw.Polyline
+ * @aka Draw.Polyline
+ * @inherits L.Draw.Feature
+ */
+L.Draw.Polyline = L.Draw.Feature.extend({
+ statics: {
+ TYPE: 'polyline'
+ },
+
+ Poly: L.Polyline,
+
+ options: {
+ allowIntersection: true,
+ repeatMode: false,
+ drawError: {
+ color: '#b00b00',
+ timeout: 2500
+ },
+ icon: new L.DivIcon({
+ iconSize: new L.Point(8, 8),
+ className: 'leaflet-div-icon leaflet-editing-icon'
+ }),
+ touchIcon: new L.DivIcon({
+ iconSize: new L.Point(20, 20),
+ className: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon'
+ }),
+ guidelineDistance: 20,
+ maxGuideLineLength: 4000,
+ shapeOptions: {
+ stroke: true,
+ color: '#3388ff',
+ weight: 4,
+ opacity: 0.5,
+ fill: false,
+ clickable: true
+ },
+ metric: true, // Whether to use the metric measurement system or imperial
+ feet: true, // When not metric, to use feet instead of yards for display.
+ nautic: false, // When not metric, not feet use nautic mile for display
+ showLength: true, // Whether to display distance in the tooltip
+ zIndexOffset: 2000, // This should be > than the highest z-index any map layers
+ factor: 1, // To change distance calculation
+ maxPoints: 0 // Once this number of points are placed, finish shape
+ },
+
+ // @method initialize(): void
+ initialize: function (map, options) {
+ // if touch, switch to touch icon
+ if (L.Browser.touch) {
+ this.options.icon = this.options.touchIcon;
+ }
+
+ // Need to set this here to ensure the correct message is used.
+ this.options.drawError.message = L.drawLocal.draw.handlers.polyline.error;
+
+ // Merge default drawError options with custom options
+ if (options && options.drawError) {
+ options.drawError = L.Util.extend({}, this.options.drawError, options.drawError);
+ }
+
+ // Save the type so super can fire, need to do this as cannot do this.TYPE :(
+ this.type = L.Draw.Polyline.TYPE;
+
+ L.Draw.Feature.prototype.initialize.call(this, map, options);
+ },
+
+ // @method addHooks(): void
+ // Add listener hooks to this handler
+ addHooks: function () {
+ L.Draw.Feature.prototype.addHooks.call(this);
+ if (this._map) {
+ this._markers = [];
+
+ this._markerGroup = new L.LayerGroup();
+ this._map.addLayer(this._markerGroup);
+
+ this._poly = new L.Polyline([], this.options.shapeOptions);
+
+ this._tooltip.updateContent(this._getTooltipText());
+
+ // Make a transparent marker that will used to catch click events. These click
+ // events will create the vertices. We need to do this so we can ensure that
+ // we can create vertices over other map layers (markers, vector layers). We
+ // also do not want to trigger any click handlers of objects we are clicking on
+ // while drawing.
+ if (!this._mouseMarker) {
+ this._mouseMarker = L.marker(this._map.getCenter(), {
+ icon: L.divIcon({
+ className: 'leaflet-mouse-marker',
+ iconAnchor: [20, 20],
+ iconSize: [40, 40]
+ }),
+ opacity: 0,
+ zIndexOffset: this.options.zIndexOffset
+ });
+ }
+
+ this._mouseMarker
+ .on('mouseout', this._onMouseOut, this)
+ .on('mousemove', this._onMouseMove, this) // Necessary to prevent 0.8 stutter
+ .on('mousedown', this._onMouseDown, this)
+ .on('mouseup', this._onMouseUp, this) // Necessary for 0.8 compatibility
+ .addTo(this._map);
+
+ this._map
+ .on('mouseup', this._onMouseUp, this) // Necessary for 0.7 compatibility
+ .on('mousemove', this._onMouseMove, this)
+ .on('zoomlevelschange', this._onZoomEnd, this)
+ .on('touchstart', this._onTouch, this)
+ .on('zoomend', this._onZoomEnd, this);
+
+ }
+ },
+
+ // @method removeHooks(): void
+ // Remove listener hooks from this handler.
+ removeHooks: function () {
+ L.Draw.Feature.prototype.removeHooks.call(this);
+
+ this._clearHideErrorTimeout();
+
+ this._cleanUpShape();
+
+ // remove markers from map
+ 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;
+
+ // clean up DOM
+ 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);
+ },
+
+ // @method deleteLastVertex(): void
+ // Remove the last vertex from the polyline, removes polyline from map if only one point exists.
+ deleteLastVertex: function () {
+ if (this._markers.length <= 1) {
+ return;
+ }
+
+ var lastMarker = this._markers.pop(),
+ poly = this._poly,
+ // Replaces .spliceLatLngs()
+ 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);
+ }
+
+ this._vertexChanged(latlng, false);
+ },
+
+ // @method addVertex(): void
+ // Add a vertex to the end of the polyline
+ addVertex: function (latlng) {
+ var markersLength = this._markers.length;
+ // markersLength must be greater than or equal to 2 before intersections can occur
+ if (markersLength >= 2 && !this.options.allowIntersection && this._poly.newLatLngIntersects(latlng)) {
+ this._showErrorTooltip();
+ return;
+ }
+ else if (this._errorShown) {
+ this._hideErrorTooltip();
+ }
+
+ this._markers.push(this._createMarker(latlng));
+
+ this._poly.addLatLng(latlng);
+
+ if (this._poly.getLatLngs().length === 2) {
+ this._map.addLayer(this._poly);
+ }
+
+ this._vertexChanged(latlng, true);
+ },
+
+ // @method completeShape(): void
+ // Closes the polyline between the first and last points
+ completeShape: function () {
+ if (this._markers.length <= 1 || !this._shapeIsValid()) {
+ return;
+ }
+
+ 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;
+ }
+
+ this._fireCreatedEvent();
+ this.disable();
+ if (this.options.repeatMode) {
+ this.enable();
+ }
+ },
+
+ // Called to verify the shape is valid when the user tries to finish it
+ // Return false if the shape is not valid
+ _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);
+
+ // Save latlng
+ // should this be moved to _updateGuide() ?
+ this._currentLatLng = latlng;
+
+ this._updateTooltip(latlng);
+
+ // Update the guide line
+ this._updateGuide(newPos);
+
+ // Update the mouse marker position
+ this._mouseMarker.setLatLng(latlng);
+
+ L.DomEvent.preventDefault(e.originalEvent);
+ },
+
+ _vertexChanged: function (latlng, added) {
+ this._map.fire(L.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 = L.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 = L.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 && L.Browser.touch) {
+ this._finishShape();
+ } else if (Math.abs(dragCheckDistance) < 9 * (window.devicePixelRatio || 1)) {
+ this.addVertex(e.latlng);
+ }
+ this._enableNewMarkers(); // after a short pause, enable new markers
+ }
+ this._mouseDownOrigin = null;
+ },
+
+ // ontouch prevented by clickHandled flag because some browsers fire both click/touch events,
+ // causing unwanted behavior
+ _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;
+ }
+ this._clickHandled = null;
+ },
+
+ _onMouseOut: function () {
+ if (this._tooltip) {
+ this._tooltip._onMouseOut.call(this._tooltip);
+ }
+ },
+
+ // calculate if we are currently within close enough distance
+ // of the closing point (first point for shapes, last point for lines)
+ // this is semi-ugly code but the only reliable way i found to get the job done
+ // note: calculating point.distanceTo between mouseDownOrigin and last marker did NOT work
+ _calculateFinishDistance: function (potentialLatLng) {
+ var lastPtDistance;
+ if (this._markers.length > 0) {
+ var finishMarker;
+ if (this.type === L.Draw.Polyline.TYPE) {
+ finishMarker = this._markers[this._markers.length - 1];
+ } else if (this.type === L.Draw.Polygon.TYPE) {
+ finishMarker = this._markers[0];
+ } else {
+ return Infinity;
+ }
+ var lastMarkerPoint = this._map.latLngToContainerPoint(finishMarker.getLatLng()),
+ potentialMarker = new L.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;
+ }
+ return lastPtDistance;
+ },
+
+ _updateFinishHandler: function () {
+ var markerCount = this._markers.length;
+ // The last marker should have a click handler to close the polyline
+ if (markerCount > 1) {
+ this._markers[markerCount - 1].on('click', this._finishShape, this);
+ }
+
+ // Remove the old marker click handler (as only the last point should close the polyline)
+ if (markerCount > 2) {
+ this._markers[markerCount - 2].off('click', this._finishShape, this);
+ }
+ },
+
+ _createMarker: function (latlng) {
+ var marker = new L.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);
+
+ // draw the guide line
+ this._clearGuides();
+ this._drawGuide(
+ this._map.latLngToLayerPoint(this._markers[markerCount - 1].getLatLng()),
+ newPos
+ );
+ }
+ },
+
+ _updateTooltip: function (latLng) {
+ var text = this._getTooltipText();
+
+ if (latLng) {
+ this._tooltip.updatePosition(latLng);
+ }
+
+ if (!this._errorShown) {
+ 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,
+ // Only draw a guideline with a max length
+ i = length > maxGuideLineLength ? length - maxGuideLineLength : guidelineDistance,
+ fraction,
+ dashPoint,
+ dash;
+
+ //create the guides container if we haven't yet
+ if (!this._guidesContainer) {
+ this._guidesContainer = L.DomUtil.create('div', 'leaflet-draw-guides', this._overlayPane);
+ }
+
+ //draw a dash every GuildeLineDistance
+ for (; i < length; i += this.options.guidelineDistance) {
+ //work out fraction along line we are
+ fraction = i / length;
+
+ //calculate new x,y point
+ dashPoint = {
+ x: Math.floor((pointA.x * (1 - fraction)) + (fraction * pointB.x)),
+ y: Math.floor((pointA.y * (1 - fraction)) + (fraction * pointB.y))
+ };
+
+ //add guide dash to guide container
+ dash = L.DomUtil.create('div', 'leaflet-draw-guide-dash', this._guidesContainer);
+ dash.style.backgroundColor =
+ !this._errorShown ? this.options.shapeOptions.color : this.options.drawError.color;
+
+ L.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;
+ }
+ }
+ },
+
+ // removes all child elements (guide dashes) from the guides container
+ _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: L.drawLocal.draw.handlers.polyline.tooltip.start
+ };
+ } else {
+ distanceStr = showLength ? this._getMeasurementString() : '';
+
+ if (this._markers.length === 1) {
+ labelText = {
+ text: L.drawLocal.draw.handlers.polyline.tooltip.cont,
+ subtext: distanceStr
+ };
+ } else {
+ labelText = {
+ text: L.drawLocal.draw.handlers.polyline.tooltip.end,
+ subtext: distanceStr
+ };
+ }
+ }
+ 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);
+
+ // Calculate the distance based on the version
+ if (L.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);
+ }
+
+ this._measurementRunningTotal += distance * (added ? 1 : -1);
+ }
+ },
+
+ _getMeasurementString: function () {
+ var currentLatLng = this._currentLatLng,
+ previousLatLng = this._markers[this._markers.length - 1].getLatLng(),
+ distance;
+
+ // Calculate the distance from the last fixed point to the mouse position based on the version
+ if (L.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;
+ }
+
+ return L.GeometryUtil.readableDistance(distance, this.options.metric, this.options.feet, this.options.nautic, this.options.precision);
+ },
+
+ _showErrorTooltip: function () {
+ this._errorShown = true;
+
+ // Update tooltip
+ this._tooltip
+ .showAsError()
+ .updateContent({text: this.options.drawError.message});
+
+ // Update shape
+ this._updateGuideColor(this.options.drawError.color);
+ this._poly.setStyle({color: this.options.drawError.color});
+
+ // Hide the error after 2 seconds
+ this._clearHideErrorTimeout();
+ this._hideErrorTimeout = setTimeout(L.Util.bind(this._hideErrorTooltip, this), this.options.drawError.timeout);
+ },
+
+ _hideErrorTooltip: function () {
+ this._errorShown = false;
+
+ this._clearHideErrorTimeout();
+
+ // Revert tooltip
+ this._tooltip
+ .removeError()
+ .updateContent(this._getTooltipText());
+
+ // Revert shape
+ 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;
+ }
+ },
+
+ // disable new markers temporarily;
+ // this is to prevent duplicated touch/click events in some browsers
+ _disableNewMarkers: function () {
+ this._disableMarkers = true;
+ },
+
+ // see _disableNewMarkers
+ _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);
+ L.Draw.Feature.prototype._fireCreatedEvent.call(this, poly);
+ }
+});
+
+
+
+/**
+ * @class L.Draw.Polygon
+ * @aka Draw.Polygon
+ * @inherits L.Draw.Polyline
+ */
+L.Draw.Polygon = L.Draw.Polyline.extend({
+ statics: {
+ TYPE: 'polygon'
+ },
+
+ Poly: L.Polygon,
+
+ options: {
+ showArea: false,
+ showLength: false,
+ shapeOptions: {
+ stroke: true,
+ color: '#3388ff',
+ weight: 4,
+ opacity: 0.5,
+ fill: true,
+ fillColor: null, //same as color by default
+ fillOpacity: 0.2,
+ clickable: true
+ },
+ // Whether to use the metric measurement system (truthy) or not (falsy).
+ // Also defines the units to use for the metric system as an array of
+ // strings (e.g. `['ha', 'm']`).
+ metric: true,
+ feet: true, // When not metric, to use feet instead of yards for display.
+ nautic: false, // When not metric, not feet use nautic mile for display
+ // Defines the precision for each type of unit (e.g. {km: 2, ft: 0}
+ precision: {}
+ },
+
+ // @method initialize(): void
+ initialize: function (map, options) {
+ L.Draw.Polyline.prototype.initialize.call(this, map, options);
+
+ // Save the type so super can fire, need to do this as cannot do this.TYPE :(
+ this.type = L.Draw.Polygon.TYPE;
+ },
+
+ _updateFinishHandler: function () {
+ var markerCount = this._markers.length;
+
+ // The first marker should have a click handler to close the polygon
+ if (markerCount === 1) {
+ this._markers[0].on('click', this._finishShape, this);
+ }
+
+ // Add and update the double click handler
+ if (markerCount > 2) {
+ this._markers[markerCount - 1].on('dblclick', this._finishShape, this);
+ // Only need to remove handler if has been added before
+ if (markerCount > 3) {
+ this._markers[markerCount - 2].off('dblclick', this._finishShape, this);
+ }
+ }
+ },
+
+ _getTooltipText: function () {
+ var text, subtext;
+
+ if (this._markers.length === 0) {
+ text = L.drawLocal.draw.handlers.polygon.tooltip.start;
+ } else if (this._markers.length < 3) {
+ text = L.drawLocal.draw.handlers.polygon.tooltip.cont;
+ subtext = this._getMeasurementString();
+ } else {
+ text = L.drawLocal.draw.handlers.polygon.tooltip.end;
+ subtext = this._getMeasurementString();
+ }
+
+ return {
+ text: text,
+ subtext: subtext
+ };
+ },
+
+ _getMeasurementString: function () {
+ var area = this._area,
+ measurementString = '';
+
+
+ if (!area && !this.options.showLength) {
+ return null;
+ }
+
+ if (this.options.showLength) {
+ measurementString = L.Draw.Polyline.prototype._getMeasurementString.call(this);
+ }
+
+ if (area) {
+ measurementString += ' ' + L.GeometryUtil.readableArea(area, this.options.metric, this.options.precision);
+ }
+
+ return measurementString;
+ },
+
+ _shapeIsValid: function () {
+ return this._markers.length >= 3;
+ },
+
+ _vertexChanged: function (latlng, added) {
+ var latLngs;
+
+ // Check to see if we should show the area
+ if (!this.options.allowIntersection && this.options.showArea) {
+ latLngs = this._poly.getLatLngs();
+
+ this._area = L.GeometryUtil.geodesicArea(latLngs);
+ }
+
+ L.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);
+ }
+ }
+ }
+});
+
+
+
+L.SimpleShape = {};
+/**
+ * @class L.Draw.SimpleShape
+ * @aka Draw.SimpleShape
+ * @inherits L.Draw.Feature
+ */
+L.Draw.SimpleShape = L.Draw.Feature.extend({
+ options: {
+ repeatMode: false
+ },
+
+ // @method initialize(): void
+ initialize: function (map, options) {
+ this._endLabelText = L.drawLocal.draw.handlers.simpleshape.tooltip.end;
+
+ L.Draw.Feature.prototype.initialize.call(this, map, options);
+ },
+
+ // @method addHooks(): void
+ // Add listener hooks to this handler.
+ addHooks: function () {
+ L.Draw.Feature.prototype.addHooks.call(this);
+ if (this._map) {
+ this._mapDraggable = this._map.dragging.enabled();
+
+ if (this._mapDraggable) {
+ this._map.dragging.disable();
+ }
+
+ //TODO refactor: move cursor to styles
+ 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);
+
+ // we should prevent default, otherwise default behavior (scrolling) will fire,
+ // and that will cause document.touchend to fire and will stop the drawing
+ // (circle, rectangle) in touch mode.
+ // (update): we have to send passive now to prevent scroll, because by default it is {passive: true} now, which means,
+ // handler can't event.preventDefault
+ // check the news https://developers.google.com/web/updates/2016/06/passive-event-listeners
+ document.addEventListener('touchstart', L.DomEvent.preventDefault, {passive: false});
+ }
+ },
+
+ // @method removeHooks(): void
+ // Remove listener hooks from this handler.
+ removeHooks: function () {
+ L.Draw.Feature.prototype.removeHooks.call(this);
+ if (this._map) {
+ if (this._mapDraggable) {
+ this._map.dragging.enable();
+ }
+
+ //TODO refactor: move cursor to styles
+ 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);
+
+ L.DomEvent.off(document, 'mouseup', this._onMouseUp, this);
+ L.DomEvent.off(document, 'touchend', this._onMouseUp, this);
+
+ document.removeEventListener('touchstart', L.DomEvent.preventDefault);
+
+ // If the box element doesn't exist they must not have moved the mouse, so don't need to destroy/return
+ if (this._shape) {
+ this._map.removeLayer(this._shape);
+ delete this._shape;
+ }
+ }
+ this._isDrawing = false;
+ },
+
+ _getTooltipText: function () {
+ return {
+ text: this._endLabelText
+ };
+ },
+
+ _onMouseDown: function (e) {
+ this._isDrawing = true;
+ this._startLatLng = e.latlng;
+
+ L.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();
+ }
+
+ this.disable();
+ if (this.options.repeatMode) {
+ this.enable();
+ }
+ }
+});
+
+
+
+/**
+ * @class L.Draw.Rectangle
+ * @aka Draw.Rectangle
+ * @inherits L.Draw.SimpleShape
+ */
+L.Draw.Rectangle = L.Draw.SimpleShape.extend({
+ statics: {
+ TYPE: 'rectangle'
+ },
+
+ options: {
+ shapeOptions: {
+ stroke: true,
+ color: '#3388ff',
+ weight: 4,
+ opacity: 0.5,
+ fill: true,
+ fillColor: null, //same as color by default
+ fillOpacity: 0.2,
+ clickable: true
+ },
+ showArea: true, //Whether to show the area in the tooltip
+ metric: true // Whether to use the metric measurement system or imperial
+ },
+
+ // @method initialize(): void
+ initialize: function (map, options) {
+ // Save the type so super can fire, need to do this as cannot do this.TYPE :(
+ this.type = L.Draw.Rectangle.TYPE;
+
+ this._initialLabelText = L.drawLocal.draw.handlers.rectangle.tooltip.start;
+
+ L.Draw.SimpleShape.prototype.initialize.call(this, map, options);
+ },
+
+ // @method disable(): void
+ disable: function () {
+ if (!this._enabled) {
+ return;
+ }
+
+ this._isCurrentlyTwoClickDrawing = false;
+ L.Draw.SimpleShape.prototype.disable.call(this);
+ },
+
+ _onMouseUp: function (e) {
+ if (!this._shape && !this._isCurrentlyTwoClickDrawing) {
+ this._isCurrentlyTwoClickDrawing = true;
+ return;
+ }
+
+ // Make sure closing click is on map
+ if (this._isCurrentlyTwoClickDrawing && !_hasAncestor(e.target, 'leaflet-pane')) {
+ return;
+ }
+
+ L.Draw.SimpleShape.prototype._onMouseUp.call(this);
+ },
+
+ _drawShape: function (latlng) {
+ if (!this._shape) {
+ this._shape = new L.Rectangle(new L.LatLngBounds(this._startLatLng, latlng), this.options.shapeOptions);
+ this._map.addLayer(this._shape);
+ } else {
+ this._shape.setBounds(new L.LatLngBounds(this._startLatLng, latlng));
+ }
+ },
+
+ _fireCreatedEvent: function () {
+ var rectangle = new L.Rectangle(this._shape.getBounds(), this.options.shapeOptions);
+ L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, rectangle);
+ },
+
+ _getTooltipText: function () {
+ var tooltipText = L.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 = L.GeometryUtil.geodesicArea(latLngs);
+ subtext = showArea ? L.GeometryUtil.readableArea(area, this.options.metric) : '';
+ }
+
+ return {
+ text: tooltipText.text,
+ subtext: subtext
+ };
+ }
+});
+
+function _hasAncestor(el, cls) {
+ while ((el = el.parentElement) && !el.classList.contains(cls)) {
+ ;
+ }
+ return el;
+}
+
+
+
+/**
+ * @class L.Draw.Marker
+ * @aka Draw.Marker
+ * @inherits L.Draw.Feature
+ */
+L.Draw.Marker = L.Draw.Feature.extend({
+ statics: {
+ TYPE: 'marker'
+ },
+
+ options: {
+ icon: new L.Icon.Default(),
+ repeatMode: false,
+ zIndexOffset: 2000 // This should be > than the highest z-index any markers
+ },
+
+ // @method initialize(): void
+ initialize: function (map, options) {
+ // Save the type so super can fire, need to do this as cannot do this.TYPE :(
+ this.type = L.Draw.Marker.TYPE;
+
+ this._initialLabelText = L.drawLocal.draw.handlers.marker.tooltip.start;
+
+ L.Draw.Feature.prototype.initialize.call(this, map, options);
+ },
+
+ // @method addHooks(): void
+ // Add listener hooks to this handler.
+ addHooks: function () {
+ L.Draw.Feature.prototype.addHooks.call(this);
+
+ if (this._map) {
+ this._tooltip.updateContent({text: this._initialLabelText});
+
+ // Same mouseMarker as in Draw.Polyline
+ if (!this._mouseMarker) {
+ this._mouseMarker = L.marker(this._map.getCenter(), {
+ icon: L.divIcon({
+ className: 'leaflet-mouse-marker',
+ iconAnchor: [20, 20],
+ iconSize: [40, 40]
+ }),
+ opacity: 0,
+ zIndexOffset: this.options.zIndexOffset
+ });
+ }
+
+ this._mouseMarker
+ .on('click', this._onClick, this)
+ .addTo(this._map);
+
+ this._map.on('mousemove', this._onMouseMove, this);
+ this._map.on('click', this._onTouch, this);
+ }
+ },
+
+ // @method removeHooks(): void
+ // Remove listener hooks from this handler.
+ removeHooks: function () {
+ L.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;
+ }
+
+ 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);
+ // Bind to both marker and map to make sure we get the click event.
+ this._marker.on('click', this._onClick, this);
+ this._map
+ .on('click', this._onClick, this)
+ .addLayer(this._marker);
+ }
+ else {
+ latlng = this._mouseMarker.getLatLng();
+ this._marker.setLatLng(latlng);
+ }
+ },
+
+ _createMarker: function (latlng) {
+ return new L.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) {
+ // called on click & tap, only really does any thing on tap
+ this._onMouseMove(e); // creates & places marker
+ this._onClick(); // permanently places marker & ends interaction
+ },
+
+ _fireCreatedEvent: function () {
+ var marker = new L.Marker.Touch(this._marker.getLatLng(), {icon: this.options.icon});
+ L.Draw.Feature.prototype._fireCreatedEvent.call(this, marker);
+ }
+});
+
+
+
+/**
+ * @class L.Draw.CircleMarker
+ * @aka Draw.CircleMarker
+ * @inherits L.Draw.Marker
+ */
+L.Draw.CircleMarker = L.Draw.Marker.extend({
+ statics: {
+ TYPE: 'circlemarker'
+ },
+
+ options: {
+ stroke: true,
+ color: '#3388ff',
+ weight: 4,
+ opacity: 0.5,
+ fill: true,
+ fillColor: null, //same as color by default
+ fillOpacity: 0.2,
+ clickable: true,
+ zIndexOffset: 2000 // This should be > than the highest z-index any markers
+ },
+
+ // @method initialize(): void
+ initialize: function (map, options) {
+ // Save the type so super can fire, need to do this as cannot do this.TYPE :(
+ this.type = L.Draw.CircleMarker.TYPE;
+
+ this._initialLabelText = L.drawLocal.draw.handlers.circlemarker.tooltip.start;
+
+ L.Draw.Feature.prototype.initialize.call(this, map, options);
+ },
+
+
+ _fireCreatedEvent: function () {
+ var circleMarker = new L.CircleMarker(this._marker.getLatLng(), this.options);
+ L.Draw.Feature.prototype._fireCreatedEvent.call(this, circleMarker);
+ },
+
+ _createMarker: function (latlng) {
+ return new L.CircleMarker(latlng, this.options);
+ }
+});
+
+
+
+/**
+ * @class L.Draw.Circle
+ * @aka Draw.Circle
+ * @inherits L.Draw.SimpleShape
+ */
+L.Draw.Circle = L.Draw.SimpleShape.extend({
+ statics: {
+ TYPE: 'circle'
+ },
+
+ options: {
+ shapeOptions: {
+ stroke: true,
+ color: '#3388ff',
+ weight: 4,
+ opacity: 0.5,
+ fill: true,
+ fillColor: null, //same as color by default
+ fillOpacity: 0.2,
+ clickable: true
+ },
+ showRadius: true,
+ metric: true, // Whether to use the metric measurement system or imperial
+ feet: true, // When not metric, use feet instead of yards for display
+ nautic: false // When not metric, not feet use nautic mile for display
+ },
+
+ // @method initialize(): void
+ initialize: function (map, options) {
+ // Save the type so super can fire, need to do this as cannot do this.TYPE :(
+ this.type = L.Draw.Circle.TYPE;
+
+ this._initialLabelText = L.drawLocal.draw.handlers.circle.tooltip.start;
+
+ L.Draw.SimpleShape.prototype.initialize.call(this, map, options);
+ },
+
+ _drawShape: function (latlng) {
+ // Calculate the distance based on the version
+ if (L.GeometryUtil.isVersion07x()) {
+ var distance = this._startLatLng.distanceTo(latlng);
+ } else {
+ var distance = this._map.distance(this._startLatLng, latlng);
+ }
+
+ if (!this._shape) {
+ this._shape = new L.Circle(this._startLatLng, distance, this.options.shapeOptions);
+ this._map.addLayer(this._shape);
+ } else {
+ this._shape.setRadius(distance);
+ }
+ },
+
+ _fireCreatedEvent: function () {
+ var circle = new L.Circle(this._startLatLng, this._shape.getRadius(), this.options.shapeOptions);
+ L.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);
+
+ // Get the new radius (rounded to 1 dp)
+ radius = this._shape.getRadius().toFixed(1);
+
+ var subtext = '';
+ if (showRadius) {
+ subtext = L.drawLocal.draw.handlers.circle.radius + ': ' +
+ L.GeometryUtil.readableDistance(radius, useMetric, this.options.feet, this.options.nautic);
+ }
+ this._tooltip.updateContent({
+ text: this._endLabelText,
+ subtext: subtext
+ });
+ }
+ }
+});
+
+
+
+L.Edit = L.Edit || {};
+
+/**
+ * @class L.Edit.Marker
+ * @aka Edit.Marker
+ */
+L.Edit.Marker = L.Handler.extend({
+ // @method initialize(): void
+ initialize: function (marker, options) {
+ this._marker = marker;
+ L.setOptions(this, options);
+ },
+
+ // @method addHooks(): void
+ // Add listener hooks to this handler
+ addHooks: function () {
+ var marker = this._marker;
+
+ marker.dragging.enable();
+ marker.on('dragend', this._onDragEnd, marker);
+ this._toggleMarkerHighlight();
+ },
+
+ // @method removeHooks(): void
+ // Remove listener hooks from this handler
+ 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(L.Draw.Event.EDITMOVE, {layer: layer});
+ },
+
+ _toggleMarkerHighlight: function () {
+ var icon = this._marker._icon;
+
+ // Don't do anything if this layer is a marker but doesn't have an icon. Markers
+ // should usually have icons. If using Leaflet.draw with Leaflet.markercluster there
+ // is a chance that a marker doesn't.
+ if (!icon) {
+ return;
+ }
+
+ // This is quite naughty, but I don't see another way of doing it. (short of setting a new icon)
+ icon.style.display = 'none';
+
+ if (L.DomUtil.hasClass(icon, 'leaflet-edit-marker-selected')) {
+ L.DomUtil.removeClass(icon, 'leaflet-edit-marker-selected');
+ // Offset as the border will make the icon move.
+ this._offsetMarker(icon, -4);
+
+ } else {
+ L.DomUtil.addClass(icon, 'leaflet-edit-marker-selected');
+ // Offset as the border will make the icon move.
+ this._offsetMarker(icon, 4);
+ }
+
+ 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';
+ }
+});
+
+L.Marker.addInitHook(function () {
+ if (L.Edit.Marker) {
+ this.editing = new L.Edit.Marker(this);
+
+ if (this.options.editable) {
+ this.editing.enable();
+ }
+ }
+});
+
+
+
+L.Edit = L.Edit || {};
+
+/**
+ * @class L.Edit.Polyline
+ * @aka L.Edit.Poly
+ * @aka Edit.Poly
+ */
+L.Edit.Poly = L.Handler.extend({
+ // @method initialize(): void
+ initialize: function (poly) {
+
+ this.latlngs = [poly._latlngs];
+ if (poly._holes) {
+ this.latlngs = this.latlngs.concat(poly._holes);
+ }
+
+ this._poly = poly;
+
+ this._poly.on('revert-edited', this._updateLatLngs, this);
+ },
+
+ // Compatibility method to normalize Poly* objects
+ // between 0.7.x and 1.0+
+ _defaultShape: function () {
+ if (!L.Polyline._flat) {
+ return this._poly._latlngs;
+ }
+ return L.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]);
+ }
+ },
+
+ // @method addHooks(): void
+ // Add listener hooks to this handler
+ addHooks: function () {
+ this._initHandlers();
+ this._eachVertexHandler(function (handler) {
+ handler.addHooks();
+ });
+ },
+
+ // @method removeHooks(): void
+ // Remove listener hooks from this handler
+ removeHooks: function () {
+ this._eachVertexHandler(function (handler) {
+ handler.removeHooks();
+ });
+ },
+
+ // @method updateMarkers(): void
+ // Fire an update for each vertex handler
+ 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 L.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);
+ }
+ }
+
+});
+
+/**
+ * @class L.Edit.PolyVerticesEdit
+ * @aka Edit.PolyVerticesEdit
+ */
+L.Edit.PolyVerticesEdit = L.Handler.extend({
+ options: {
+ icon: new L.DivIcon({
+ iconSize: new L.Point(8, 8),
+ className: 'leaflet-div-icon leaflet-editing-icon'
+ }),
+ touchIcon: new L.DivIcon({
+ iconSize: new L.Point(20, 20),
+ className: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon'
+ }),
+ drawError: {
+ color: '#b00b00',
+ timeout: 1000
+ }
+
+
+ },
+
+ // @method intialize(): void
+ initialize: function (poly, latlngs, options) {
+ // if touch, switch to touch icon
+ if (L.Browser.touch) {
+ this.options.icon = this.options.touchIcon;
+ }
+ this._poly = poly;
+
+ if (options && options.drawError) {
+ options.drawError = L.Util.extend({}, this.options.drawError, options.drawError);
+ }
+
+ this._latlngs = latlngs;
+
+ L.setOptions(this, options);
+ },
+
+ // Compatibility method to normalize Poly* objects
+ // between 0.7.x and 1.0+
+ _defaultShape: function () {
+ if (!L.Polyline._flat) {
+ return this._latlngs;
+ }
+ return L.Polyline._flat(this._latlngs) ? this._latlngs : this._latlngs[0];
+ },
+
+ // @method addHooks(): void
+ // Add listener hooks to this handler.
+ addHooks: function () {
+ var poly = this._poly;
+ var path = poly._path;
+
+ if (!(poly instanceof L.Polygon)) {
+ poly.options.fill = false;
+ if (poly.options.editing) {
+ poly.options.editing.fill = false;
+ }
+ }
+
+ if (path) {
+ if (poly.options.editing && poly.options.editing.className) {
+ if (poly.options.original.className) {
+ poly.options.original.className.split(' ').forEach(function (className) {
+ L.DomUtil.removeClass(path, className);
+ });
+ }
+ poly.options.editing.className.split(' ').forEach(function (className) {
+ L.DomUtil.addClass(path, className);
+ });
+ }
+ }
+
+ poly.setStyle(poly.options.editing);
+
+ if (this._poly._map) {
+
+ this._map = this._poly._map; // Set map
+
+ if (!this._markerGroup) {
+ this._initMarkers();
+ }
+ this._poly._map.addLayer(this._markerGroup);
+ }
+ },
+
+ // @method removeHooks(): void
+ // Remove listener hooks from this handler.
+ 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) {
+ L.DomUtil.removeClass(path, className);
+ });
+ if (poly.options.original.className) {
+ poly.options.original.className.split(' ').forEach(function (className) {
+ L.DomUtil.addClass(path, className);
+ });
+ }
+ }
+ }
+
+ poly.setStyle(poly.options.original);
+
+ if (poly._map) {
+ poly._map.removeLayer(this._markerGroup);
+ delete this._markerGroup;
+ delete this._markers;
+ }
+ },
+
+ // @method updateMarkers(): void
+ // Clear markers and update their location
+ updateMarkers: function () {
+ this._markerGroup.clearLayers();
+ this._initMarkers();
+ },
+
+ _initMarkers: function () {
+ if (!this._markerGroup) {
+ this._markerGroup = new L.LayerGroup();
+ }
+ 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);
+ }
+
+ var markerLeft, markerRight;
+
+ for (i = 0, j = len - 1; i < len; j = i++) {
+ if (i === 0 && !(L.Polygon && (this._poly instanceof L.Polygon))) {
+ continue;
+ }
+
+ markerLeft = this._markers[j];
+ markerRight = this._markers[i];
+
+ this._createMiddleMarker(markerLeft, markerRight);
+ this._updatePrevNext(markerLeft, markerRight);
+ }
+ },
+
+ _createMarker: function (latlng, index) {
+ // Extending L.Marker in TouchEvents.js to include touch.
+ var marker = new L.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(L.Draw.Event.EDITVERTEX, {layers: this._markerGroup, poly: this._poly});
+ },
+
+ _onMarkerDrag: function (e) {
+ var marker = e.target;
+ var poly = this._poly;
+
+ var oldOrigLatLng = L.LatLngUtil.cloneLatLng(marker._origLatLng);
+ L.extend(marker._origLatLng, marker._latlng);
+ if (poly.options.poly) {
+ var tooltip = poly._map._editTooltip; // Access the tooltip
+
+ // If we don't allow intersections and the polygon intersects
+ if (!poly.options.poly.allowIntersection && poly.intersects()) {
+ L.extend(marker._origLatLng, oldOrigLatLng);
+ marker.setLatLng(oldOrigLatLng);
+ var originalColor = poly.options.color;
+ poly.setStyle({color: this.options.drawError.color});
+ if (tooltip) {
+ tooltip.updateContent({
+ text: L.drawLocal.draw.handlers.polyline.error
+ });
+ }
+
+ // Reset everything back to normal after a second
+ setTimeout(function () {
+ poly.setStyle({color: originalColor});
+ if (tooltip) {
+ tooltip.updateContent({
+ text: L.drawLocal.edit.handlers.edit.tooltip.text,
+ subtext: L.drawLocal.edit.handlers.edit.tooltip.subtext
+ });
+ }
+ }, 1000);
+ }
+ }
+
+ if (marker._middleLeft) {
+ marker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));
+ }
+ if (marker._middleRight) {
+ marker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));
+ }
+
+ //refresh the bounds when draging
+ this._poly._bounds._southWest = L.latLng(Infinity, Infinity);
+ this._poly._bounds._northEast = L.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 = L.Polygon && (this._poly instanceof L.Polygon) ? 4 : 3,
+ marker = e.target;
+
+ // If removing this point would create an invalid polyline/polygon don't remove
+ if (this._defaultShape().length < minPoints) {
+ return;
+ }
+
+ // remove the marker
+ this._removeMarker(marker);
+
+ // update prev/next links of adjacent markers
+ this._updatePrevNext(marker._prev, marker._next);
+
+ // remove ghost markers near the removed marker
+ if (marker._middleLeft) {
+ this._markerGroup.removeLayer(marker._middleLeft);
+ }
+ if (marker._middleRight) {
+ this._markerGroup.removeLayer(marker._middleRight);
+ }
+
+ // create a ghost marker in place of the removed one
+ 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;
+ }
+
+ this._fireEdit();
+ },
+
+ _onContextMenu: function (e) {
+ var marker = e.target;
+ var poly = this._poly;
+ this._poly._map.fire(L.Draw.Event.MARKERCONTEXT, {marker: marker, layers: this._markerGroup, poly: this._poly});
+ L.DomEvent.stopPropagation;
+ },
+
+ _onTouchMove: function (e) {
+
+ var layerPoint = this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]),
+ latlng = this._map.layerPointToLatLng(layerPoint),
+ marker = e.target;
+
+ L.extend(marker._origLatLng, latlng);
+
+ if (marker._middleLeft) {
+ marker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));
+ }
+ if (marker._middleRight) {
+ marker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));
+ }
+
+ 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;
+ }
+ 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));
+ }
+});
+
+L.Polyline.addInitHook(function () {
+
+ // Check to see if handler has already been initialized. This is to support versions of Leaflet that still have L.Handler.PolyEdit
+ if (this.editing) {
+ return;
+ }
+
+ if (L.Edit.Poly) {
+
+ this.editing = new L.Edit.Poly(this);
+
+ if (this.options.editable) {
+ this.editing.enable();
+ }
+ }
+
+ 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();
+ }
+ });
+});
+
+
+
+L.Edit = L.Edit || {};
+/**
+ * @class L.Edit.SimpleShape
+ * @aka Edit.SimpleShape
+ */
+L.Edit.SimpleShape = L.Handler.extend({
+ options: {
+ moveIcon: new L.DivIcon({
+ iconSize: new L.Point(8, 8),
+ className: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move'
+ }),
+ resizeIcon: new L.DivIcon({
+ iconSize: new L.Point(8, 8),
+ className: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize'
+ }),
+ touchMoveIcon: new L.DivIcon({
+ iconSize: new L.Point(20, 20),
+ className: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move leaflet-touch-icon'
+ }),
+ touchResizeIcon: new L.DivIcon({
+ iconSize: new L.Point(20, 20),
+ className: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize leaflet-touch-icon'
+ }),
+ },
+
+ // @method intialize(): void
+ initialize: function (shape, options) {
+ // if touch, switch to touch icon
+ if (L.Browser.touch) {
+ this.options.moveIcon = this.options.touchMoveIcon;
+ this.options.resizeIcon = this.options.touchResizeIcon;
+ }
+
+ this._shape = shape;
+ L.Util.setOptions(this, options);
+ },
+
+ // @method addHooks(): void
+ // Add listener hooks to this handler
+ 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();
+ }
+ this._map.addLayer(this._markerGroup);
+ }
+ }
+ },
+
+ // @method removeHooks(): void
+ // Remove listener hooks from this handler
+ 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]);
+ }
+ this._resizeMarkers = null;
+
+ this._map.removeLayer(this._markerGroup);
+ delete this._markerGroup;
+ }
+
+ this._map = null;
+ },
+
+ // @method updateMarkers(): void
+ // Remove the edit markers from this layer
+ updateMarkers: function () {
+ this._markerGroup.clearLayers();
+ this._initMarkers();
+ },
+
+ _initMarkers: function () {
+ if (!this._markerGroup) {
+ this._markerGroup = new L.LayerGroup();
+ }
+
+ // Create center marker
+ this._createMoveMarker();
+
+ // Create edge marker
+ this._createResizeMarker();
+ },
+
+ _createMoveMarker: function () {
+ // Children override
+ },
+
+ _createResizeMarker: function () {
+ // Children override
+ },
+
+ _createMarker: function (latlng, icon) {
+ // Extending L.Marker in TouchEvents.js to include touch.
+ var marker = new L.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);
+ }
+
+ this._shape.redraw();
+ this._shape.fire('editdrag');
+ },
+
+ _onMarkerDragEnd: function (e) {
+ var marker = e.target;
+ marker.setOpacity(1);
+
+ this._fireEdit();
+ },
+
+ _onTouchStart: function (e) {
+ L.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e);
+
+ if (typeof(this._getCorners) === 'function') {
+ // Save a reference to the opposite point
+ var corners = this._getCorners(),
+ marker = e.target,
+ currentCornerIndex = marker._cornerIndex;
+
+ marker.setOpacity(0);
+
+ // Copyed from Edit.Rectangle.js line 23 _onMarkerDragStart()
+ // Latlng is null otherwise.
+ this._oppositeCorner = corners[(currentCornerIndex + 2) % 4];
+ this._toggleCornerMarkers(0, currentCornerIndex);
+ }
+
+ 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);
+ }
+
+ this._shape.redraw();
+
+ // prevent touchcancel in IOS
+ // e.preventDefault();
+ return false;
+ },
+
+ _onTouchEnd: function (e) {
+ var marker = e.target;
+ marker.setOpacity(1);
+ this.updateMarkers();
+ this._fireEdit();
+ },
+
+ _move: function () {
+ // Children override
+ },
+
+ _resize: function () {
+ // Children override
+ }
+});
+
+
+
+L.Edit = L.Edit || {};
+/**
+ * @class L.Edit.Rectangle
+ * @aka Edit.Rectangle
+ * @inherits L.Edit.SimpleShape
+ */
+L.Edit.Rectangle = L.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));
+ // Monkey in the corner index as we will need to know this for dragging
+ this._resizeMarkers[i]._cornerIndex = i;
+ }
+ },
+
+ _onMarkerDragStart: function (e) {
+ L.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e);
+
+ // Save a reference to the opposite point
+ 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;
+
+ // Reset move marker position to the center
+ if (marker === this._moveMarker) {
+ bounds = this._shape.getBounds();
+ center = bounds.getCenter();
+
+ marker.setLatLng(center);
+ }
+
+ this._toggleCornerMarkers(1);
+
+ this._repositionCornerMarkers();
+
+ L.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 = [];
+
+ // Offset the latlngs to the new center
+ 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]]);
+ }
+
+ this._shape.setLatLngs(newLatLngs);
+
+ // Reposition the resize markers
+ this._repositionCornerMarkers();
+
+ this._map.fire(L.Draw.Event.EDITMOVE, {layer: this._shape});
+ },
+
+ _resize: function (latlng) {
+ var bounds;
+
+ // Update the shape based on the current position of this corner and the opposite point
+ this._shape.setBounds(L.latLngBounds(latlng, this._oppositeCorner));
+
+ // Reposition the move marker
+ bounds = this._shape.getBounds();
+ this._moveMarker.setLatLng(bounds.getCenter());
+
+ this._map.fire(L.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]);
+ }
+ }
+});
+
+L.Rectangle.addInitHook(function () {
+ if (L.Edit.Rectangle) {
+ this.editing = new L.Edit.Rectangle(this);
+
+ if (this.options.editable) {
+ this.editing.enable();
+ }
+ }
+});
+
+
+
+L.Edit = L.Edit || {};
+/**
+ * @class L.Edit.CircleMarker
+ * @aka Edit.Circle
+ * @inherits L.Edit.SimpleShape
+ */
+L.Edit.CircleMarker = L.Edit.SimpleShape.extend({
+ _createMoveMarker: function () {
+ var center = this._shape.getLatLng();
+
+ this._moveMarker = this._createMarker(center, this.options.moveIcon);
+ },
+
+ _createResizeMarker: function () {
+ // To avoid an undefined check in L.Edit.SimpleShape.removeHooks
+ this._resizeMarkers = [];
+ },
+
+ _move: function (latlng) {
+ if (this._resizeMarkers.length) {
+ var resizemarkerPoint = this._getResizeMarkerPoint(latlng);
+ // Move the resize marker
+ this._resizeMarkers[0].setLatLng(resizemarkerPoint);
+ }
+
+ // Move the circle
+ this._shape.setLatLng(latlng);
+
+ this._map.fire(L.Draw.Event.EDITMOVE, {layer: this._shape});
+ },
+});
+
+L.CircleMarker.addInitHook(function () {
+ if (L.Edit.CircleMarker) {
+ this.editing = new L.Edit.CircleMarker(this);
+
+ if (this.options.editable) {
+ this.editing.enable();
+ }
+ }
+
+ 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();
+ }
+ });
+});
+
+
+
+L.Edit = L.Edit || {};
+/**
+ * @class L.Edit.Circle
+ * @aka Edit.Circle
+ * @inherits L.Edit.CircleMarker
+ */
+L.Edit.Circle = L.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) {
+ // From L.shape.getBounds()
+ 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();
+
+ // Calculate the radius based on the version
+ if (L.GeometryUtil.isVersion07x()) {
+ radius = moveLatLng.distanceTo(latlng);
+ } else {
+ radius = this._map.distance(moveLatLng, latlng);
+ }
+ this._shape.setRadius(radius);
+
+ if (this._map.editTooltip) {
+ this._map._editTooltip.updateContent({
+ text: L.drawLocal.edit.handlers.edit.tooltip.subtext + ' ' + L.drawLocal.edit.handlers.edit.tooltip.text,
+ subtext: L.drawLocal.draw.handlers.circle.radius + ': ' +
+ L.GeometryUtil.readableDistance(radius, true, this.options.feet, this.options.nautic)
+ });
+ }
+
+ this._shape.setRadius(radius);
+
+ this._map.fire(L.Draw.Event.EDITRESIZE, {layer: this._shape});
+ }
+});
+
+L.Circle.addInitHook(function () {
+ if (L.Edit.Circle) {
+ this.editing = new L.Edit.Circle(this);
+
+ if (this.options.editable) {
+ this.editing.enable();
+ }
+ }
+});
+
+
+
+L.Map.mergeOptions({
+ touchExtend: true
+});
+
+/**
+ * @class L.Map.TouchExtend
+ * @aka TouchExtend
+ */
+L.Map.TouchExtend = L.Handler.extend({
+
+ // @method initialize(): void
+ // Sets TouchExtend private accessor variables
+ initialize: function (map) {
+ this._map = map;
+ this._container = map._container;
+ this._pane = map._panes.overlayPane;
+ },
+
+ // @method addHooks(): void
+ // Adds dom listener events to the map container
+ addHooks: function () {
+ L.DomEvent.on(this._container, 'touchstart', this._onTouchStart, this);
+ L.DomEvent.on(this._container, 'touchend', this._onTouchEnd, this);
+ L.DomEvent.on(this._container, 'touchmove', this._onTouchMove, this);
+ if (this._detectIE()) {
+ L.DomEvent.on(this._container, 'MSPointerDown', this._onTouchStart, this);
+ L.DomEvent.on(this._container, 'MSPointerUp', this._onTouchEnd, this);
+ L.DomEvent.on(this._container, 'MSPointerMove', this._onTouchMove, this);
+ L.DomEvent.on(this._container, 'MSPointerCancel', this._onTouchCancel, this);
+
+ } else {
+ L.DomEvent.on(this._container, 'touchcancel', this._onTouchCancel, this);
+ L.DomEvent.on(this._container, 'touchleave', this._onTouchLeave, this);
+ }
+ },
+
+ // @method removeHooks(): void
+ // Removes dom listener events from the map container
+ removeHooks: function () {
+ L.DomEvent.off(this._container, 'touchstart', this._onTouchStart, this);
+ L.DomEvent.off(this._container, 'touchend', this._onTouchEnd, this);
+ L.DomEvent.off(this._container, 'touchmove', this._onTouchMove, this);
+ if (this._detectIE()) {
+ L.DomEvent.off(this._container, 'MSPointerDown', this._onTouchStart, this);
+ L.DomEvent.off(this._container, 'MSPointerUp', this._onTouchEnd, this);
+ L.DomEvent.off(this._container, 'MSPointerMove', this._onTouchMove, this);
+ L.DomEvent.off(this._container, 'MSPointerCancel', this._onTouchCancel, this);
+ } else {
+ L.DomEvent.off(this._container, 'touchcancel', this._onTouchCancel, this);
+ L.DomEvent.off(this._container, 'touchleave', this._onTouchLeave, this);
+ }
+ },
+
+ _touchEvent: function (e, type) {
+ // #TODO: fix the pageX error that is do a bug in Android where a single touch triggers two click events
+ // _filterClick is what leaflet uses as a workaround.
+ // This is a problem with more things than just android. Another problem is touchEnd has no touches in
+ // its touch list.
+ var touchEvent = {};
+ if (typeof e.touches !== 'undefined') {
+ if (!e.touches.length) {
+ return;
+ }
+ touchEvent = e.touches[0];
+ } else if (e.pointerType === 'touch') {
+ touchEvent = e;
+ if (!this._filterClick(e)) {
+ return;
+ }
+ } else {
+ return;
+ }
+
+ 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
+ });
+ },
+
+ /** Borrowed from Leaflet and modified for bool ops **/
+ _filterClick: function (e) {
+ var timeStamp = (e.timeStamp || e.originalEvent.timeStamp),
+ elapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick);
+
+ // are they closer together than 500ms yet more than 100ms?
+ // Android typically triggers them ~300ms apart while multiple listeners
+ // on the same event should be triggered far faster;
+ // or check if click is simulated on the element, and if it is, reject any non-simulated events
+ if ((elapsed && elapsed > 100 && elapsed < 500) || (e.target._simulatedClick && !e._simulated)) {
+ L.DomEvent.stop(e);
+ return false;
+ }
+ L.DomEvent._lastClick = timeStamp;
+ return true;
+ },
+
+ _onTouchStart: function (e) {
+ if (!this._map._loaded) {
+ return;
+ }
+
+ var type = 'touchstart';
+ this._touchEvent(e, type);
+
+ },
+
+ _onTouchEnd: function (e) {
+ if (!this._map._loaded) {
+ return;
+ }
+
+ var type = 'touchend';
+ this._touchEvent(e, type);
+ },
+
+ _onTouchCancel: function (e) {
+ if (!this._map._loaded) {
+ return;
+ }
+
+ var type = 'touchcancel';
+ if (this._detectIE()) {
+ type = 'pointercancel';
+ }
+ this._touchEvent(e, type);
+ },
+
+ _onTouchLeave: function (e) {
+ if (!this._map._loaded) {
+ return;
+ }
+
+ var type = 'touchleave';
+ this._touchEvent(e, type);
+ },
+
+ _onTouchMove: function (e) {
+ if (!this._map._loaded) {
+ return;
+ }
+
+ var type = 'touchmove';
+ this._touchEvent(e, type);
+ },
+
+ _detectIE: function () {
+ var ua = window.navigator.userAgent;
+
+ var msie = ua.indexOf('MSIE ');
+ if (msie > 0) {
+ // IE 10 or older => return version number
+ return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
+ }
+
+ var trident = ua.indexOf('Trident/');
+ if (trident > 0) {
+ // IE 11 => return version number
+ var rv = ua.indexOf('rv:');
+ return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
+ }
+
+ var edge = ua.indexOf('Edge/');
+ if (edge > 0) {
+ // IE 12 => return version number
+ return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
+ }
+
+ // other browser
+ return false;
+ }
+});
+
+L.Map.addInitHook('addHandler', 'touchExtend', L.Map.TouchExtend);
+
+
+/**
+ * @class L.Marker.Touch
+ * @aka Marker.Touch
+ *
+ * This isn't full Touch support. This is just to get markers to also support dom touch events after creation
+ * #TODO: find a better way of getting markers to support touch.
+ */
+L.Marker.Touch = L.Marker.extend({
+
+ _initInteraction: function () {
+ if (!this.addInteractiveTarget) {
+ // 0.7.x support
+ return this._initInteractionLegacy();
+ }
+ // TODO this may need be updated to re-add touch events for 1.0+
+ return L.Marker.prototype._initInteraction.apply(this);
+ },
+
+ // This is an exact copy of https://github.com/Leaflet/Leaflet/blob/v0.7/src/layer/marker/Marker.js
+ // with the addition of the touch events
+ _initInteractionLegacy: function () {
+
+ if (!this.options.clickable) {
+ return;
+ }
+
+ // TODO refactor into something shared with Map/Path/etc. to DRY it up
+
+ 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']);
+ }
+
+ L.DomUtil.addClass(icon, 'leaflet-clickable');
+ L.DomEvent.on(icon, 'click', this._onMouseClick, this);
+ L.DomEvent.on(icon, 'keypress', this._onKeyPress, this);
+
+ for (var i = 0; i < events.length; i++) {
+ L.DomEvent.on(icon, events[i], this._fireMouseEvent, this);
+ }
+
+ if (L.Handler.MarkerDrag) {
+ this.dragging = new L.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) {
+ // IE 10 or older => return version number
+ return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);
+ }
+
+ var trident = ua.indexOf('Trident/');
+ if (trident > 0) {
+ // IE 11 => return version number
+ var rv = ua.indexOf('rv:');
+ return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);
+ }
+
+ var edge = ua.indexOf('Edge/');
+ if (edge > 0) {
+ // IE 12 => return version number
+ return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);
+ }
+
+ // other browser
+ return false;
+ }
+});
+
+
+
+/**
+ * @class L.LatLngUtil
+ * @aka LatLngUtil
+ */
+L.LatLngUtil = {
+ // Clones a LatLngs[], returns [][]
+
+ // @method cloneLatLngs(LatLngs[]): L.LatLngs[]
+ // Clone the latLng point or points or nested points and return an array with those points
+ cloneLatLngs: function (latlngs) {
+ var clone = [];
+ for (var i = 0, l = latlngs.length; i < l; i++) {
+ // Check for nested array (Polyline/Polygon)
+ if (Array.isArray(latlngs[i])) {
+ clone.push(L.LatLngUtil.cloneLatLngs(latlngs[i]));
+ } else {
+ clone.push(this.cloneLatLng(latlngs[i]));
+ }
+ }
+ return clone;
+ },
+
+ // @method cloneLatLng(LatLng): L.LatLng
+ // Clone the latLng and return a new LatLng object.
+ cloneLatLng: function (latlng) {
+ return L.latLng(latlng.lat, latlng.lng);
+ }
+};
+
+
+
+(function () {
+
+ var defaultPrecision = {
+ km: 2,
+ ha: 2,
+ m: 0,
+ mi: 2,
+ ac: 2,
+ yd: 0,
+ ft: 0,
+ nm: 2
+ };
+
+
+ /**
+ * @class L.GeometryUtil
+ * @aka GeometryUtil
+ */
+ L.GeometryUtil = L.extend(L.GeometryUtil || {}, {
+ // Ported from the OpenLayers implementation. See https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Geometry/LinearRing.js#L270
+
+ // @method geodesicArea(): number
+ 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));
+ }
+ area = area * 6378137.0 * 6378137.0 / 2.0;
+ }
+
+ return Math.abs(area);
+ },
+
+ // @method formattedNumber(n, precision): string
+ // Returns n in specified number format (if defined) and precision
+ formattedNumber: function (n, precision) {
+ var formatted = parseFloat(n).toFixed(precision),
+ format = L.drawLocal.format && L.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];
+ }
+ }
+
+ return formatted;
+ },
+
+ // @method readableArea(area, isMetric, precision): string
+ // Returns a readable area string in yards or metric.
+ // The value will be rounded as defined by the precision option object.
+ readableArea: function (area, isMetric, precision) {
+ var areaStr,
+ units,
+ precision = L.Util.extend({}, defaultPrecision, precision);
+
+ if (isMetric) {
+ units = ['ha', 'm'];
+ type = typeof isMetric;
+ if (type === 'string') {
+ units = [isMetric];
+ } else if (type !== 'boolean') {
+ units = isMetric;
+ }
+
+ if (area >= 1000000 && units.indexOf('km') !== -1) {
+ areaStr = L.GeometryUtil.formattedNumber(area * 0.000001, precision['km']) + ' km²';
+ } else if (area >= 10000 && units.indexOf('ha') !== -1) {
+ areaStr = L.GeometryUtil.formattedNumber(area * 0.0001, precision['ha']) + ' ha';
+ } else {
+ areaStr = L.GeometryUtil.formattedNumber(area, precision['m']) + ' m²';
+ }
+ } else {
+ area /= 0.836127; // Square yards in 1 meter
+
+ if (area >= 3097600) { //3097600 square yards in 1 square mile
+ areaStr = L.GeometryUtil.formattedNumber(area / 3097600, precision['mi']) + ' mi²';
+ } else if (area >= 4840) { //4840 square yards in 1 acre
+ areaStr = L.GeometryUtil.formattedNumber(area / 4840, precision['ac']) + ' acres';
+ } else {
+ areaStr = L.GeometryUtil.formattedNumber(area, precision['yd']) + ' yd²';
+ }
+ }
+
+ return areaStr;
+ },
+
+ // @method readableDistance(distance, units): string
+ // Converts a metric distance to one of [ feet, nauticalMile, metric or yards ] string
+ //
+ // @alternative
+ // @method readableDistance(distance, isMetric, useFeet, isNauticalMile, precision): string
+ // Converts metric distance to distance string.
+ // The value will be rounded as defined by the precision option object.
+ readableDistance: function (distance, isMetric, isFeet, isNauticalMile, precision) {
+ var distanceStr,
+ units,
+ precision = L.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';
+ }
+
+ switch (units) {
+ case 'metric':
+ // show metres when distance is < 1km, then show km
+ if (distance > 1000) {
+ distanceStr = L.GeometryUtil.formattedNumber(distance / 1000, precision['km']) + ' km';
+ } else {
+ distanceStr = L.GeometryUtil.formattedNumber(distance, precision['m']) + ' m';
+ }
+ break;
+ case 'feet':
+ distance *= 1.09361 * 3;
+ distanceStr = L.GeometryUtil.formattedNumber(distance, precision['ft']) + ' ft';
+
+ break;
+ case 'nauticalMile':
+ distance *= 0.53996;
+ distanceStr = L.GeometryUtil.formattedNumber(distance / 1000, precision['nm']) + ' nm';
+ break;
+ case 'yards':
+ default:
+ distance *= 1.09361;
+
+ if (distance > 1760) {
+ distanceStr = L.GeometryUtil.formattedNumber(distance / 1760, precision['mi']) + ' miles';
+ } else {
+ distanceStr = L.GeometryUtil.formattedNumber(distance, precision['yd']) + ' yd';
+ }
+ break;
+ }
+ return distanceStr;
+ },
+
+ // @method isVersion07x(): boolean
+ // Returns true if the Leaflet version is 0.7.x, false otherwise.
+ isVersion07x: function () {
+ var version = L.version.split('.');
+ //If Version is == 0.7.*
+ return parseInt(version[0], 10) === 0 && parseInt(version[1], 10) === 7;
+ },
+ });
+
+})();
+
+
+
+/**
+ * @class L.LineUtil
+ * @aka Util
+ * @aka L.Utils
+ */
+L.Util.extend(L.LineUtil, {
+
+ // @method segmentsIntersect(): boolean
+ // Checks to see if two line segments intersect. Does not handle degenerate cases.
+ // http://compgeom.cs.uiuc.edu/~jeffe/teaching/373/notes/x06-sweepline.pdf
+ segmentsIntersect: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2, /*Point*/ p3) {
+ return this._checkCounterclockwise(p, p2, p3) !==
+ this._checkCounterclockwise(p1, p2, p3) &&
+ this._checkCounterclockwise(p, p1, p2) !==
+ this._checkCounterclockwise(p, p1, p3);
+ },
+
+ // check to see if points are in counterclockwise order
+ _checkCounterclockwise: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2) {
+ return (p2.y - p.y) * (p1.x - p.x) > (p1.y - p.y) * (p2.x - p.x);
+ }
+});
+
+
+
+/**
+ * @class L.Polyline
+ * @aka Polyline
+ */
+L.Polyline.include({
+
+ // @method intersects(): boolean
+ // Check to see if this polyline has any linesegments that intersect.
+ // NOTE: does not support detecting intersection for degenerate cases.
+ intersects: function () {
+ var points = this._getProjectedPoints(),
+ len = points ? points.length : 0,
+ i, p, p1;
+
+ if (this._tooFewPointsForIntersection()) {
+ return false;
+ }
+
+ for (i = len - 1; i >= 3; i--) {
+ p = points[i - 1];
+ p1 = points[i];
+
+
+ if (this._lineSegmentsIntersectsRange(p, p1, i - 2)) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ // @method newLatLngIntersects(): boolean
+ // Check for intersection if new latlng was added to this polyline.
+ // NOTE: does not support detecting intersection for degenerate cases.
+ newLatLngIntersects: function (latlng, skipFirst) {
+ // Cannot check a polyline for intersecting lats/lngs when not added to the map
+ if (!this._map) {
+ return false;
+ }
+
+ return this.newPointIntersects(this._map.latLngToLayerPoint(latlng), skipFirst);
+ },
+
+ // @method newPointIntersects(): boolean
+ // Check for intersection if new point was added to this polyline.
+ // newPoint must be a layer point.
+ // NOTE: does not support detecting intersection for degenerate cases.
+ newPointIntersects: function (newPoint, skipFirst) {
+ var points = this._getProjectedPoints(),
+ len = points ? points.length : 0,
+ lastPoint = points ? points[len - 1] : null,
+ // The previous previous line segment. Previous line segment doesn't need testing.
+ maxIndex = len - 2;
+
+ if (this._tooFewPointsForIntersection(1)) {
+ return false;
+ }
+
+ return this._lineSegmentsIntersectsRange(lastPoint, newPoint, maxIndex, skipFirst ? 1 : 0);
+ },
+
+ // Polylines with 2 sides can only intersect in cases where points are collinear (we don't support detecting these).
+ // Cannot have intersection when < 3 line segments (< 4 points)
+ _tooFewPointsForIntersection: function (extraPoints) {
+ var points = this._getProjectedPoints(),
+ len = points ? points.length : 0;
+ // Increment length by extraPoints if present
+ len += extraPoints || 0;
+
+ return !points || len <= 3;
+ },
+
+ // Checks a line segment intersections with any line segments before its predecessor.
+ // Don't need to check the predecessor as will never intersect.
+ _lineSegmentsIntersectsRange: function (p, p1, maxIndex, minIndex) {
+ var points = this._getProjectedPoints(),
+ p2, p3;
+
+ minIndex = minIndex || 0;
+
+ // Check all previous line segments (beside the immediately previous) for intersections
+ for (var j = maxIndex; j > minIndex; j--) {
+ p2 = points[j - 1];
+ p3 = points[j];
+
+ if (L.LineUtil.segmentsIntersect(p, p1, p2, p3)) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ _getProjectedPoints: function () {
+ if (!this._defaultShape) {
+ return this._originalPoints;
+ }
+ var points = [],
+ _shape = this._defaultShape();
+
+ for (var i = 0; i < _shape.length; i++) {
+ points.push(this._map.latLngToLayerPoint(_shape[i]));
+ }
+ return points;
+ }
+});
+
+
+
+/**
+ * @class L.Polygon
+ * @aka Polygon
+ */
+L.Polygon.include({
+
+ // @method intersects(): boolean
+ // Checks a polygon for any intersecting line segments. Ignores holes.
+ intersects: function () {
+ var polylineIntersects,
+ points = this._getProjectedPoints(),
+ len, firstPoint, lastPoint, maxIndex;
+
+ if (this._tooFewPointsForIntersection()) {
+ return false;
+ }
+
+ polylineIntersects = L.Polyline.prototype.intersects.call(this);
+
+ // If already found an intersection don't need to check for any more.
+ if (polylineIntersects) {
+ return true;
+ }
+
+ len = points.length;
+ firstPoint = points[0];
+ lastPoint = points[len - 1];
+ maxIndex = len - 2;
+
+ // Check the line segment between last and first point. Don't need to check the first line segment (minIndex = 1)
+ return this._lineSegmentsIntersectsRange(lastPoint, firstPoint, maxIndex, 1);
+ }
+});
+
+
+
+/**
+ * @class L.Control.Draw
+ * @aka L.Draw
+ */
+L.Control.Draw = L.Control.extend({
+
+ // Options
+ options: {
+ position: 'topleft',
+ draw: {},
+ edit: false
+ },
+
+ // @method initialize(): void
+ // Initializes draw control, toolbars from the options
+ initialize: function (options) {
+ if (L.version < '0.7') {
+ throw new Error('Leaflet.draw 0.2.3+ requires Leaflet 0.7.0+. Download latest from https://github.com/Leaflet/Leaflet/');
+ }
+
+ L.Control.prototype.initialize.call(this, options);
+
+ var toolbar;
+
+ this._toolbars = {};
+
+ // Initialize toolbars
+ if (L.DrawToolbar && this.options.draw) {
+ toolbar = new L.DrawToolbar(this.options.draw);
+
+ this._toolbars[L.DrawToolbar.TYPE] = toolbar;
+
+ // Listen for when toolbar is enabled
+ this._toolbars[L.DrawToolbar.TYPE].on('enable', this._toolbarEnabled, this);
+ }
+
+ if (L.EditToolbar && this.options.edit) {
+ toolbar = new L.EditToolbar(this.options.edit);
+
+ this._toolbars[L.EditToolbar.TYPE] = toolbar;
+
+ // Listen for when toolbar is enabled
+ this._toolbars[L.EditToolbar.TYPE].on('enable', this._toolbarEnabled, this);
+ }
+ L.toolbar = this; //set global var for editing the toolbar
+ },
+
+ // @method onAdd(): container
+ // Adds the toolbar container to the map
+ onAdd: function (map) {
+ var container = L.DomUtil.create('div', 'leaflet-draw'),
+ addedTopClass = false,
+ topClassName = 'leaflet-draw-toolbar-top',
+ toolbarContainer;
+
+ for (var toolbarId in this._toolbars) {
+ if (this._toolbars.hasOwnProperty(toolbarId)) {
+ toolbarContainer = this._toolbars[toolbarId].addToolbar(map);
+
+ if (toolbarContainer) {
+ // Add class to the first toolbar to remove the margin
+ if (!addedTopClass) {
+ if (!L.DomUtil.hasClass(toolbarContainer, topClassName)) {
+ L.DomUtil.addClass(toolbarContainer.childNodes[0], topClassName);
+ }
+ addedTopClass = true;
+ }
+
+ container.appendChild(toolbarContainer);
+ }
+ }
+ }
+
+ return container;
+ },
+
+ // @method onRemove(): void
+ // Removes the toolbars from the map toolbar container
+ onRemove: function () {
+ for (var toolbarId in this._toolbars) {
+ if (this._toolbars.hasOwnProperty(toolbarId)) {
+ this._toolbars[toolbarId].removeToolbar();
+ }
+ }
+ },
+
+ // @method setDrawingOptions(options): void
+ // Sets options to all toolbar instances
+ setDrawingOptions: function (options) {
+ for (var toolbarId in this._toolbars) {
+ if (this._toolbars[toolbarId] instanceof L.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();
+ }
+ }
+ }
+});
+
+L.Map.mergeOptions({
+ drawControlTooltips: true,
+ drawControl: false
+});
+
+L.Map.addInitHook(function () {
+ if (this.options.drawControl) {
+ this.drawControl = new L.Control.Draw();
+ this.addControl(this.drawControl);
+ }
+});
+
+
+
+/**
+ * @class L.Draw.Toolbar
+ * @aka Toolbar
+ *
+ * The toolbar class of the API — it is used to create the ui
+ * This will be depreciated
+ *
+ * @example
+ *
+ * ```js
+ * var toolbar = L.Toolbar();
+ * toolbar.addToolbar(map);
+ * ```
+ *
+ * ### Disabling a toolbar
+ *
+ * If you do not want a particular toolbar in your app you can turn it off by setting the toolbar to false.
+ *
+ * ```js
+ * var drawControl = new L.Control.Draw({
+ * draw: false,
+ * edit: {
+ * featureGroup: editableLayers
+ * }
+ * });
+ * ```
+ *
+ * ### Disabling a toolbar item
+ *
+ * If you want to turn off a particular toolbar item, set it to false. The following disables drawing polygons and
+ * markers. It also turns off the ability to edit layers.
+ *
+ * ```js
+ * var drawControl = new L.Control.Draw({
+ * draw: {
+ * polygon: false,
+ * marker: false
+ * },
+ * edit: {
+ * featureGroup: editableLayers,
+ * edit: false
+ * }
+ * });
+ * ```
+ */
+L.Toolbar = L.Class.extend({
+ // @section Methods for modifying the toolbar
+
+ // @method initialize(options): void
+ // Toolbar constructor
+ initialize: function (options) {
+ L.setOptions(this, options);
+
+ this._modes = {};
+ this._actionButtons = [];
+ this._activeMode = null;
+
+ var version = L.version.split('.');
+ //If Version is >= 1.2.0
+ if (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {
+ L.Toolbar.include(L.Evented.prototype);
+ } else {
+ L.Toolbar.include(L.Mixin.Events);
+ }
+ },
+
+ // @method enabled(): boolean
+ // Gets a true/false of whether the toolbar is enabled
+ enabled: function () {
+ return this._activeMode !== null;
+ },
+
+ // @method disable(): void
+ // Disables the toolbar
+ disable: function () {
+ if (!this.enabled()) {
+ return;
+ }
+
+ this._activeMode.handler.disable();
+ },
+
+ // @method addToolbar(map): L.DomUtil
+ // Adds the toolbar to the map and returns the toolbar dom element
+ addToolbar: function (map) {
+ var container = L.DomUtil.create('div', 'leaflet-draw-section'),
+ buttonIndex = 0,
+ buttonClassPrefix = this._toolbarClass || '',
+ modeHandlers = this.getModeHandlers(map),
+ i;
+
+ this._toolbarContainer = L.DomUtil.create('div', 'leaflet-draw-toolbar leaflet-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
+ );
+ }
+ }
+
+ // if no buttons were added, do not add the toolbar
+ if (!buttonIndex) {
+ return;
+ }
+
+ // Save button index of the last button, -1 as we would have ++ after the last button
+ this._lastButtonIndex = --buttonIndex;
+
+ // Create empty actions part of the toolbar
+ this._actionsContainer = L.DomUtil.create('ul', 'leaflet-draw-actions');
+
+ // Add draw and cancel containers to the control container
+ container.appendChild(this._toolbarContainer);
+ container.appendChild(this._actionsContainer);
+
+ return container;
+ },
+
+ // @method removeToolbar(): void
+ // Removes the toolbar and drops the handler event listeners
+ removeToolbar: function () {
+ // Dispose each handler
+ for (var handlerId in this._modes) {
+ if (this._modes.hasOwnProperty(handlerId)) {
+ // Unbind handler button
+ this._disposeButton(
+ this._modes[handlerId].button,
+ this._modes[handlerId].handler.enable,
+ this._modes[handlerId].handler
+ );
+
+ // Make sure is disabled
+ this._modes[handlerId].handler.disable();
+
+ // Unbind handler
+ this._modes[handlerId].handler
+ .off('enabled', this._handlerActivated, this)
+ .off('disabled', this._handlerDeactivated, this);
+ }
+ }
+ this._modes = {};
+
+ // Dispose the actions toolbar
+ for (var i = 0, l = this._actionButtons.length; i < l; i++) {
+ this._disposeButton(
+ this._actionButtons[i].button,
+ this._actionButtons[i].callback,
+ this
+ );
+ }
+ 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);
+ },
+
+ /* Detect iOS based on browser User Agent, based on:
+ * http://stackoverflow.com/a/9039885 */
+ _detectIOS: function () {
+ var iOS = (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream);
+ return iOS;
+ },
+
+ _createButton: function (options) {
+
+ var link = L.DomUtil.create('a', options.className || '', options.container);
+ // Screen reader tag
+ var sr = L.DomUtil.create('span', 'sr-only', options.container);
+
+ link.href = '#';
+ link.appendChild(sr);
+
+ if (options.title) {
+ link.title = options.title;
+ sr.innerHTML = options.title;
+ }
+
+ if (options.text) {
+ link.innerHTML = options.text;
+ sr.innerHTML = options.text;
+ }
+
+ /* iOS does not use click events */
+ var buttonEvent = this._detectIOS() ? 'touchstart' : 'click';
+
+ L.DomEvent
+ .on(link, 'click', L.DomEvent.stopPropagation)
+ .on(link, 'mousedown', L.DomEvent.stopPropagation)
+ .on(link, 'dblclick', L.DomEvent.stopPropagation)
+ .on(link, 'touchstart', L.DomEvent.stopPropagation)
+ .on(link, 'click', L.DomEvent.preventDefault)
+ .on(link, buttonEvent, options.callback, options.context);
+
+ return link;
+ },
+
+ _disposeButton: function (button, callback) {
+ /* iOS does not use click events */
+ var buttonEvent = this._detectIOS() ? 'touchstart' : 'click';
+
+ L.DomEvent
+ .off(button, 'click', L.DomEvent.stopPropagation)
+ .off(button, 'mousedown', L.DomEvent.stopPropagation)
+ .off(button, 'dblclick', L.DomEvent.stopPropagation)
+ .off(button, 'touchstart', L.DomEvent.stopPropagation)
+ .off(button, 'click', L.DomEvent.preventDefault)
+ .off(button, buttonEvent, callback);
+ },
+
+ _handlerActivated: function (e) {
+ // Disable active mode (if present)
+ this.disable();
+
+ // Cache new active feature
+ this._activeMode = this._modes[e.handler];
+
+ L.DomUtil.addClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled');
+
+ this._showActionsToolbar();
+
+ this.fire('enable');
+ },
+
+ _handlerDeactivated: function () {
+ this._hideActionsToolbar();
+
+ L.DomUtil.removeClass(this._activeMode.button, 'leaflet-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;
+
+ // Dispose the actions toolbar (todo: dispose only not used buttons)
+ for (di = 0, dl = this._actionButtons.length; di < dl; di++) {
+ this._disposeButton(this._actionButtons[di].button, this._actionButtons[di].callback);
+ }
+ this._actionButtons = [];
+
+ // Remove all old buttons
+ while (container.firstChild) {
+ container.removeChild(container.firstChild);
+ }
+
+ for (var i = 0; i < l; i++) {
+ if ('enabled' in buttons[i] && !buttons[i].enabled) {
+ continue;
+ }
+
+ li = L.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;
+
+ // Recreate action buttons on every click
+ this._createActions(this._activeMode.handler);
+
+ // Correctly position the cancel button
+ this._actionsContainer.style.top = toolbarPosition + 'px';
+
+ if (buttonIndex === 0) {
+ L.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop');
+ L.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-top');
+ }
+
+ if (buttonIndex === lastButtonIndex) {
+ L.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom');
+ L.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-bottom');
+ }
+
+ this._actionsContainer.style.display = 'block';
+ this._map.fire(L.Draw.Event.TOOLBAROPENED);
+ },
+
+ _hideActionsToolbar: function () {
+ this._actionsContainer.style.display = 'none';
+
+ L.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop');
+ L.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom');
+ L.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-top');
+ L.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-bottom');
+ this._map.fire(L.Draw.Event.TOOLBARCLOSED);
+ }
+});
+
+
+
+L.Draw = L.Draw || {};
+/**
+ * @class L.Draw.Tooltip
+ * @aka Tooltip
+ *
+ * The tooltip class — it is used to display the tooltip while drawing
+ * This will be depreciated
+ *
+ * @example
+ *
+ * ```js
+ * var tooltip = L.Draw.Tooltip();
+ * ```
+ *
+ */
+L.Draw.Tooltip = L.Class.extend({
+
+ // @section Methods for modifying draw state
+
+ // @method initialize(map): void
+ // Tooltip constructor
+ initialize: function (map) {
+ this._map = map;
+ this._popupPane = map._panes.popupPane;
+ this._visible = false;
+
+ this._container = map.options.drawControlTooltips ?
+ L.DomUtil.create('div', 'leaflet-draw-tooltip', this._popupPane) : null;
+ this._singleLineLabel = false;
+
+ this._map.on('mouseout', this._onMouseOut, this);
+ },
+
+ // @method dispose(): void
+ // Remove Tooltip DOM and unbind events
+ dispose: function () {
+ this._map.off('mouseout', this._onMouseOut, this);
+
+ if (this._container) {
+ this._popupPane.removeChild(this._container);
+ this._container = null;
+ }
+ },
+
+ // @method updateContent(labelText): this
+ // Changes the tooltip text to string in function call
+ updateContent: function (labelText) {
+ if (!this._container) {
+ return this;
+ }
+ labelText.subtext = labelText.subtext || '';
+
+ // update the vertical position (only if changed)
+ if (labelText.subtext.length === 0 && !this._singleLineLabel) {
+ L.DomUtil.addClass(this._container, 'leaflet-draw-tooltip-single');
+ this._singleLineLabel = true;
+ }
+ else if (labelText.subtext.length > 0 && this._singleLineLabel) {
+ L.DomUtil.removeClass(this._container, 'leaflet-draw-tooltip-single');
+ this._singleLineLabel = false;
+ }
+
+ this._container.innerHTML =
+ (labelText.subtext.length > 0 ?
+ '' + labelText.subtext + ' ' + ' ' : '') +
+ '' + labelText.text + ' ';
+
+ if (!labelText.text && !labelText.subtext) {
+ this._visible = false;
+ this._container.style.visibility = 'hidden';
+ } else {
+ this._visible = true;
+ this._container.style.visibility = 'inherit';
+ }
+
+ return this;
+ },
+
+ // @method updatePosition(latlng): this
+ // Changes the location of the tooltip
+ updatePosition: function (latlng) {
+ var pos = this._map.latLngToLayerPoint(latlng),
+ tooltipContainer = this._container;
+
+ if (this._container) {
+ if (this._visible) {
+ tooltipContainer.style.visibility = 'inherit';
+ }
+ L.DomUtil.setPosition(tooltipContainer, pos);
+ }
+
+ return this;
+ },
+
+ // @method showAsError(): this
+ // Applies error class to tooltip
+ showAsError: function () {
+ if (this._container) {
+ L.DomUtil.addClass(this._container, 'leaflet-error-draw-tooltip');
+ }
+ return this;
+ },
+
+ // @method removeError(): this
+ // Removes the error class from the tooltip
+ removeError: function () {
+ if (this._container) {
+ L.DomUtil.removeClass(this._container, 'leaflet-error-draw-tooltip');
+ }
+ return this;
+ },
+
+ _onMouseOut: function () {
+ if (this._container) {
+ this._container.style.visibility = 'hidden';
+ }
+ }
+});
+
+
+
+/**
+ * @class L.DrawToolbar
+ * @aka Toolbar
+ */
+L.DrawToolbar = L.Toolbar.extend({
+
+ statics: {
+ TYPE: 'draw'
+ },
+
+ options: {
+ polyline: {},
+ polygon: {},
+ rectangle: {},
+ circle: {},
+ marker: {},
+ circlemarker: {}
+ },
+
+ // @method initialize(): void
+ initialize: function (options) {
+ // Ensure that the options are merged correctly since L.extend is only shallow
+ for (var type in this.options) {
+ if (this.options.hasOwnProperty(type)) {
+ if (options[type]) {
+ options[type] = L.extend({}, this.options[type], options[type]);
+ }
+ }
+ }
+
+ this._toolbarClass = 'leaflet-draw-draw';
+ L.Toolbar.prototype.initialize.call(this, options);
+ },
+
+ // @method getModeHandlers(): object
+ // Get mode handlers information
+ getModeHandlers: function (map) {
+ return [
+ {
+ enabled: this.options.polyline,
+ handler: new L.Draw.Polyline(map, this.options.polyline),
+ title: L.drawLocal.draw.toolbar.buttons.polyline
+ },
+ {
+ enabled: this.options.polygon,
+ handler: new L.Draw.Polygon(map, this.options.polygon),
+ title: L.drawLocal.draw.toolbar.buttons.polygon
+ },
+ {
+ enabled: this.options.rectangle,
+ handler: new L.Draw.Rectangle(map, this.options.rectangle),
+ title: L.drawLocal.draw.toolbar.buttons.rectangle
+ },
+ {
+ enabled: this.options.circle,
+ handler: new L.Draw.Circle(map, this.options.circle),
+ title: L.drawLocal.draw.toolbar.buttons.circle
+ },
+ {
+ enabled: this.options.marker,
+ handler: new L.Draw.Marker(map, this.options.marker),
+ title: L.drawLocal.draw.toolbar.buttons.marker
+ },
+ {
+ enabled: this.options.circlemarker,
+ handler: new L.Draw.CircleMarker(map, this.options.circlemarker),
+ title: L.drawLocal.draw.toolbar.buttons.circlemarker
+ }
+ ];
+ },
+
+ // @method getActions(): object
+ // Get action information
+ getActions: function (handler) {
+ return [
+ {
+ enabled: handler.completeShape,
+ title: L.drawLocal.draw.toolbar.finish.title,
+ text: L.drawLocal.draw.toolbar.finish.text,
+ callback: handler.completeShape,
+ context: handler
+ },
+ {
+ enabled: handler.deleteLastVertex,
+ title: L.drawLocal.draw.toolbar.undo.title,
+ text: L.drawLocal.draw.toolbar.undo.text,
+ callback: handler.deleteLastVertex,
+ context: handler
+ },
+ {
+ title: L.drawLocal.draw.toolbar.actions.title,
+ text: L.drawLocal.draw.toolbar.actions.text,
+ callback: this.disable,
+ context: this
+ }
+ ];
+ },
+
+ // @method setOptions(): void
+ // Sets the options to the toolbar
+ setOptions: function (options) {
+ L.setOptions(this, options);
+
+ for (var type in this._modes) {
+ if (this._modes.hasOwnProperty(type) && options.hasOwnProperty(type)) {
+ this._modes[type].handler.setOptions(options[type]);
+ }
+ }
+ }
+});
+
+
+
+/*L.Map.mergeOptions({
+ editControl: true
+ });*/
+/**
+ * @class L.EditToolbar
+ * @aka EditToolbar
+ */
+L.EditToolbar = L.Toolbar.extend({
+ statics: {
+ TYPE: 'edit'
+ },
+
+ options: {
+ edit: {
+ selectedPathOptions: {
+ dashArray: '10, 10',
+
+ fill: true,
+ fillColor: '#fe57a1',
+ fillOpacity: 0.1,
+
+ // Whether to user the existing layers color
+ maintainColor: false
+ }
+ },
+ remove: {},
+ poly: null,
+ featureGroup: null /* REQUIRED! TODO: perhaps if not set then all layers on the map are selectable? */
+ },
+
+ // @method intialize(): void
+ initialize: function (options) {
+ // Need to set this manually since null is an acceptable value here
+ if (options.edit) {
+ if (typeof options.edit.selectedPathOptions === 'undefined') {
+ options.edit.selectedPathOptions = this.options.edit.selectedPathOptions;
+ }
+ options.edit.selectedPathOptions = L.extend({}, this.options.edit.selectedPathOptions, options.edit.selectedPathOptions);
+ }
+
+ if (options.remove) {
+ options.remove = L.extend({}, this.options.remove, options.remove);
+ }
+
+ if (options.poly) {
+ options.poly = L.extend({}, this.options.poly, options.poly);
+ }
+
+ this._toolbarClass = 'leaflet-draw-edit';
+ L.Toolbar.prototype.initialize.call(this, options);
+
+ this._selectedFeatureCount = 0;
+ },
+
+ // @method getModeHandlers(): object
+ // Get mode handlers information
+ getModeHandlers: function (map) {
+ var featureGroup = this.options.featureGroup;
+ return [
+ {
+ enabled: this.options.edit,
+ handler: new L.EditToolbar.Edit(map, {
+ featureGroup: featureGroup,
+ selectedPathOptions: this.options.edit.selectedPathOptions,
+ poly: this.options.poly
+ }),
+ title: L.drawLocal.edit.toolbar.buttons.edit
+ },
+ {
+ enabled: this.options.remove,
+ handler: new L.EditToolbar.Delete(map, {
+ featureGroup: featureGroup
+ }),
+ title: L.drawLocal.edit.toolbar.buttons.remove
+ }
+ ];
+ },
+
+ // @method getActions(): object
+ // Get actions information
+ getActions: function (handler) {
+ var actions = [
+ {
+ title: L.drawLocal.edit.toolbar.actions.save.title,
+ text: L.drawLocal.edit.toolbar.actions.save.text,
+ callback: this._save,
+ context: this
+ },
+ {
+ title: L.drawLocal.edit.toolbar.actions.cancel.title,
+ text: L.drawLocal.edit.toolbar.actions.cancel.text,
+ callback: this.disable,
+ context: this
+ }
+ ];
+
+ if (handler.removeAllLayers) {
+ actions.push({
+ title: L.drawLocal.edit.toolbar.actions.clearAll.title,
+ text: L.drawLocal.edit.toolbar.actions.clearAll.text,
+ callback: this._clearAllLayers,
+ context: this
+ });
+ }
+
+ return actions;
+ },
+
+ // @method addToolbar(map): L.DomUtil
+ // Adds the toolbar to the map
+ addToolbar: function (map) {
+ var container = L.Toolbar.prototype.addToolbar.call(this, map);
+
+ this._checkDisabled();
+
+ this.options.featureGroup.on('layeradd layerremove', this._checkDisabled, this);
+
+ return container;
+ },
+
+ // @method removeToolbar(): void
+ // Removes the toolbar from the map
+ removeToolbar: function () {
+ this.options.featureGroup.off('layeradd layerremove', this._checkDisabled, this);
+
+ L.Toolbar.prototype.removeToolbar.call(this);
+ },
+
+ // @method disable(): void
+ // Disables the toolbar
+ disable: function () {
+ if (!this.enabled()) {
+ return;
+ }
+
+ this._activeMode.handler.revertLayers();
+
+ L.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[L.EditToolbar.Edit.TYPE].button;
+
+ if (hasLayers) {
+ L.DomUtil.removeClass(button, 'leaflet-disabled');
+ } else {
+ L.DomUtil.addClass(button, 'leaflet-disabled');
+ }
+
+ button.setAttribute(
+ 'title',
+ hasLayers ?
+ L.drawLocal.edit.toolbar.buttons.edit
+ : L.drawLocal.edit.toolbar.buttons.editDisabled
+ );
+ }
+
+ if (this.options.remove) {
+ button = this._modes[L.EditToolbar.Delete.TYPE].button;
+
+ if (hasLayers) {
+ L.DomUtil.removeClass(button, 'leaflet-disabled');
+ } else {
+ L.DomUtil.addClass(button, 'leaflet-disabled');
+ }
+
+ button.setAttribute(
+ 'title',
+ hasLayers ?
+ L.drawLocal.edit.toolbar.buttons.remove
+ : L.drawLocal.edit.toolbar.buttons.removeDisabled
+ );
+ }
+ }
+});
+
+
+
+/**
+ * @class L.EditToolbar.Edit
+ * @aka EditToolbar.Edit
+ */
+L.EditToolbar.Edit = L.Handler.extend({
+ statics: {
+ TYPE: 'edit'
+ },
+
+ // @method intialize(): void
+ initialize: function (map, options) {
+ L.Handler.prototype.initialize.call(this, map);
+
+ L.setOptions(this, options);
+
+ // Store the selectable layer group for ease of access
+ this._featureGroup = options.featureGroup;
+
+ if (!(this._featureGroup instanceof L.FeatureGroup)) {
+ throw new Error('options.featureGroup must be a L.FeatureGroup');
+ }
+
+ this._uneditedLayerProps = {};
+
+ // Save the type so super can fire, need to do this as cannot do this.TYPE :(
+ this.type = L.EditToolbar.Edit.TYPE;
+
+ var version = L.version.split('.');
+ //If Version is >= 1.2.0
+ if (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {
+ L.EditToolbar.Edit.include(L.Evented.prototype);
+ } else {
+ L.EditToolbar.Edit.include(L.Mixin.Events);
+ }
+ },
+
+ // @method enable(): void
+ // Enable the edit toolbar
+ enable: function () {
+ if (this._enabled || !this._hasAvailableLayers()) {
+ return;
+ }
+ this.fire('enabled', {handler: this.type});
+ //this disable other handlers
+
+ this._map.fire(L.Draw.Event.EDITSTART, {handler: this.type});
+ //allow drawLayer to be updated before beginning edition.
+
+ L.Handler.prototype.enable.call(this);
+ this._featureGroup
+ .on('layeradd', this._enableLayerEdit, this)
+ .on('layerremove', this._disableLayerEdit, this);
+ },
+
+ // @method disable(): void
+ // Disable the edit toolbar
+ disable: function () {
+ if (!this._enabled) {
+ return;
+ }
+ this._featureGroup
+ .off('layeradd', this._enableLayerEdit, this)
+ .off('layerremove', this._disableLayerEdit, this);
+ L.Handler.prototype.disable.call(this);
+ this._map.fire(L.Draw.Event.EDITSTOP, {handler: this.type});
+ this.fire('disabled', {handler: this.type});
+ },
+
+ // @method addHooks(): void
+ // Add listener hooks for this handler
+ addHooks: function () {
+ var map = this._map;
+
+ if (map) {
+ map.getContainer().focus();
+
+ this._featureGroup.eachLayer(this._enableLayerEdit, this);
+
+ this._tooltip = new L.Draw.Tooltip(this._map);
+ this._tooltip.updateContent({
+ text: L.drawLocal.edit.handlers.edit.tooltip.text,
+ subtext: L.drawLocal.edit.handlers.edit.tooltip.subtext
+ });
+
+ // Quickly access the tooltip to update for intersection checking
+ map._editTooltip = this._tooltip;
+
+ this._updateTooltip();
+
+ this._map
+ .on('mousemove', this._onMouseMove, this)
+ .on('touchmove', this._onMouseMove, this)
+ .on('MSPointerMove', this._onMouseMove, this)
+ .on(L.Draw.Event.EDITVERTEX, this._updateTooltip, this);
+ }
+ },
+
+ // @method removeHooks(): void
+ // Remove listener hooks for this handler
+ removeHooks: function () {
+ if (this._map) {
+ // Clean up selected layers.
+ this._featureGroup.eachLayer(this._disableLayerEdit, this);
+
+ // Clear the backups of the original layers
+ 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(L.Draw.Event.EDITVERTEX, this._updateTooltip, this);
+ }
+ },
+
+ // @method revertLayers(): void
+ // Revert each layer's geometry changes
+ revertLayers: function () {
+ this._featureGroup.eachLayer(function (layer) {
+ this._revertLayer(layer);
+ }, this);
+ },
+
+ // @method save(): void
+ // Save the layer geometries
+ save: function () {
+ var editedLayers = new L.LayerGroup();
+ this._featureGroup.eachLayer(function (layer) {
+ if (layer.edited) {
+ editedLayers.addLayer(layer);
+ layer.edited = false;
+ }
+ });
+ this._map.fire(L.Draw.Event.EDITED, {layers: editedLayers});
+ },
+
+ _backupLayer: function (layer) {
+ var id = L.Util.stamp(layer);
+
+ if (!this._uneditedLayerProps[id]) {
+ // Polyline, Polygon or Rectangle
+ if (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) {
+ this._uneditedLayerProps[id] = {
+ latlngs: L.LatLngUtil.cloneLatLngs(layer.getLatLngs())
+ };
+ } else if (layer instanceof L.Circle) {
+ this._uneditedLayerProps[id] = {
+ latlng: L.LatLngUtil.cloneLatLng(layer.getLatLng()),
+ radius: layer.getRadius()
+ };
+ } else if (layer instanceof L.Marker || layer instanceof L.CircleMarker) { // Marker
+ this._uneditedLayerProps[id] = {
+ latlng: L.LatLngUtil.cloneLatLng(layer.getLatLng())
+ };
+ }
+ }
+ },
+
+ _getTooltipText: function () {
+ return ({
+ text: L.drawLocal.edit.handlers.edit.tooltip.text,
+ subtext: L.drawLocal.edit.handlers.edit.tooltip.subtext
+ });
+ },
+
+ _updateTooltip: function () {
+ this._tooltip.updateContent(this._getTooltipText());
+ },
+
+ _revertLayer: function (layer) {
+ var id = L.Util.stamp(layer);
+ layer.edited = false;
+ if (this._uneditedLayerProps.hasOwnProperty(id)) {
+ // Polyline, Polygon or Rectangle
+ if (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) {
+ layer.setLatLngs(this._uneditedLayerProps[id].latlngs);
+ } else if (layer instanceof L.Circle) {
+ layer.setLatLng(this._uneditedLayerProps[id].latlng);
+ layer.setRadius(this._uneditedLayerProps[id].radius);
+ } else if (layer instanceof L.Marker || layer instanceof L.CircleMarker) { // Marker or CircleMarker
+ layer.setLatLng(this._uneditedLayerProps[id].latlng);
+ }
+
+ layer.fire('revert-edited', {layer: layer});
+ }
+ },
+
+ _enableLayerEdit: function (e) {
+ var layer = e.layer || e.target || e,
+ pathOptions, poly;
+
+ // Back up this layer (if haven't before)
+ this._backupLayer(layer);
+
+ if (this.options.poly) {
+ poly = L.Util.extend({}, this.options.poly);
+ layer.options.poly = poly;
+ }
+
+ // Set different style for editing mode
+ if (this.options.selectedPathOptions) {
+ pathOptions = L.Util.extend({}, this.options.selectedPathOptions);
+
+ // Use the existing color of the layer
+ if (pathOptions.maintainColor) {
+ pathOptions.color = layer.options.color;
+ pathOptions.fillColor = layer.options.fillColor;
+ }
+
+ layer.options.original = L.extend({}, layer.options);
+ layer.options.editing = pathOptions;
+
+ }
+
+ if (layer instanceof L.Marker) {
+ if (layer.editing) {
+ layer.editing.enable();
+ }
+ layer.dragging.enable();
+ layer
+ .on('dragend', this._onMarkerDragEnd)
+ // #TODO: remove when leaflet finally fixes their draggable so it's touch friendly again.
+ .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();
+ }
+
+ delete layer.options.editing;
+ delete layer.options.original;
+ // Reset layer styles to that of before select
+ if (this._selectedPathOptions) {
+ if (layer instanceof L.Marker) {
+ this._toggleMarkerHighlight(layer);
+ } else {
+ // reset the layer style to what is was before being selected
+ layer.setStyle(layer.options.previousOptions);
+ // remove the cached options for the layer object
+ delete layer.options.previousOptions;
+ }
+ }
+
+ if (layer instanceof L.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(L.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;
+ }
+});
+
+
+
+/**
+ * @class L.EditToolbar.Delete
+ * @aka EditToolbar.Delete
+ */
+L.EditToolbar.Delete = L.Handler.extend({
+ statics: {
+ TYPE: 'remove' // not delete as delete is reserved in js
+ },
+
+ // @method intialize(): void
+ initialize: function (map, options) {
+ L.Handler.prototype.initialize.call(this, map);
+
+ L.Util.setOptions(this, options);
+
+ // Store the selectable layer group for ease of access
+ this._deletableLayers = this.options.featureGroup;
+
+ if (!(this._deletableLayers instanceof L.FeatureGroup)) {
+ throw new Error('options.featureGroup must be a L.FeatureGroup');
+ }
+
+ // Save the type so super can fire, need to do this as cannot do this.TYPE :(
+ this.type = L.EditToolbar.Delete.TYPE;
+
+ var version = L.version.split('.');
+ //If Version is >= 1.2.0
+ if (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {
+ L.EditToolbar.Delete.include(L.Evented.prototype);
+ } else {
+ L.EditToolbar.Delete.include(L.Mixin.Events);
+ }
+
+ },
+
+ // @method enable(): void
+ // Enable the delete toolbar
+ enable: function () {
+ if (this._enabled || !this._hasAvailableLayers()) {
+ return;
+ }
+ this.fire('enabled', {handler: this.type});
+
+ this._map.fire(L.Draw.Event.DELETESTART, {handler: this.type});
+
+ L.Handler.prototype.enable.call(this);
+
+ this._deletableLayers
+ .on('layeradd', this._enableLayerDelete, this)
+ .on('layerremove', this._disableLayerDelete, this);
+ },
+
+ // @method disable(): void
+ // Disable the delete toolbar
+ disable: function () {
+ if (!this._enabled) {
+ return;
+ }
+
+ this._deletableLayers
+ .off('layeradd', this._enableLayerDelete, this)
+ .off('layerremove', this._disableLayerDelete, this);
+
+ L.Handler.prototype.disable.call(this);
+
+ this._map.fire(L.Draw.Event.DELETESTOP, {handler: this.type});
+
+ this.fire('disabled', {handler: this.type});
+ },
+
+ // @method addHooks(): void
+ // Add listener hooks to this handler
+ addHooks: function () {
+ var map = this._map;
+
+ if (map) {
+ map.getContainer().focus();
+
+ this._deletableLayers.eachLayer(this._enableLayerDelete, this);
+ this._deletedLayers = new L.LayerGroup();
+
+ this._tooltip = new L.Draw.Tooltip(this._map);
+ this._tooltip.updateContent({text: L.drawLocal.edit.handlers.remove.tooltip.text});
+
+ this._map.on('mousemove', this._onMouseMove, this);
+ }
+ },
+
+ // @method removeHooks(): void
+ // Remove listener hooks from this handler
+ 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);
+ }
+ },
+
+ // @method revertLayers(): void
+ // Revert the deleted layers back to their prior state.
+ revertLayers: function () {
+ // Iterate of the deleted layers and add them back into the featureGroup
+ this._deletedLayers.eachLayer(function (layer) {
+ this._deletableLayers.addLayer(layer);
+ layer.fire('revert-deleted', {layer: layer});
+ }, this);
+ },
+
+ // @method save(): void
+ // Save deleted layers
+ save: function () {
+ this._map.fire(L.Draw.Event.DELETED, {layers: this._deletedLayers});
+ },
+
+ // @method removeAllLayers(): void
+ // Remove all delateable layers
+ removeAllLayers: function () {
+ // Iterate of the delateable layers and add remove them
+ 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);
+
+ // Remove from the deleted layers so we can't accidentally revert if the user presses cancel
+ 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;
+ }
+});
+
+
+
+}(window, document));
+//# sourceMappingURL=leaflet.draw-src.map
\ No newline at end of file
diff --git a/node_modules/leaflet-draw/dist/leaflet.draw-src.map b/node_modules/leaflet-draw/dist/leaflet.draw-src.map
new file mode 100644
index 00000000..53d78238
--- /dev/null
+++ b/node_modules/leaflet-draw/dist/leaflet.draw-src.map
@@ -0,0 +1 @@
+{"version":3,"sources":["src/Leaflet.draw.js","src/Leaflet.Draw.Event.js","src/draw/handler/Draw.Feature.js","src/draw/handler/Draw.Polyline.js","src/draw/handler/Draw.Polygon.js","src/draw/handler/Draw.SimpleShape.js","src/draw/handler/Draw.Rectangle.js","src/draw/handler/Draw.Marker.js","src/draw/handler/Draw.CircleMarker.js","src/draw/handler/Draw.Circle.js","src/edit/handler/Edit.Marker.js","src/edit/handler/Edit.Poly.js","src/edit/handler/Edit.SimpleShape.js","src/edit/handler/Edit.Rectangle.js","src/edit/handler/Edit.CircleMarker.js","src/edit/handler/Edit.Circle.js","src/ext/TouchEvents.js","src/ext/LatLngUtil.js","src/ext/GeometryUtil.js","src/ext/LineUtil.Intersect.js","src/ext/Polyline.Intersect.js","src/ext/Polygon.Intersect.js","src/Control.Draw.js","src/Toolbar.js","src/Tooltip.js","src/draw/DrawToolbar.js","src/edit/EditToolbar.js","src/edit/handler/EditToolbar.Edit.js","src/edit/handler/EditToolbar.Delete.js"],"names":[],"mappings":";;;;;;;yCAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7LA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChLA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACxGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChlBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACjIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACvHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AClGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC/HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1CA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACnFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACpFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACxgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC7HA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACzDA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AChRA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC5BA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACrKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC1GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACjCA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC9UA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;ACtHA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AC9GA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AClMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;AClSA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","sourcesContent":["/**\n * Leaflet.draw assumes that you have already included the Leaflet library.\n */\nL.drawVersion = \"1.0.4\";\n/**\n * @class L.Draw\n * @aka Draw\n *\n *\n * To add the draw toolbar set the option drawControl: true in the map options.\n *\n * @example\n * ```js\n * var map = L.map('map', {drawControl: true}).setView([51.505, -0.09], 13);\n *\n * L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {\n * attribution: '© OpenStreetMap contributors'\n * }).addTo(map);\n * ```\n *\n * ### Adding the edit toolbar\n * To use the edit toolbar you must initialise the Leaflet.draw control and manually add it to the map.\n *\n * ```js\n * var map = L.map('map').setView([51.505, -0.09], 13);\n *\n * L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {\n * attribution: '© OpenStreetMap contributors'\n * }).addTo(map);\n *\n * // FeatureGroup is to store editable layers\n * var drawnItems = new L.FeatureGroup();\n * map.addLayer(drawnItems);\n *\n * var drawControl = new L.Control.Draw({\n * edit: {\n * featureGroup: drawnItems\n * }\n * });\n * map.addControl(drawControl);\n * ```\n *\n * The key here is the featureGroup option. This tells the plugin which FeatureGroup contains the layers that\n * should be editable. The featureGroup can contain 0 or more features with geometry types Point, LineString, and Polygon.\n * Leaflet.draw does not work with multigeometry features such as MultiPoint, MultiLineString, MultiPolygon,\n * or GeometryCollection. If you need to add multigeometry features to the draw plugin, convert them to a\n * FeatureCollection of non-multigeometries (Points, LineStrings, or Polygons).\n */\nL.Draw = {};\n\n/**\n * @class L.drawLocal\n * @aka L.drawLocal\n *\n * The core toolbar class of the API — it is used to create the toolbar ui\n *\n * @example\n * ```js\n * var modifiedDraw = L.drawLocal.extend({\n * draw: {\n * toolbar: {\n * buttons: {\n * polygon: 'Draw an awesome polygon'\n * }\n * }\n * }\n * });\n * ```\n *\n * The default state for the control is the draw toolbar just below the zoom control.\n * This will allow map users to draw vectors and markers.\n * **Please note the edit toolbar is not enabled by default.**\n */\nL.drawLocal = {\n\t// format: {\n\t// \tnumeric: {\n\t// \t\tdelimiters: {\n\t// \t\t\tthousands: ',',\n\t// \t\t\tdecimal: '.'\n\t// \t\t}\n\t// \t}\n\t// },\n\tdraw: {\n\t\ttoolbar: {\n\t\t\t// #TODO: this should be reorganized where actions are nested in actions\n\t\t\t// ex: actions.undo or actions.cancel\n\t\t\tactions: {\n\t\t\t\ttitle: 'Cancel drawing',\n\t\t\t\ttext: 'Cancel'\n\t\t\t},\n\t\t\tfinish: {\n\t\t\t\ttitle: 'Finish drawing',\n\t\t\t\ttext: 'Finish'\n\t\t\t},\n\t\t\tundo: {\n\t\t\t\ttitle: 'Delete last point drawn',\n\t\t\t\ttext: 'Delete last point'\n\t\t\t},\n\t\t\tbuttons: {\n\t\t\t\tpolyline: 'Draw a polyline',\n\t\t\t\tpolygon: 'Draw a polygon',\n\t\t\t\trectangle: 'Draw a rectangle',\n\t\t\t\tcircle: 'Draw a circle',\n\t\t\t\tmarker: 'Draw a marker',\n\t\t\t\tcirclemarker: 'Draw a circlemarker'\n\t\t\t}\n\t\t},\n\t\thandlers: {\n\t\t\tcircle: {\n\t\t\t\ttooltip: {\n\t\t\t\t\tstart: 'Click and drag to draw circle.'\n\t\t\t\t},\n\t\t\t\tradius: 'Radius'\n\t\t\t},\n\t\t\tcirclemarker: {\n\t\t\t\ttooltip: {\n\t\t\t\t\tstart: 'Click map to place circle marker.'\n\t\t\t\t}\n\t\t\t},\n\t\t\tmarker: {\n\t\t\t\ttooltip: {\n\t\t\t\t\tstart: 'Click map to place marker.'\n\t\t\t\t}\n\t\t\t},\n\t\t\tpolygon: {\n\t\t\t\ttooltip: {\n\t\t\t\t\tstart: 'Click to start drawing shape.',\n\t\t\t\t\tcont: 'Click to continue drawing shape.',\n\t\t\t\t\tend: 'Click first point to close this shape.'\n\t\t\t\t}\n\t\t\t},\n\t\t\tpolyline: {\n\t\t\t\terror: 'Error: shape edges cannot cross!',\n\t\t\t\ttooltip: {\n\t\t\t\t\tstart: 'Click to start drawing line.',\n\t\t\t\t\tcont: 'Click to continue drawing line.',\n\t\t\t\t\tend: 'Click last point to finish line.'\n\t\t\t\t}\n\t\t\t},\n\t\t\trectangle: {\n\t\t\t\ttooltip: {\n\t\t\t\t\tstart: 'Click and drag to draw rectangle.'\n\t\t\t\t}\n\t\t\t},\n\t\t\tsimpleshape: {\n\t\t\t\ttooltip: {\n\t\t\t\t\tend: 'Release mouse to finish drawing.'\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t},\n\tedit: {\n\t\ttoolbar: {\n\t\t\tactions: {\n\t\t\t\tsave: {\n\t\t\t\t\ttitle: 'Save changes',\n\t\t\t\t\ttext: 'Save'\n\t\t\t\t},\n\t\t\t\tcancel: {\n\t\t\t\t\ttitle: 'Cancel editing, discards all changes',\n\t\t\t\t\ttext: 'Cancel'\n\t\t\t\t},\n\t\t\t\tclearAll: {\n\t\t\t\t\ttitle: 'Clear all layers',\n\t\t\t\t\ttext: 'Clear All'\n\t\t\t\t}\n\t\t\t},\n\t\t\tbuttons: {\n\t\t\t\tedit: 'Edit layers',\n\t\t\t\teditDisabled: 'No layers to edit',\n\t\t\t\tremove: 'Delete layers',\n\t\t\t\tremoveDisabled: 'No layers to delete'\n\t\t\t}\n\t\t},\n\t\thandlers: {\n\t\t\tedit: {\n\t\t\t\ttooltip: {\n\t\t\t\t\ttext: 'Drag handles or markers to edit features.',\n\t\t\t\t\tsubtext: 'Click cancel to undo changes.'\n\t\t\t\t}\n\t\t\t},\n\t\t\tremove: {\n\t\t\t\ttooltip: {\n\t\t\t\t\ttext: 'Click on a feature to remove.'\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n};\n","/**\n * ### Events\n * Once you have successfully added the Leaflet.draw plugin to your map you will want to respond to the different\n * actions users can initiate. The following events will be triggered on the map:\n *\n * @class L.Draw.Event\n * @aka Draw.Event\n *\n * Use `L.Draw.Event.EVENTNAME` constants to ensure events are correct.\n *\n * @example\n * ```js\n * map.on(L.Draw.Event.CREATED; function (e) {\n * var type = e.layerType,\n * layer = e.layer;\n *\n * if (type === 'marker') {\n * // Do marker specific actions\n * }\n *\n * // Do whatever else you need to. (save to db; add to map etc)\n * map.addLayer(layer);\n *});\n * ```\n */\nL.Draw.Event = {};\n/**\n * @event draw:created: PolyLine; Polygon; Rectangle; Circle; Marker | String\n *\n * Layer that was just created.\n * The type of layer this is. One of: `polyline`; `polygon`; `rectangle`; `circle`; `marker`\n * Triggered when a new vector or marker has been created.\n *\n */\nL.Draw.Event.CREATED = 'draw:created';\n\n/**\n * @event draw:edited: LayerGroup\n *\n * List of all layers just edited on the map.\n *\n *\n * Triggered when layers in the FeatureGroup; initialised with the plugin; have been edited and saved.\n *\n * @example\n * ```js\n * map.on('draw:edited', function (e) {\n * var layers = e.layers;\n * layers.eachLayer(function (layer) {\n * //do whatever you want; most likely save back to db\n * });\n * });\n * ```\n */\nL.Draw.Event.EDITED = 'draw:edited';\n\n/**\n * @event draw:deleted: LayerGroup\n *\n * List of all layers just removed from the map.\n *\n * Triggered when layers have been removed (and saved) from the FeatureGroup.\n */\nL.Draw.Event.DELETED = 'draw:deleted';\n\n/**\n * @event draw:drawstart: String\n *\n * The type of layer this is. One of:`polyline`; `polygon`; `rectangle`; `circle`; `marker`\n *\n * Triggered when the user has chosen to draw a particular vector or marker.\n */\nL.Draw.Event.DRAWSTART = 'draw:drawstart';\n\n/**\n * @event draw:drawstop: String\n *\n * The type of layer this is. One of: `polyline`; `polygon`; `rectangle`; `circle`; `marker`\n *\n * Triggered when the user has finished a particular vector or marker.\n */\n\nL.Draw.Event.DRAWSTOP = 'draw:drawstop';\n\n/**\n * @event draw:drawvertex: LayerGroup\n *\n * List of all layers just being added from the map.\n *\n * Triggered when a vertex is created on a polyline or polygon.\n */\nL.Draw.Event.DRAWVERTEX = 'draw:drawvertex';\n\n/**\n * @event draw:editstart: String\n *\n * The type of edit this is. One of: `edit`\n *\n * Triggered when the user starts edit mode by clicking the edit tool button.\n */\n\nL.Draw.Event.EDITSTART = 'draw:editstart';\n\n/**\n * @event draw:editmove: ILayer\n *\n * Layer that was just moved.\n *\n * Triggered as the user moves a rectangle; circle or marker.\n */\nL.Draw.Event.EDITMOVE = 'draw:editmove';\n\n/**\n * @event draw:editresize: ILayer\n *\n * Layer that was just moved.\n *\n * Triggered as the user resizes a rectangle or circle.\n */\nL.Draw.Event.EDITRESIZE = 'draw:editresize';\n\n/**\n * @event draw:editvertex: LayerGroup\n *\n * List of all layers just being edited from the map.\n *\n * Triggered when a vertex is edited on a polyline or polygon.\n */\nL.Draw.Event.EDITVERTEX = 'draw:editvertex';\n\n/**\n * @event draw:editstop: String\n *\n * The type of edit this is. One of: `edit`\n *\n * Triggered when the user has finshed editing (edit mode) and saves edits.\n */\nL.Draw.Event.EDITSTOP = 'draw:editstop';\n\n/**\n * @event draw:deletestart: String\n *\n * The type of edit this is. One of: `remove`\n *\n * Triggered when the user starts remove mode by clicking the remove tool button.\n */\nL.Draw.Event.DELETESTART = 'draw:deletestart';\n\n/**\n * @event draw:deletestop: String\n *\n * The type of edit this is. One of: `remove`\n *\n * Triggered when the user has finished removing shapes (remove mode) and saves.\n */\nL.Draw.Event.DELETESTOP = 'draw:deletestop';\n\n/**\n * @event draw:toolbaropened: String\n *\n * Triggered when a toolbar is opened.\n */\nL.Draw.Event.TOOLBAROPENED = 'draw:toolbaropened';\n\n/**\n * @event draw:toolbarclosed: String\n *\n * Triggered when a toolbar is closed.\n */\nL.Draw.Event.TOOLBARCLOSED = 'draw:toolbarclosed';\n\n/**\n * @event draw:markercontext: String\n *\n * Triggered when a marker is right clicked.\n */\nL.Draw.Event.MARKERCONTEXT = 'draw:markercontext';","L.Draw = L.Draw || {};\n\n/**\n * @class L.Draw.Feature\n * @aka Draw.Feature\n */\nL.Draw.Feature = L.Handler.extend({\n\n\t// @method initialize(): void\n\tinitialize: function (map, options) {\n\t\tthis._map = map;\n\t\tthis._container = map._container;\n\t\tthis._overlayPane = map._panes.overlayPane;\n\t\tthis._popupPane = map._panes.popupPane;\n\n\t\t// Merge default shapeOptions options with custom shapeOptions\n\t\tif (options && options.shapeOptions) {\n\t\t\toptions.shapeOptions = L.Util.extend({}, this.options.shapeOptions, options.shapeOptions);\n\t\t}\n\t\tL.setOptions(this, options);\n\n\t\tvar version = L.version.split('.');\n\t\t//If Version is >= 1.2.0\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\n\t\t\tL.Draw.Feature.include(L.Evented.prototype);\n\t\t} else {\n\t\t\tL.Draw.Feature.include(L.Mixin.Events);\n\t\t}\n\t},\n\n\t// @method enable(): void\n\t// Enables this handler\n\tenable: function () {\n\t\tif (this._enabled) {\n\t\t\treturn;\n\t\t}\n\n\t\tL.Handler.prototype.enable.call(this);\n\n\t\tthis.fire('enabled', {handler: this.type});\n\n\t\tthis._map.fire(L.Draw.Event.DRAWSTART, {layerType: this.type});\n\t},\n\n\t// @method disable(): void\n\tdisable: function () {\n\t\tif (!this._enabled) {\n\t\t\treturn;\n\t\t}\n\n\t\tL.Handler.prototype.disable.call(this);\n\n\t\tthis._map.fire(L.Draw.Event.DRAWSTOP, {layerType: this.type});\n\n\t\tthis.fire('disabled', {handler: this.type});\n\t},\n\n\t// @method addHooks(): void\n\t// Add's event listeners to this handler\n\taddHooks: function () {\n\t\tvar map = this._map;\n\n\t\tif (map) {\n\t\t\tL.DomUtil.disableTextSelection();\n\n\t\t\tmap.getContainer().focus();\n\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\n\n\t\t\tL.DomEvent.on(this._container, 'keyup', this._cancelDrawing, this);\n\t\t}\n\t},\n\n\t// @method removeHooks(): void\n\t// Removes event listeners from this handler\n\tremoveHooks: function () {\n\t\tif (this._map) {\n\t\t\tL.DomUtil.enableTextSelection();\n\n\t\t\tthis._tooltip.dispose();\n\t\t\tthis._tooltip = null;\n\n\t\t\tL.DomEvent.off(this._container, 'keyup', this._cancelDrawing, this);\n\t\t}\n\t},\n\n\t// @method setOptions(object): void\n\t// Sets new options to this handler\n\tsetOptions: function (options) {\n\t\tL.setOptions(this, options);\n\t},\n\n\t_fireCreatedEvent: function (layer) {\n\t\tthis._map.fire(L.Draw.Event.CREATED, {layer: layer, layerType: this.type});\n\t},\n\n\t// Cancel drawing when the escape key is pressed\n\t_cancelDrawing: function (e) {\n\t\tif (e.keyCode === 27) {\n\t\t\tthis._map.fire('draw:canceled', {layerType: this.type});\n\t\t\tthis.disable();\n\t\t}\n\t}\n});\n","/**\n * @class L.Draw.Polyline\n * @aka Draw.Polyline\n * @inherits L.Draw.Feature\n */\nL.Draw.Polyline = L.Draw.Feature.extend({\n\tstatics: {\n\t\tTYPE: 'polyline'\n\t},\n\n\tPoly: L.Polyline,\n\n\toptions: {\n\t\tallowIntersection: true,\n\t\trepeatMode: false,\n\t\tdrawError: {\n\t\t\tcolor: '#b00b00',\n\t\t\ttimeout: 2500\n\t\t},\n\t\ticon: new L.DivIcon({\n\t\t\ticonSize: new L.Point(8, 8),\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon'\n\t\t}),\n\t\ttouchIcon: new L.DivIcon({\n\t\t\ticonSize: new L.Point(20, 20),\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon'\n\t\t}),\n\t\tguidelineDistance: 20,\n\t\tmaxGuideLineLength: 4000,\n\t\tshapeOptions: {\n\t\t\tstroke: true,\n\t\t\tcolor: '#3388ff',\n\t\t\tweight: 4,\n\t\t\topacity: 0.5,\n\t\t\tfill: false,\n\t\t\tclickable: true\n\t\t},\n\t\tmetric: true, // Whether to use the metric measurement system or imperial\n\t\tfeet: true, // When not metric, to use feet instead of yards for display.\n\t\tnautic: false, // When not metric, not feet use nautic mile for display\n\t\tshowLength: true, // Whether to display distance in the tooltip\n\t\tzIndexOffset: 2000, // This should be > than the highest z-index any map layers\n\t\tfactor: 1, // To change distance calculation\n\t\tmaxPoints: 0 // Once this number of points are placed, finish shape\n\t},\n\n\t// @method initialize(): void\n\tinitialize: function (map, options) {\n\t\t// if touch, switch to touch icon\n\t\tif (L.Browser.touch) {\n\t\t\tthis.options.icon = this.options.touchIcon;\n\t\t}\n\n\t\t// Need to set this here to ensure the correct message is used.\n\t\tthis.options.drawError.message = L.drawLocal.draw.handlers.polyline.error;\n\n\t\t// Merge default drawError options with custom options\n\t\tif (options && options.drawError) {\n\t\t\toptions.drawError = L.Util.extend({}, this.options.drawError, options.drawError);\n\t\t}\n\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\n\t\tthis.type = L.Draw.Polyline.TYPE;\n\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\n\t},\n\n\t// @method addHooks(): void\n\t// Add listener hooks to this handler\n\taddHooks: function () {\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\n\t\tif (this._map) {\n\t\t\tthis._markers = [];\n\n\t\t\tthis._markerGroup = new L.LayerGroup();\n\t\t\tthis._map.addLayer(this._markerGroup);\n\n\t\t\tthis._poly = new L.Polyline([], this.options.shapeOptions);\n\n\t\t\tthis._tooltip.updateContent(this._getTooltipText());\n\n\t\t\t// Make a transparent marker that will used to catch click events. These click\n\t\t\t// events will create the vertices. We need to do this so we can ensure that\n\t\t\t// we can create vertices over other map layers (markers, vector layers). We\n\t\t\t// also do not want to trigger any click handlers of objects we are clicking on\n\t\t\t// while drawing.\n\t\t\tif (!this._mouseMarker) {\n\t\t\t\tthis._mouseMarker = L.marker(this._map.getCenter(), {\n\t\t\t\t\ticon: L.divIcon({\n\t\t\t\t\t\tclassName: 'leaflet-mouse-marker',\n\t\t\t\t\t\ticonAnchor: [20, 20],\n\t\t\t\t\t\ticonSize: [40, 40]\n\t\t\t\t\t}),\n\t\t\t\t\topacity: 0,\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tthis._mouseMarker\n\t\t\t\t.on('mouseout', this._onMouseOut, this)\n\t\t\t\t.on('mousemove', this._onMouseMove, this) // Necessary to prevent 0.8 stutter\n\t\t\t\t.on('mousedown', this._onMouseDown, this)\n\t\t\t\t.on('mouseup', this._onMouseUp, this) // Necessary for 0.8 compatibility\n\t\t\t\t.addTo(this._map);\n\n\t\t\tthis._map\n\t\t\t\t.on('mouseup', this._onMouseUp, this) // Necessary for 0.7 compatibility\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\n\t\t\t\t.on('zoomlevelschange', this._onZoomEnd, this)\n\t\t\t\t.on('touchstart', this._onTouch, this)\n\t\t\t\t.on('zoomend', this._onZoomEnd, this);\n\n\t\t}\n\t},\n\n\t// @method removeHooks(): void\n\t// Remove listener hooks from this handler.\n\tremoveHooks: function () {\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\n\n\t\tthis._clearHideErrorTimeout();\n\n\t\tthis._cleanUpShape();\n\n\t\t// remove markers from map\n\t\tthis._map.removeLayer(this._markerGroup);\n\t\tdelete this._markerGroup;\n\t\tdelete this._markers;\n\n\t\tthis._map.removeLayer(this._poly);\n\t\tdelete this._poly;\n\n\t\tthis._mouseMarker\n\t\t\t.off('mousedown', this._onMouseDown, this)\n\t\t\t.off('mouseout', this._onMouseOut, this)\n\t\t\t.off('mouseup', this._onMouseUp, this)\n\t\t\t.off('mousemove', this._onMouseMove, this);\n\t\tthis._map.removeLayer(this._mouseMarker);\n\t\tdelete this._mouseMarker;\n\n\t\t// clean up DOM\n\t\tthis._clearGuides();\n\n\t\tthis._map\n\t\t\t.off('mouseup', this._onMouseUp, this)\n\t\t\t.off('mousemove', this._onMouseMove, this)\n\t\t\t.off('zoomlevelschange', this._onZoomEnd, this)\n\t\t\t.off('zoomend', this._onZoomEnd, this)\n\t\t\t.off('touchstart', this._onTouch, this)\n\t\t\t.off('click', this._onTouch, this);\n\t},\n\n\t// @method deleteLastVertex(): void\n\t// Remove the last vertex from the polyline, removes polyline from map if only one point exists.\n\tdeleteLastVertex: function () {\n\t\tif (this._markers.length <= 1) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar lastMarker = this._markers.pop(),\n\t\t\tpoly = this._poly,\n\t\t\t// Replaces .spliceLatLngs()\n\t\t\tlatlngs = poly.getLatLngs(),\n\t\t\tlatlng = latlngs.splice(-1, 1)[0];\n\t\tthis._poly.setLatLngs(latlngs);\n\n\t\tthis._markerGroup.removeLayer(lastMarker);\n\n\t\tif (poly.getLatLngs().length < 2) {\n\t\t\tthis._map.removeLayer(poly);\n\t\t}\n\n\t\tthis._vertexChanged(latlng, false);\n\t},\n\n\t// @method addVertex(): void\n\t// Add a vertex to the end of the polyline\n\taddVertex: function (latlng) {\n\t\tvar markersLength = this._markers.length;\n\t\t// markersLength must be greater than or equal to 2 before intersections can occur\n\t\tif (markersLength >= 2 && !this.options.allowIntersection && this._poly.newLatLngIntersects(latlng)) {\n\t\t\tthis._showErrorTooltip();\n\t\t\treturn;\n\t\t}\n\t\telse if (this._errorShown) {\n\t\t\tthis._hideErrorTooltip();\n\t\t}\n\n\t\tthis._markers.push(this._createMarker(latlng));\n\n\t\tthis._poly.addLatLng(latlng);\n\n\t\tif (this._poly.getLatLngs().length === 2) {\n\t\t\tthis._map.addLayer(this._poly);\n\t\t}\n\n\t\tthis._vertexChanged(latlng, true);\n\t},\n\n\t// @method completeShape(): void\n\t// Closes the polyline between the first and last points\n\tcompleteShape: function () {\n\t\tif (this._markers.length <= 1 || !this._shapeIsValid()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._fireCreatedEvent();\n\t\tthis.disable();\n\n\t\tif (this.options.repeatMode) {\n\t\t\tthis.enable();\n\t\t}\n\t},\n\n\t_finishShape: function () {\n\t\tvar latlngs = this._poly._defaultShape ? this._poly._defaultShape() : this._poly.getLatLngs();\n\t\tvar intersects = this._poly.newLatLngIntersects(latlngs[latlngs.length - 1]);\n\n\t\tif ((!this.options.allowIntersection && intersects) || !this._shapeIsValid()) {\n\t\t\tthis._showErrorTooltip();\n\t\t\treturn;\n\t\t}\n\n\t\tthis._fireCreatedEvent();\n\t\tthis.disable();\n\t\tif (this.options.repeatMode) {\n\t\t\tthis.enable();\n\t\t}\n\t},\n\n\t// Called to verify the shape is valid when the user tries to finish it\n\t// Return false if the shape is not valid\n\t_shapeIsValid: function () {\n\t\treturn true;\n\t},\n\n\t_onZoomEnd: function () {\n\t\tif (this._markers !== null) {\n\t\t\tthis._updateGuide();\n\t\t}\n\t},\n\n\t_onMouseMove: function (e) {\n\t\tvar newPos = this._map.mouseEventToLayerPoint(e.originalEvent);\n\t\tvar latlng = this._map.layerPointToLatLng(newPos);\n\n\t\t// Save latlng\n\t\t// should this be moved to _updateGuide() ?\n\t\tthis._currentLatLng = latlng;\n\n\t\tthis._updateTooltip(latlng);\n\n\t\t// Update the guide line\n\t\tthis._updateGuide(newPos);\n\n\t\t// Update the mouse marker position\n\t\tthis._mouseMarker.setLatLng(latlng);\n\n\t\tL.DomEvent.preventDefault(e.originalEvent);\n\t},\n\n\t_vertexChanged: function (latlng, added) {\n\t\tthis._map.fire(L.Draw.Event.DRAWVERTEX, {layers: this._markerGroup});\n\t\tthis._updateFinishHandler();\n\n\t\tthis._updateRunningMeasure(latlng, added);\n\n\t\tthis._clearGuides();\n\n\t\tthis._updateTooltip();\n\t},\n\n\t_onMouseDown: function (e) {\n\t\tif (!this._clickHandled && !this._touchHandled && !this._disableMarkers) {\n\t\t\tthis._onMouseMove(e);\n\t\t\tthis._clickHandled = true;\n\t\t\tthis._disableNewMarkers();\n\t\t\tvar originalEvent = e.originalEvent;\n\t\t\tvar clientX = originalEvent.clientX;\n\t\t\tvar clientY = originalEvent.clientY;\n\t\t\tthis._startPoint.call(this, clientX, clientY);\n\t\t}\n\t},\n\n\t_startPoint: function (clientX, clientY) {\n\t\tthis._mouseDownOrigin = L.point(clientX, clientY);\n\t},\n\n\t_onMouseUp: function (e) {\n\t\tvar originalEvent = e.originalEvent;\n\t\tvar clientX = originalEvent.clientX;\n\t\tvar clientY = originalEvent.clientY;\n\t\tthis._endPoint.call(this, clientX, clientY, e);\n\t\tthis._clickHandled = null;\n\t},\n\n\t_endPoint: function (clientX, clientY, e) {\n\t\tif (this._mouseDownOrigin) {\n\t\t\tvar dragCheckDistance = L.point(clientX, clientY)\n\t\t\t\t.distanceTo(this._mouseDownOrigin);\n\t\t\tvar lastPtDistance = this._calculateFinishDistance(e.latlng);\n\t\t\tif (this.options.maxPoints > 1 && this.options.maxPoints == this._markers.length + 1) {\n\t\t\t\tthis.addVertex(e.latlng);\n\t\t\t\tthis._finishShape();\n\t\t\t} else if (lastPtDistance < 10 && L.Browser.touch) {\n\t\t\t\tthis._finishShape();\n\t\t\t} else if (Math.abs(dragCheckDistance) < 9 * (window.devicePixelRatio || 1)) {\n\t\t\t\tthis.addVertex(e.latlng);\n\t\t\t}\n\t\t\tthis._enableNewMarkers(); // after a short pause, enable new markers\n\t\t}\n\t\tthis._mouseDownOrigin = null;\n\t},\n\n\t// ontouch prevented by clickHandled flag because some browsers fire both click/touch events,\n\t// causing unwanted behavior\n\t_onTouch: function (e) {\n\t\tvar originalEvent = e.originalEvent;\n\t\tvar clientX;\n\t\tvar clientY;\n\t\tif (originalEvent.touches && originalEvent.touches[0] && !this._clickHandled && !this._touchHandled && !this._disableMarkers) {\n\t\t\tclientX = originalEvent.touches[0].clientX;\n\t\t\tclientY = originalEvent.touches[0].clientY;\n\t\t\tthis._disableNewMarkers();\n\t\t\tthis._touchHandled = true;\n\t\t\tthis._startPoint.call(this, clientX, clientY);\n\t\t\tthis._endPoint.call(this, clientX, clientY, e);\n\t\t\tthis._touchHandled = null;\n\t\t}\n\t\tthis._clickHandled = null;\n\t},\n\n\t_onMouseOut: function () {\n\t\tif (this._tooltip) {\n\t\t\tthis._tooltip._onMouseOut.call(this._tooltip);\n\t\t}\n\t},\n\n\t// calculate if we are currently within close enough distance\n\t// of the closing point (first point for shapes, last point for lines)\n\t// this is semi-ugly code but the only reliable way i found to get the job done\n\t// note: calculating point.distanceTo between mouseDownOrigin and last marker did NOT work\n\t_calculateFinishDistance: function (potentialLatLng) {\n\t\tvar lastPtDistance;\n\t\tif (this._markers.length > 0) {\n\t\t\tvar finishMarker;\n\t\t\tif (this.type === L.Draw.Polyline.TYPE) {\n\t\t\t\tfinishMarker = this._markers[this._markers.length - 1];\n\t\t\t} else if (this.type === L.Draw.Polygon.TYPE) {\n\t\t\t\tfinishMarker = this._markers[0];\n\t\t\t} else {\n\t\t\t\treturn Infinity;\n\t\t\t}\n\t\t\tvar lastMarkerPoint = this._map.latLngToContainerPoint(finishMarker.getLatLng()),\n\t\t\t\tpotentialMarker = new L.Marker(potentialLatLng, {\n\t\t\t\t\ticon: this.options.icon,\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset * 2\n\t\t\t\t});\n\t\t\tvar potentialMarkerPint = this._map.latLngToContainerPoint(potentialMarker.getLatLng());\n\t\t\tlastPtDistance = lastMarkerPoint.distanceTo(potentialMarkerPint);\n\t\t} else {\n\t\t\tlastPtDistance = Infinity;\n\t\t}\n\t\treturn lastPtDistance;\n\t},\n\n\t_updateFinishHandler: function () {\n\t\tvar markerCount = this._markers.length;\n\t\t// The last marker should have a click handler to close the polyline\n\t\tif (markerCount > 1) {\n\t\t\tthis._markers[markerCount - 1].on('click', this._finishShape, this);\n\t\t}\n\n\t\t// Remove the old marker click handler (as only the last point should close the polyline)\n\t\tif (markerCount > 2) {\n\t\t\tthis._markers[markerCount - 2].off('click', this._finishShape, this);\n\t\t}\n\t},\n\n\t_createMarker: function (latlng) {\n\t\tvar marker = new L.Marker(latlng, {\n\t\t\ticon: this.options.icon,\n\t\t\tzIndexOffset: this.options.zIndexOffset * 2\n\t\t});\n\n\t\tthis._markerGroup.addLayer(marker);\n\n\t\treturn marker;\n\t},\n\n\t_updateGuide: function (newPos) {\n\t\tvar markerCount = this._markers ? this._markers.length : 0;\n\n\t\tif (markerCount > 0) {\n\t\t\tnewPos = newPos || this._map.latLngToLayerPoint(this._currentLatLng);\n\n\t\t\t// draw the guide line\n\t\t\tthis._clearGuides();\n\t\t\tthis._drawGuide(\n\t\t\t\tthis._map.latLngToLayerPoint(this._markers[markerCount - 1].getLatLng()),\n\t\t\t\tnewPos\n\t\t\t);\n\t\t}\n\t},\n\n\t_updateTooltip: function (latLng) {\n\t\tvar text = this._getTooltipText();\n\n\t\tif (latLng) {\n\t\t\tthis._tooltip.updatePosition(latLng);\n\t\t}\n\n\t\tif (!this._errorShown) {\n\t\t\tthis._tooltip.updateContent(text);\n\t\t}\n\t},\n\n\t_drawGuide: function (pointA, pointB) {\n\t\tvar length = Math.floor(Math.sqrt(Math.pow((pointB.x - pointA.x), 2) + Math.pow((pointB.y - pointA.y), 2))),\n\t\t\tguidelineDistance = this.options.guidelineDistance,\n\t\t\tmaxGuideLineLength = this.options.maxGuideLineLength,\n\t\t\t// Only draw a guideline with a max length\n\t\t\ti = length > maxGuideLineLength ? length - maxGuideLineLength : guidelineDistance,\n\t\t\tfraction,\n\t\t\tdashPoint,\n\t\t\tdash;\n\n\t\t//create the guides container if we haven't yet\n\t\tif (!this._guidesContainer) {\n\t\t\tthis._guidesContainer = L.DomUtil.create('div', 'leaflet-draw-guides', this._overlayPane);\n\t\t}\n\n\t\t//draw a dash every GuildeLineDistance\n\t\tfor (; i < length; i += this.options.guidelineDistance) {\n\t\t\t//work out fraction along line we are\n\t\t\tfraction = i / length;\n\n\t\t\t//calculate new x,y point\n\t\t\tdashPoint = {\n\t\t\t\tx: Math.floor((pointA.x * (1 - fraction)) + (fraction * pointB.x)),\n\t\t\t\ty: Math.floor((pointA.y * (1 - fraction)) + (fraction * pointB.y))\n\t\t\t};\n\n\t\t\t//add guide dash to guide container\n\t\t\tdash = L.DomUtil.create('div', 'leaflet-draw-guide-dash', this._guidesContainer);\n\t\t\tdash.style.backgroundColor =\n\t\t\t\t!this._errorShown ? this.options.shapeOptions.color : this.options.drawError.color;\n\n\t\t\tL.DomUtil.setPosition(dash, dashPoint);\n\t\t}\n\t},\n\n\t_updateGuideColor: function (color) {\n\t\tif (this._guidesContainer) {\n\t\t\tfor (var i = 0, l = this._guidesContainer.childNodes.length; i < l; i++) {\n\t\t\t\tthis._guidesContainer.childNodes[i].style.backgroundColor = color;\n\t\t\t}\n\t\t}\n\t},\n\n\t// removes all child elements (guide dashes) from the guides container\n\t_clearGuides: function () {\n\t\tif (this._guidesContainer) {\n\t\t\twhile (this._guidesContainer.firstChild) {\n\t\t\t\tthis._guidesContainer.removeChild(this._guidesContainer.firstChild);\n\t\t\t}\n\t\t}\n\t},\n\n\t_getTooltipText: function () {\n\t\tvar showLength = this.options.showLength,\n\t\t\tlabelText, distanceStr;\n\t\tif (this._markers.length === 0) {\n\t\t\tlabelText = {\n\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.start\n\t\t\t};\n\t\t} else {\n\t\t\tdistanceStr = showLength ? this._getMeasurementString() : '';\n\n\t\t\tif (this._markers.length === 1) {\n\t\t\t\tlabelText = {\n\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.cont,\n\t\t\t\t\tsubtext: distanceStr\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tlabelText = {\n\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.tooltip.end,\n\t\t\t\t\tsubtext: distanceStr\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t\treturn labelText;\n\t},\n\n\t_updateRunningMeasure: function (latlng, added) {\n\t\tvar markersLength = this._markers.length,\n\t\t\tpreviousMarkerIndex, distance;\n\n\t\tif (this._markers.length === 1) {\n\t\t\tthis._measurementRunningTotal = 0;\n\t\t} else {\n\t\t\tpreviousMarkerIndex = markersLength - (added ? 2 : 1);\n\n\t\t\t// Calculate the distance based on the version\n\t\t\tif (L.GeometryUtil.isVersion07x()) {\n\t\t\t\tdistance = latlng.distanceTo(this._markers[previousMarkerIndex].getLatLng()) * (this.options.factor || 1);\n\t\t\t} else {\n\t\t\t\tdistance = this._map.distance(latlng, this._markers[previousMarkerIndex].getLatLng()) * (this.options.factor || 1);\n\t\t\t}\n\n\t\t\tthis._measurementRunningTotal += distance * (added ? 1 : -1);\n\t\t}\n\t},\n\n\t_getMeasurementString: function () {\n\t\tvar currentLatLng = this._currentLatLng,\n\t\t\tpreviousLatLng = this._markers[this._markers.length - 1].getLatLng(),\n\t\t\tdistance;\n\n\t\t// Calculate the distance from the last fixed point to the mouse position based on the version\n\t\tif (L.GeometryUtil.isVersion07x()) {\n\t\t\tdistance = previousLatLng && currentLatLng && currentLatLng.distanceTo ? this._measurementRunningTotal + currentLatLng.distanceTo(previousLatLng) * (this.options.factor || 1) : this._measurementRunningTotal || 0;\n\t\t} else {\n\t\t\tdistance = previousLatLng && currentLatLng ? this._measurementRunningTotal + this._map.distance(currentLatLng, previousLatLng) * (this.options.factor || 1) : this._measurementRunningTotal || 0;\n\t\t}\n\n\t\treturn L.GeometryUtil.readableDistance(distance, this.options.metric, this.options.feet, this.options.nautic, this.options.precision);\n\t},\n\n\t_showErrorTooltip: function () {\n\t\tthis._errorShown = true;\n\n\t\t// Update tooltip\n\t\tthis._tooltip\n\t\t\t.showAsError()\n\t\t\t.updateContent({text: this.options.drawError.message});\n\n\t\t// Update shape\n\t\tthis._updateGuideColor(this.options.drawError.color);\n\t\tthis._poly.setStyle({color: this.options.drawError.color});\n\n\t\t// Hide the error after 2 seconds\n\t\tthis._clearHideErrorTimeout();\n\t\tthis._hideErrorTimeout = setTimeout(L.Util.bind(this._hideErrorTooltip, this), this.options.drawError.timeout);\n\t},\n\n\t_hideErrorTooltip: function () {\n\t\tthis._errorShown = false;\n\n\t\tthis._clearHideErrorTimeout();\n\n\t\t// Revert tooltip\n\t\tthis._tooltip\n\t\t\t.removeError()\n\t\t\t.updateContent(this._getTooltipText());\n\n\t\t// Revert shape\n\t\tthis._updateGuideColor(this.options.shapeOptions.color);\n\t\tthis._poly.setStyle({color: this.options.shapeOptions.color});\n\t},\n\n\t_clearHideErrorTimeout: function () {\n\t\tif (this._hideErrorTimeout) {\n\t\t\tclearTimeout(this._hideErrorTimeout);\n\t\t\tthis._hideErrorTimeout = null;\n\t\t}\n\t},\n\n\t// disable new markers temporarily;\n\t// this is to prevent duplicated touch/click events in some browsers\n\t_disableNewMarkers: function () {\n\t\tthis._disableMarkers = true;\n\t},\n\n\t// see _disableNewMarkers\n\t_enableNewMarkers: function () {\n\t\tsetTimeout(function () {\n\t\t\tthis._disableMarkers = false;\n\t\t}.bind(this), 50);\n\t},\n\n\t_cleanUpShape: function () {\n\t\tif (this._markers.length > 1) {\n\t\t\tthis._markers[this._markers.length - 1].off('click', this._finishShape, this);\n\t\t}\n\t},\n\n\t_fireCreatedEvent: function () {\n\t\tvar poly = new this.Poly(this._poly.getLatLngs(), this.options.shapeOptions);\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, poly);\n\t}\n});\n","/**\n * @class L.Draw.Polygon\n * @aka Draw.Polygon\n * @inherits L.Draw.Polyline\n */\nL.Draw.Polygon = L.Draw.Polyline.extend({\n\tstatics: {\n\t\tTYPE: 'polygon'\n\t},\n\n\tPoly: L.Polygon,\n\n\toptions: {\n\t\tshowArea: false,\n\t\tshowLength: false,\n\t\tshapeOptions: {\n\t\t\tstroke: true,\n\t\t\tcolor: '#3388ff',\n\t\t\tweight: 4,\n\t\t\topacity: 0.5,\n\t\t\tfill: true,\n\t\t\tfillColor: null, //same as color by default\n\t\t\tfillOpacity: 0.2,\n\t\t\tclickable: true\n\t\t},\n\t\t// Whether to use the metric measurement system (truthy) or not (falsy).\n\t\t// Also defines the units to use for the metric system as an array of\n\t\t// strings (e.g. `['ha', 'm']`).\n\t\tmetric: true,\n\t\tfeet: true, // When not metric, to use feet instead of yards for display.\n\t\tnautic: false, // When not metric, not feet use nautic mile for display\n\t\t// Defines the precision for each type of unit (e.g. {km: 2, ft: 0}\n\t\tprecision: {}\n\t},\n\n\t// @method initialize(): void\n\tinitialize: function (map, options) {\n\t\tL.Draw.Polyline.prototype.initialize.call(this, map, options);\n\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\n\t\tthis.type = L.Draw.Polygon.TYPE;\n\t},\n\n\t_updateFinishHandler: function () {\n\t\tvar markerCount = this._markers.length;\n\n\t\t// The first marker should have a click handler to close the polygon\n\t\tif (markerCount === 1) {\n\t\t\tthis._markers[0].on('click', this._finishShape, this);\n\t\t}\n\n\t\t// Add and update the double click handler\n\t\tif (markerCount > 2) {\n\t\t\tthis._markers[markerCount - 1].on('dblclick', this._finishShape, this);\n\t\t\t// Only need to remove handler if has been added before\n\t\t\tif (markerCount > 3) {\n\t\t\t\tthis._markers[markerCount - 2].off('dblclick', this._finishShape, this);\n\t\t\t}\n\t\t}\n\t},\n\n\t_getTooltipText: function () {\n\t\tvar text, subtext;\n\n\t\tif (this._markers.length === 0) {\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.start;\n\t\t} else if (this._markers.length < 3) {\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.cont;\n\t\t\tsubtext = this._getMeasurementString();\n\t\t} else {\n\t\t\ttext = L.drawLocal.draw.handlers.polygon.tooltip.end;\n\t\t\tsubtext = this._getMeasurementString();\n\t\t}\n\n\t\treturn {\n\t\t\ttext: text,\n\t\t\tsubtext: subtext\n\t\t};\n\t},\n\n\t_getMeasurementString: function () {\n\t\tvar area = this._area,\n\t\t\tmeasurementString = '';\n\n\n\t\tif (!area && !this.options.showLength) {\n\t\t\treturn null;\n\t\t}\n\n\t\tif (this.options.showLength) {\n\t\t\tmeasurementString = L.Draw.Polyline.prototype._getMeasurementString.call(this);\n\t\t}\n\n\t\tif (area) {\n\t\t\tmeasurementString += ' ' + L.GeometryUtil.readableArea(area, this.options.metric, this.options.precision);\n\t\t}\n\n\t\treturn measurementString;\n\t},\n\n\t_shapeIsValid: function () {\n\t\treturn this._markers.length >= 3;\n\t},\n\n\t_vertexChanged: function (latlng, added) {\n\t\tvar latLngs;\n\n\t\t// Check to see if we should show the area\n\t\tif (!this.options.allowIntersection && this.options.showArea) {\n\t\t\tlatLngs = this._poly.getLatLngs();\n\n\t\t\tthis._area = L.GeometryUtil.geodesicArea(latLngs);\n\t\t}\n\n\t\tL.Draw.Polyline.prototype._vertexChanged.call(this, latlng, added);\n\t},\n\n\t_cleanUpShape: function () {\n\t\tvar markerCount = this._markers.length;\n\n\t\tif (markerCount > 0) {\n\t\t\tthis._markers[0].off('click', this._finishShape, this);\n\n\t\t\tif (markerCount > 2) {\n\t\t\t\tthis._markers[markerCount - 1].off('dblclick', this._finishShape, this);\n\t\t\t}\n\t\t}\n\t}\n});\n","L.SimpleShape = {};\n/**\n * @class L.Draw.SimpleShape\n * @aka Draw.SimpleShape\n * @inherits L.Draw.Feature\n */\nL.Draw.SimpleShape = L.Draw.Feature.extend({\n\toptions: {\n\t\trepeatMode: false\n\t},\n\n\t// @method initialize(): void\n\tinitialize: function (map, options) {\n\t\tthis._endLabelText = L.drawLocal.draw.handlers.simpleshape.tooltip.end;\n\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\n\t},\n\n\t// @method addHooks(): void\n\t// Add listener hooks to this handler.\n\taddHooks: function () {\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\n\t\tif (this._map) {\n\t\t\tthis._mapDraggable = this._map.dragging.enabled();\n\n\t\t\tif (this._mapDraggable) {\n\t\t\t\tthis._map.dragging.disable();\n\t\t\t}\n\n\t\t\t//TODO refactor: move cursor to styles\n\t\t\tthis._container.style.cursor = 'crosshair';\n\n\t\t\tthis._tooltip.updateContent({text: this._initialLabelText});\n\n\t\t\tthis._map\n\t\t\t\t.on('mousedown', this._onMouseDown, this)\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\n\t\t\t\t.on('touchstart', this._onMouseDown, this)\n\t\t\t\t.on('touchmove', this._onMouseMove, this);\n\n\t\t\t// we should prevent default, otherwise default behavior (scrolling) will fire,\n\t\t\t// and that will cause document.touchend to fire and will stop the drawing\n\t\t\t// (circle, rectangle) in touch mode.\n\t\t\t// (update): we have to send passive now to prevent scroll, because by default it is {passive: true} now, which means,\n\t\t\t// handler can't event.preventDefault\n\t\t\t// check the news https://developers.google.com/web/updates/2016/06/passive-event-listeners\n\t\t\tdocument.addEventListener('touchstart', L.DomEvent.preventDefault, {passive: false});\n\t\t}\n\t},\n\n\t// @method removeHooks(): void\n\t// Remove listener hooks from this handler.\n\tremoveHooks: function () {\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\n\t\tif (this._map) {\n\t\t\tif (this._mapDraggable) {\n\t\t\t\tthis._map.dragging.enable();\n\t\t\t}\n\n\t\t\t//TODO refactor: move cursor to styles\n\t\t\tthis._container.style.cursor = '';\n\n\t\t\tthis._map\n\t\t\t\t.off('mousedown', this._onMouseDown, this)\n\t\t\t\t.off('mousemove', this._onMouseMove, this)\n\t\t\t\t.off('touchstart', this._onMouseDown, this)\n\t\t\t\t.off('touchmove', this._onMouseMove, this);\n\n\t\t\tL.DomEvent.off(document, 'mouseup', this._onMouseUp, this);\n\t\t\tL.DomEvent.off(document, 'touchend', this._onMouseUp, this);\n\n\t\t\tdocument.removeEventListener('touchstart', L.DomEvent.preventDefault);\n\n\t\t\t// If the box element doesn't exist they must not have moved the mouse, so don't need to destroy/return\n\t\t\tif (this._shape) {\n\t\t\t\tthis._map.removeLayer(this._shape);\n\t\t\t\tdelete this._shape;\n\t\t\t}\n\t\t}\n\t\tthis._isDrawing = false;\n\t},\n\n\t_getTooltipText: function () {\n\t\treturn {\n\t\t\ttext: this._endLabelText\n\t\t};\n\t},\n\n\t_onMouseDown: function (e) {\n\t\tthis._isDrawing = true;\n\t\tthis._startLatLng = e.latlng;\n\n\t\tL.DomEvent\n\t\t\t.on(document, 'mouseup', this._onMouseUp, this)\n\t\t\t.on(document, 'touchend', this._onMouseUp, this)\n\t\t\t.preventDefault(e.originalEvent);\n\t},\n\n\t_onMouseMove: function (e) {\n\t\tvar latlng = e.latlng;\n\n\t\tthis._tooltip.updatePosition(latlng);\n\t\tif (this._isDrawing) {\n\t\t\tthis._tooltip.updateContent(this._getTooltipText());\n\t\t\tthis._drawShape(latlng);\n\t\t}\n\t},\n\n\t_onMouseUp: function () {\n\t\tif (this._shape) {\n\t\t\tthis._fireCreatedEvent();\n\t\t}\n\n\t\tthis.disable();\n\t\tif (this.options.repeatMode) {\n\t\t\tthis.enable();\n\t\t}\n\t}\n});\n","/**\n * @class L.Draw.Rectangle\n * @aka Draw.Rectangle\n * @inherits L.Draw.SimpleShape\n */\nL.Draw.Rectangle = L.Draw.SimpleShape.extend({\n\tstatics: {\n\t\tTYPE: 'rectangle'\n\t},\n\n\toptions: {\n\t\tshapeOptions: {\n\t\t\tstroke: true,\n\t\t\tcolor: '#3388ff',\n\t\t\tweight: 4,\n\t\t\topacity: 0.5,\n\t\t\tfill: true,\n\t\t\tfillColor: null, //same as color by default\n\t\t\tfillOpacity: 0.2,\n\t\t\tclickable: true\n\t\t},\n\t\tshowArea: true, //Whether to show the area in the tooltip\n\t\tmetric: true // Whether to use the metric measurement system or imperial\n\t},\n\n\t// @method initialize(): void\n\tinitialize: function (map, options) {\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\n\t\tthis.type = L.Draw.Rectangle.TYPE;\n\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.rectangle.tooltip.start;\n\n\t\tL.Draw.SimpleShape.prototype.initialize.call(this, map, options);\n\t},\n\n\t// @method disable(): void\n\tdisable: function () {\n\t\tif (!this._enabled) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._isCurrentlyTwoClickDrawing = false;\n\t\tL.Draw.SimpleShape.prototype.disable.call(this);\n\t},\n\n\t_onMouseUp: function (e) {\n\t\tif (!this._shape && !this._isCurrentlyTwoClickDrawing) {\n\t\t\tthis._isCurrentlyTwoClickDrawing = true;\n\t\t\treturn;\n\t\t}\n\n\t\t// Make sure closing click is on map\n\t\tif (this._isCurrentlyTwoClickDrawing && !_hasAncestor(e.target, 'leaflet-pane')) {\n\t\t\treturn;\n\t\t}\n\n\t\tL.Draw.SimpleShape.prototype._onMouseUp.call(this);\n\t},\n\n\t_drawShape: function (latlng) {\n\t\tif (!this._shape) {\n\t\t\tthis._shape = new L.Rectangle(new L.LatLngBounds(this._startLatLng, latlng), this.options.shapeOptions);\n\t\t\tthis._map.addLayer(this._shape);\n\t\t} else {\n\t\t\tthis._shape.setBounds(new L.LatLngBounds(this._startLatLng, latlng));\n\t\t}\n\t},\n\n\t_fireCreatedEvent: function () {\n\t\tvar rectangle = new L.Rectangle(this._shape.getBounds(), this.options.shapeOptions);\n\t\tL.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, rectangle);\n\t},\n\n\t_getTooltipText: function () {\n\t\tvar tooltipText = L.Draw.SimpleShape.prototype._getTooltipText.call(this),\n\t\t\tshape = this._shape,\n\t\t\tshowArea = this.options.showArea,\n\t\t\tlatLngs, area, subtext;\n\n\t\tif (shape) {\n\t\t\tlatLngs = this._shape._defaultShape ? this._shape._defaultShape() : this._shape.getLatLngs();\n\t\t\tarea = L.GeometryUtil.geodesicArea(latLngs);\n\t\t\tsubtext = showArea ? L.GeometryUtil.readableArea(area, this.options.metric) : '';\n\t\t}\n\n\t\treturn {\n\t\t\ttext: tooltipText.text,\n\t\t\tsubtext: subtext\n\t\t};\n\t}\n});\n\nfunction _hasAncestor(el, cls) {\n\twhile ((el = el.parentElement) && !el.classList.contains(cls)) {\n\t\t;\n\t}\n\treturn el;\n}\n","/**\n * @class L.Draw.Marker\n * @aka Draw.Marker\n * @inherits L.Draw.Feature\n */\nL.Draw.Marker = L.Draw.Feature.extend({\n\tstatics: {\n\t\tTYPE: 'marker'\n\t},\n\n\toptions: {\n\t\ticon: new L.Icon.Default(),\n\t\trepeatMode: false,\n\t\tzIndexOffset: 2000 // This should be > than the highest z-index any markers\n\t},\n\n\t// @method initialize(): void\n\tinitialize: function (map, options) {\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\n\t\tthis.type = L.Draw.Marker.TYPE;\n\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.marker.tooltip.start;\n\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\n\t},\n\n\t// @method addHooks(): void\n\t// Add listener hooks to this handler.\n\taddHooks: function () {\n\t\tL.Draw.Feature.prototype.addHooks.call(this);\n\n\t\tif (this._map) {\n\t\t\tthis._tooltip.updateContent({text: this._initialLabelText});\n\n\t\t\t// Same mouseMarker as in Draw.Polyline\n\t\t\tif (!this._mouseMarker) {\n\t\t\t\tthis._mouseMarker = L.marker(this._map.getCenter(), {\n\t\t\t\t\ticon: L.divIcon({\n\t\t\t\t\t\tclassName: 'leaflet-mouse-marker',\n\t\t\t\t\t\ticonAnchor: [20, 20],\n\t\t\t\t\t\ticonSize: [40, 40]\n\t\t\t\t\t}),\n\t\t\t\t\topacity: 0,\n\t\t\t\t\tzIndexOffset: this.options.zIndexOffset\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tthis._mouseMarker\n\t\t\t\t.on('click', this._onClick, this)\n\t\t\t\t.addTo(this._map);\n\n\t\t\tthis._map.on('mousemove', this._onMouseMove, this);\n\t\t\tthis._map.on('click', this._onTouch, this);\n\t\t}\n\t},\n\n\t// @method removeHooks(): void\n\t// Remove listener hooks from this handler.\n\tremoveHooks: function () {\n\t\tL.Draw.Feature.prototype.removeHooks.call(this);\n\n\t\tif (this._map) {\n\t\t\tthis._map\n\t\t\t\t.off('click', this._onClick, this)\n\t\t\t\t.off('click', this._onTouch, this);\n\t\t\tif (this._marker) {\n\t\t\t\tthis._marker.off('click', this._onClick, this);\n\t\t\t\tthis._map\n\t\t\t\t\t.removeLayer(this._marker);\n\t\t\t\tdelete this._marker;\n\t\t\t}\n\n\t\t\tthis._mouseMarker.off('click', this._onClick, this);\n\t\t\tthis._map.removeLayer(this._mouseMarker);\n\t\t\tdelete this._mouseMarker;\n\n\t\t\tthis._map.off('mousemove', this._onMouseMove, this);\n\t\t}\n\t},\n\n\t_onMouseMove: function (e) {\n\t\tvar latlng = e.latlng;\n\n\t\tthis._tooltip.updatePosition(latlng);\n\t\tthis._mouseMarker.setLatLng(latlng);\n\n\t\tif (!this._marker) {\n\t\t\tthis._marker = this._createMarker(latlng);\n\t\t\t// Bind to both marker and map to make sure we get the click event.\n\t\t\tthis._marker.on('click', this._onClick, this);\n\t\t\tthis._map\n\t\t\t\t.on('click', this._onClick, this)\n\t\t\t\t.addLayer(this._marker);\n\t\t}\n\t\telse {\n\t\t\tlatlng = this._mouseMarker.getLatLng();\n\t\t\tthis._marker.setLatLng(latlng);\n\t\t}\n\t},\n\n\t_createMarker: function (latlng) {\n\t\treturn new L.Marker(latlng, {\n\t\t\ticon: this.options.icon,\n\t\t\tzIndexOffset: this.options.zIndexOffset\n\t\t});\n\t},\n\n\t_onClick: function () {\n\t\tthis._fireCreatedEvent();\n\n\t\tthis.disable();\n\t\tif (this.options.repeatMode) {\n\t\t\tthis.enable();\n\t\t}\n\t},\n\n\t_onTouch: function (e) {\n\t\t// called on click & tap, only really does any thing on tap\n\t\tthis._onMouseMove(e); // creates & places marker\n\t\tthis._onClick(); // permanently places marker & ends interaction\n\t},\n\n\t_fireCreatedEvent: function () {\n\t\tvar marker = new L.Marker.Touch(this._marker.getLatLng(), {icon: this.options.icon});\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, marker);\n\t}\n});\n","/**\n * @class L.Draw.CircleMarker\n * @aka Draw.CircleMarker\n * @inherits L.Draw.Marker\n */\nL.Draw.CircleMarker = L.Draw.Marker.extend({\n\tstatics: {\n\t\tTYPE: 'circlemarker'\n\t},\n\n\toptions: {\n\t\tstroke: true,\n\t\tcolor: '#3388ff',\n\t\tweight: 4,\n\t\topacity: 0.5,\n\t\tfill: true,\n\t\tfillColor: null, //same as color by default\n\t\tfillOpacity: 0.2,\n\t\tclickable: true,\n\t\tzIndexOffset: 2000 // This should be > than the highest z-index any markers\n\t},\n\n\t// @method initialize(): void\n\tinitialize: function (map, options) {\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\n\t\tthis.type = L.Draw.CircleMarker.TYPE;\n\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.circlemarker.tooltip.start;\n\n\t\tL.Draw.Feature.prototype.initialize.call(this, map, options);\n\t},\n\n\n\t_fireCreatedEvent: function () {\n\t\tvar circleMarker = new L.CircleMarker(this._marker.getLatLng(), this.options);\n\t\tL.Draw.Feature.prototype._fireCreatedEvent.call(this, circleMarker);\n\t},\n\n\t_createMarker: function (latlng) {\n\t\treturn new L.CircleMarker(latlng, this.options);\n\t}\n});\n","/**\n * @class L.Draw.Circle\n * @aka Draw.Circle\n * @inherits L.Draw.SimpleShape\n */\nL.Draw.Circle = L.Draw.SimpleShape.extend({\n\tstatics: {\n\t\tTYPE: 'circle'\n\t},\n\n\toptions: {\n\t\tshapeOptions: {\n\t\t\tstroke: true,\n\t\t\tcolor: '#3388ff',\n\t\t\tweight: 4,\n\t\t\topacity: 0.5,\n\t\t\tfill: true,\n\t\t\tfillColor: null, //same as color by default\n\t\t\tfillOpacity: 0.2,\n\t\t\tclickable: true\n\t\t},\n\t\tshowRadius: true,\n\t\tmetric: true, // Whether to use the metric measurement system or imperial\n\t\tfeet: true, // When not metric, use feet instead of yards for display\n\t\tnautic: false // When not metric, not feet use nautic mile for display\n\t},\n\n\t// @method initialize(): void\n\tinitialize: function (map, options) {\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\n\t\tthis.type = L.Draw.Circle.TYPE;\n\n\t\tthis._initialLabelText = L.drawLocal.draw.handlers.circle.tooltip.start;\n\n\t\tL.Draw.SimpleShape.prototype.initialize.call(this, map, options);\n\t},\n\n\t_drawShape: function (latlng) {\n\t\t// Calculate the distance based on the version\n\t\tif (L.GeometryUtil.isVersion07x()) {\n\t\t\tvar distance = this._startLatLng.distanceTo(latlng);\n\t\t} else {\n\t\t\tvar distance = this._map.distance(this._startLatLng, latlng);\n\t\t}\n\n\t\tif (!this._shape) {\n\t\t\tthis._shape = new L.Circle(this._startLatLng, distance, this.options.shapeOptions);\n\t\t\tthis._map.addLayer(this._shape);\n\t\t} else {\n\t\t\tthis._shape.setRadius(distance);\n\t\t}\n\t},\n\n\t_fireCreatedEvent: function () {\n\t\tvar circle = new L.Circle(this._startLatLng, this._shape.getRadius(), this.options.shapeOptions);\n\t\tL.Draw.SimpleShape.prototype._fireCreatedEvent.call(this, circle);\n\t},\n\n\t_onMouseMove: function (e) {\n\t\tvar latlng = e.latlng,\n\t\t\tshowRadius = this.options.showRadius,\n\t\t\tuseMetric = this.options.metric,\n\t\t\tradius;\n\n\t\tthis._tooltip.updatePosition(latlng);\n\t\tif (this._isDrawing) {\n\t\t\tthis._drawShape(latlng);\n\n\t\t\t// Get the new radius (rounded to 1 dp)\n\t\t\tradius = this._shape.getRadius().toFixed(1);\n\n\t\t\tvar subtext = '';\n\t\t\tif (showRadius) {\n\t\t\t\tsubtext = L.drawLocal.draw.handlers.circle.radius + ': ' +\n\t\t\t\t\tL.GeometryUtil.readableDistance(radius, useMetric, this.options.feet, this.options.nautic);\n\t\t\t}\n\t\t\tthis._tooltip.updateContent({\n\t\t\t\ttext: this._endLabelText,\n\t\t\t\tsubtext: subtext\n\t\t\t});\n\t\t}\n\t}\n});\n","L.Edit = L.Edit || {};\n\n/**\n * @class L.Edit.Marker\n * @aka Edit.Marker\n */\nL.Edit.Marker = L.Handler.extend({\n\t// @method initialize(): void\n\tinitialize: function (marker, options) {\n\t\tthis._marker = marker;\n\t\tL.setOptions(this, options);\n\t},\n\n\t// @method addHooks(): void\n\t// Add listener hooks to this handler\n\taddHooks: function () {\n\t\tvar marker = this._marker;\n\n\t\tmarker.dragging.enable();\n\t\tmarker.on('dragend', this._onDragEnd, marker);\n\t\tthis._toggleMarkerHighlight();\n\t},\n\n\t// @method removeHooks(): void\n\t// Remove listener hooks from this handler\n\tremoveHooks: function () {\n\t\tvar marker = this._marker;\n\n\t\tmarker.dragging.disable();\n\t\tmarker.off('dragend', this._onDragEnd, marker);\n\t\tthis._toggleMarkerHighlight();\n\t},\n\n\t_onDragEnd: function (e) {\n\t\tvar layer = e.target;\n\t\tlayer.edited = true;\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: layer});\n\t},\n\n\t_toggleMarkerHighlight: function () {\n\t\tvar icon = this._marker._icon;\n\n\t\t// Don't do anything if this layer is a marker but doesn't have an icon. Markers\n\t\t// should usually have icons. If using Leaflet.draw with Leaflet.markercluster there\n\t\t// is a chance that a marker doesn't.\n\t\tif (!icon) {\n\t\t\treturn;\n\t\t}\n\n\t\t// This is quite naughty, but I don't see another way of doing it. (short of setting a new icon)\n\t\ticon.style.display = 'none';\n\n\t\tif (L.DomUtil.hasClass(icon, 'leaflet-edit-marker-selected')) {\n\t\t\tL.DomUtil.removeClass(icon, 'leaflet-edit-marker-selected');\n\t\t\t// Offset as the border will make the icon move.\n\t\t\tthis._offsetMarker(icon, -4);\n\n\t\t} else {\n\t\t\tL.DomUtil.addClass(icon, 'leaflet-edit-marker-selected');\n\t\t\t// Offset as the border will make the icon move.\n\t\t\tthis._offsetMarker(icon, 4);\n\t\t}\n\n\t\ticon.style.display = '';\n\t},\n\n\t_offsetMarker: function (icon, offset) {\n\t\tvar iconMarginTop = parseInt(icon.style.marginTop, 10) - offset,\n\t\t\ticonMarginLeft = parseInt(icon.style.marginLeft, 10) - offset;\n\n\t\ticon.style.marginTop = iconMarginTop + 'px';\n\t\ticon.style.marginLeft = iconMarginLeft + 'px';\n\t}\n});\n\nL.Marker.addInitHook(function () {\n\tif (L.Edit.Marker) {\n\t\tthis.editing = new L.Edit.Marker(this);\n\n\t\tif (this.options.editable) {\n\t\t\tthis.editing.enable();\n\t\t}\n\t}\n});\n","L.Edit = L.Edit || {};\n\n/**\n * @class L.Edit.Polyline\n * @aka L.Edit.Poly\n * @aka Edit.Poly\n */\nL.Edit.Poly = L.Handler.extend({\n\t// @method initialize(): void\n\tinitialize: function (poly) {\n\n\t\tthis.latlngs = [poly._latlngs];\n\t\tif (poly._holes) {\n\t\t\tthis.latlngs = this.latlngs.concat(poly._holes);\n\t\t}\n\n\t\tthis._poly = poly;\n\n\t\tthis._poly.on('revert-edited', this._updateLatLngs, this);\n\t},\n\n\t// Compatibility method to normalize Poly* objects\n\t// between 0.7.x and 1.0+\n\t_defaultShape: function () {\n\t\tif (!L.Polyline._flat) {\n\t\t\treturn this._poly._latlngs;\n\t\t}\n\t\treturn L.Polyline._flat(this._poly._latlngs) ? this._poly._latlngs : this._poly._latlngs[0];\n\t},\n\n\t_eachVertexHandler: function (callback) {\n\t\tfor (var i = 0; i < this._verticesHandlers.length; i++) {\n\t\t\tcallback(this._verticesHandlers[i]);\n\t\t}\n\t},\n\n\t// @method addHooks(): void\n\t// Add listener hooks to this handler\n\taddHooks: function () {\n\t\tthis._initHandlers();\n\t\tthis._eachVertexHandler(function (handler) {\n\t\t\thandler.addHooks();\n\t\t});\n\t},\n\n\t// @method removeHooks(): void\n\t// Remove listener hooks from this handler\n\tremoveHooks: function () {\n\t\tthis._eachVertexHandler(function (handler) {\n\t\t\thandler.removeHooks();\n\t\t});\n\t},\n\n\t// @method updateMarkers(): void\n\t// Fire an update for each vertex handler\n\tupdateMarkers: function () {\n\t\tthis._eachVertexHandler(function (handler) {\n\t\t\thandler.updateMarkers();\n\t\t});\n\t},\n\n\t_initHandlers: function () {\n\t\tthis._verticesHandlers = [];\n\t\tfor (var i = 0; i < this.latlngs.length; i++) {\n\t\t\tthis._verticesHandlers.push(new L.Edit.PolyVerticesEdit(this._poly, this.latlngs[i], this._poly.options.poly));\n\t\t}\n\t},\n\n\t_updateLatLngs: function (e) {\n\t\tthis.latlngs = [e.layer._latlngs];\n\t\tif (e.layer._holes) {\n\t\t\tthis.latlngs = this.latlngs.concat(e.layer._holes);\n\t\t}\n\t}\n\n});\n\n/**\n * @class L.Edit.PolyVerticesEdit\n * @aka Edit.PolyVerticesEdit\n */\nL.Edit.PolyVerticesEdit = L.Handler.extend({\n\toptions: {\n\t\ticon: new L.DivIcon({\n\t\t\ticonSize: new L.Point(8, 8),\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon'\n\t\t}),\n\t\ttouchIcon: new L.DivIcon({\n\t\t\ticonSize: new L.Point(20, 20),\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-touch-icon'\n\t\t}),\n\t\tdrawError: {\n\t\t\tcolor: '#b00b00',\n\t\t\ttimeout: 1000\n\t\t}\n\n\n\t},\n\n\t// @method intialize(): void\n\tinitialize: function (poly, latlngs, options) {\n\t\t// if touch, switch to touch icon\n\t\tif (L.Browser.touch) {\n\t\t\tthis.options.icon = this.options.touchIcon;\n\t\t}\n\t\tthis._poly = poly;\n\n\t\tif (options && options.drawError) {\n\t\t\toptions.drawError = L.Util.extend({}, this.options.drawError, options.drawError);\n\t\t}\n\n\t\tthis._latlngs = latlngs;\n\n\t\tL.setOptions(this, options);\n\t},\n\n\t// Compatibility method to normalize Poly* objects\n\t// between 0.7.x and 1.0+\n\t_defaultShape: function () {\n\t\tif (!L.Polyline._flat) {\n\t\t\treturn this._latlngs;\n\t\t}\n\t\treturn L.Polyline._flat(this._latlngs) ? this._latlngs : this._latlngs[0];\n\t},\n\n\t// @method addHooks(): void\n\t// Add listener hooks to this handler.\n\taddHooks: function () {\n\t\tvar poly = this._poly;\n\t\tvar path = poly._path;\n\n\t\tif (!(poly instanceof L.Polygon)) {\n\t\t\tpoly.options.fill = false;\n\t\t\tif (poly.options.editing) {\n\t\t\t\tpoly.options.editing.fill = false;\n\t\t\t}\n\t\t}\n\n\t\tif (path) {\n\t\t\tif (poly.options.editing && poly.options.editing.className) {\n\t\t\t\tif (poly.options.original.className) {\n\t\t\t\t\tpoly.options.original.className.split(' ').forEach(function (className) {\n\t\t\t\t\t\tL.DomUtil.removeClass(path, className);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tpoly.options.editing.className.split(' ').forEach(function (className) {\n\t\t\t\t\tL.DomUtil.addClass(path, className);\n\t\t\t\t});\n\t\t\t}\n\t\t}\n\n\t\tpoly.setStyle(poly.options.editing);\n\n\t\tif (this._poly._map) {\n\n\t\t\tthis._map = this._poly._map; // Set map\n\n\t\t\tif (!this._markerGroup) {\n\t\t\t\tthis._initMarkers();\n\t\t\t}\n\t\t\tthis._poly._map.addLayer(this._markerGroup);\n\t\t}\n\t},\n\n\t// @method removeHooks(): void\n\t// Remove listener hooks from this handler.\n\tremoveHooks: function () {\n\t\tvar poly = this._poly;\n\t\tvar path = poly._path;\n\n\t\tif (path) {\n\t\t\tif (poly.options.editing && poly.options.editing.className) {\n\t\t\t\tpoly.options.editing.className.split(' ').forEach(function (className) {\n\t\t\t\t\tL.DomUtil.removeClass(path, className);\n\t\t\t\t});\n\t\t\t\tif (poly.options.original.className) {\n\t\t\t\t\tpoly.options.original.className.split(' ').forEach(function (className) {\n\t\t\t\t\t\tL.DomUtil.addClass(path, className);\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tpoly.setStyle(poly.options.original);\n\n\t\tif (poly._map) {\n\t\t\tpoly._map.removeLayer(this._markerGroup);\n\t\t\tdelete this._markerGroup;\n\t\t\tdelete this._markers;\n\t\t}\n\t},\n\n\t// @method updateMarkers(): void\n\t// Clear markers and update their location\n\tupdateMarkers: function () {\n\t\tthis._markerGroup.clearLayers();\n\t\tthis._initMarkers();\n\t},\n\n\t_initMarkers: function () {\n\t\tif (!this._markerGroup) {\n\t\t\tthis._markerGroup = new L.LayerGroup();\n\t\t}\n\t\tthis._markers = [];\n\n\t\tvar latlngs = this._defaultShape(),\n\t\t\ti, j, len, marker;\n\n\t\tfor (i = 0, len = latlngs.length; i < len; i++) {\n\n\t\t\tmarker = this._createMarker(latlngs[i], i);\n\t\t\tmarker.on('click', this._onMarkerClick, this);\n\t\t\tmarker.on('contextmenu', this._onContextMenu, this);\n\t\t\tthis._markers.push(marker);\n\t\t}\n\n\t\tvar markerLeft, markerRight;\n\n\t\tfor (i = 0, j = len - 1; i < len; j = i++) {\n\t\t\tif (i === 0 && !(L.Polygon && (this._poly instanceof L.Polygon))) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tmarkerLeft = this._markers[j];\n\t\t\tmarkerRight = this._markers[i];\n\n\t\t\tthis._createMiddleMarker(markerLeft, markerRight);\n\t\t\tthis._updatePrevNext(markerLeft, markerRight);\n\t\t}\n\t},\n\n\t_createMarker: function (latlng, index) {\n\t\t// Extending L.Marker in TouchEvents.js to include touch.\n\t\tvar marker = new L.Marker.Touch(latlng, {\n\t\t\tdraggable: true,\n\t\t\ticon: this.options.icon,\n\t\t});\n\n\t\tmarker._origLatLng = latlng;\n\t\tmarker._index = index;\n\n\t\tmarker\n\t\t\t.on('dragstart', this._onMarkerDragStart, this)\n\t\t\t.on('drag', this._onMarkerDrag, this)\n\t\t\t.on('dragend', this._fireEdit, this)\n\t\t\t.on('touchmove', this._onTouchMove, this)\n\t\t\t.on('touchend', this._fireEdit, this)\n\t\t\t.on('MSPointerMove', this._onTouchMove, this)\n\t\t\t.on('MSPointerUp', this._fireEdit, this);\n\n\t\tthis._markerGroup.addLayer(marker);\n\n\t\treturn marker;\n\t},\n\n\t_onMarkerDragStart: function () {\n\t\tthis._poly.fire('editstart');\n\t},\n\n\t_spliceLatLngs: function () {\n\t\tvar latlngs = this._defaultShape();\n\t\tvar removed = [].splice.apply(latlngs, arguments);\n\t\tthis._poly._convertLatLngs(latlngs, true);\n\t\tthis._poly.redraw();\n\t\treturn removed;\n\t},\n\n\t_removeMarker: function (marker) {\n\t\tvar i = marker._index;\n\n\t\tthis._markerGroup.removeLayer(marker);\n\t\tthis._markers.splice(i, 1);\n\t\tthis._spliceLatLngs(i, 1);\n\t\tthis._updateIndexes(i, -1);\n\n\t\tmarker\n\t\t\t.off('dragstart', this._onMarkerDragStart, this)\n\t\t\t.off('drag', this._onMarkerDrag, this)\n\t\t\t.off('dragend', this._fireEdit, this)\n\t\t\t.off('touchmove', this._onMarkerDrag, this)\n\t\t\t.off('touchend', this._fireEdit, this)\n\t\t\t.off('click', this._onMarkerClick, this)\n\t\t\t.off('MSPointerMove', this._onTouchMove, this)\n\t\t\t.off('MSPointerUp', this._fireEdit, this);\n\t},\n\n\t_fireEdit: function () {\n\t\tthis._poly.edited = true;\n\t\tthis._poly.fire('edit');\n\t\tthis._poly._map.fire(L.Draw.Event.EDITVERTEX, {layers: this._markerGroup, poly: this._poly});\n\t},\n\n\t_onMarkerDrag: function (e) {\n\t\tvar marker = e.target;\n\t\tvar poly = this._poly;\n\n\t\tvar oldOrigLatLng = L.LatLngUtil.cloneLatLng(marker._origLatLng);\n\t\tL.extend(marker._origLatLng, marker._latlng);\n\t\tif (poly.options.poly) {\n\t\t\tvar tooltip = poly._map._editTooltip; // Access the tooltip\n\n\t\t\t// If we don't allow intersections and the polygon intersects\n\t\t\tif (!poly.options.poly.allowIntersection && poly.intersects()) {\n\t\t\t\tL.extend(marker._origLatLng, oldOrigLatLng);\n\t\t\t\tmarker.setLatLng(oldOrigLatLng);\n\t\t\t\tvar originalColor = poly.options.color;\n\t\t\t\tpoly.setStyle({color: this.options.drawError.color});\n\t\t\t\tif (tooltip) {\n\t\t\t\t\ttooltip.updateContent({\n\t\t\t\t\t\ttext: L.drawLocal.draw.handlers.polyline.error\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// Reset everything back to normal after a second\n\t\t\t\tsetTimeout(function () {\n\t\t\t\t\tpoly.setStyle({color: originalColor});\n\t\t\t\t\tif (tooltip) {\n\t\t\t\t\t\ttooltip.updateContent({\n\t\t\t\t\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\n\t\t\t\t\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t}, 1000);\n\t\t\t}\n\t\t}\n\n\t\tif (marker._middleLeft) {\n\t\t\tmarker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));\n\t\t}\n\t\tif (marker._middleRight) {\n\t\t\tmarker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));\n\t\t}\n\n\t\t//refresh the bounds when draging\n\t\tthis._poly._bounds._southWest = L.latLng(Infinity, Infinity);\n\t\tthis._poly._bounds._northEast = L.latLng(-Infinity, -Infinity);\n\t\tvar latlngs = this._poly.getLatLngs();\n\t\tthis._poly._convertLatLngs(latlngs, true);\n\t\tthis._poly.redraw();\n\t\tthis._poly.fire('editdrag');\n\t},\n\n\t_onMarkerClick: function (e) {\n\n\t\tvar minPoints = L.Polygon && (this._poly instanceof L.Polygon) ? 4 : 3,\n\t\t\tmarker = e.target;\n\n\t\t// If removing this point would create an invalid polyline/polygon don't remove\n\t\tif (this._defaultShape().length < minPoints) {\n\t\t\treturn;\n\t\t}\n\n\t\t// remove the marker\n\t\tthis._removeMarker(marker);\n\n\t\t// update prev/next links of adjacent markers\n\t\tthis._updatePrevNext(marker._prev, marker._next);\n\n\t\t// remove ghost markers near the removed marker\n\t\tif (marker._middleLeft) {\n\t\t\tthis._markerGroup.removeLayer(marker._middleLeft);\n\t\t}\n\t\tif (marker._middleRight) {\n\t\t\tthis._markerGroup.removeLayer(marker._middleRight);\n\t\t}\n\n\t\t// create a ghost marker in place of the removed one\n\t\tif (marker._prev && marker._next) {\n\t\t\tthis._createMiddleMarker(marker._prev, marker._next);\n\n\t\t} else if (!marker._prev) {\n\t\t\tmarker._next._middleLeft = null;\n\n\t\t} else if (!marker._next) {\n\t\t\tmarker._prev._middleRight = null;\n\t\t}\n\n\t\tthis._fireEdit();\n\t},\n\n\t_onContextMenu: function (e) {\n\t\tvar marker = e.target;\n\t\tvar poly = this._poly;\n\t\tthis._poly._map.fire(L.Draw.Event.MARKERCONTEXT, {marker: marker, layers: this._markerGroup, poly: this._poly});\n\t\tL.DomEvent.stopPropagation;\n\t},\n\n\t_onTouchMove: function (e) {\n\n\t\tvar layerPoint = this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]),\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint),\n\t\t\tmarker = e.target;\n\n\t\tL.extend(marker._origLatLng, latlng);\n\n\t\tif (marker._middleLeft) {\n\t\t\tmarker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));\n\t\t}\n\t\tif (marker._middleRight) {\n\t\t\tmarker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));\n\t\t}\n\n\t\tthis._poly.redraw();\n\t\tthis.updateMarkers();\n\t},\n\n\t_updateIndexes: function (index, delta) {\n\t\tthis._markerGroup.eachLayer(function (marker) {\n\t\t\tif (marker._index > index) {\n\t\t\t\tmarker._index += delta;\n\t\t\t}\n\t\t});\n\t},\n\n\t_createMiddleMarker: function (marker1, marker2) {\n\t\tvar latlng = this._getMiddleLatLng(marker1, marker2),\n\t\t\tmarker = this._createMarker(latlng),\n\t\t\tonClick,\n\t\t\tonDragStart,\n\t\t\tonDragEnd;\n\n\t\tmarker.setOpacity(0.6);\n\n\t\tmarker1._middleRight = marker2._middleLeft = marker;\n\n\t\tonDragStart = function () {\n\t\t\tmarker.off('touchmove', onDragStart, this);\n\t\t\tvar i = marker2._index;\n\n\t\t\tmarker._index = i;\n\n\t\t\tmarker\n\t\t\t\t.off('click', onClick, this)\n\t\t\t\t.on('click', this._onMarkerClick, this);\n\n\t\t\tlatlng.lat = marker.getLatLng().lat;\n\t\t\tlatlng.lng = marker.getLatLng().lng;\n\t\t\tthis._spliceLatLngs(i, 0, latlng);\n\t\t\tthis._markers.splice(i, 0, marker);\n\n\t\t\tmarker.setOpacity(1);\n\n\t\t\tthis._updateIndexes(i, 1);\n\t\t\tmarker2._index++;\n\t\t\tthis._updatePrevNext(marker1, marker);\n\t\t\tthis._updatePrevNext(marker, marker2);\n\n\t\t\tthis._poly.fire('editstart');\n\t\t};\n\n\t\tonDragEnd = function () {\n\t\t\tmarker.off('dragstart', onDragStart, this);\n\t\t\tmarker.off('dragend', onDragEnd, this);\n\t\t\tmarker.off('touchmove', onDragStart, this);\n\n\t\t\tthis._createMiddleMarker(marker1, marker);\n\t\t\tthis._createMiddleMarker(marker, marker2);\n\t\t};\n\n\t\tonClick = function () {\n\t\t\tonDragStart.call(this);\n\t\t\tonDragEnd.call(this);\n\t\t\tthis._fireEdit();\n\t\t};\n\n\t\tmarker\n\t\t\t.on('click', onClick, this)\n\t\t\t.on('dragstart', onDragStart, this)\n\t\t\t.on('dragend', onDragEnd, this)\n\t\t\t.on('touchmove', onDragStart, this);\n\n\t\tthis._markerGroup.addLayer(marker);\n\t},\n\n\t_updatePrevNext: function (marker1, marker2) {\n\t\tif (marker1) {\n\t\t\tmarker1._next = marker2;\n\t\t}\n\t\tif (marker2) {\n\t\t\tmarker2._prev = marker1;\n\t\t}\n\t},\n\n\t_getMiddleLatLng: function (marker1, marker2) {\n\t\tvar map = this._poly._map,\n\t\t\tp1 = map.project(marker1.getLatLng()),\n\t\t\tp2 = map.project(marker2.getLatLng());\n\n\t\treturn map.unproject(p1._add(p2)._divideBy(2));\n\t}\n});\n\nL.Polyline.addInitHook(function () {\n\n\t// Check to see if handler has already been initialized. This is to support versions of Leaflet that still have L.Handler.PolyEdit\n\tif (this.editing) {\n\t\treturn;\n\t}\n\n\tif (L.Edit.Poly) {\n\n\t\tthis.editing = new L.Edit.Poly(this);\n\n\t\tif (this.options.editable) {\n\t\t\tthis.editing.enable();\n\t\t}\n\t}\n\n\tthis.on('add', function () {\n\t\tif (this.editing && this.editing.enabled()) {\n\t\t\tthis.editing.addHooks();\n\t\t}\n\t});\n\n\tthis.on('remove', function () {\n\t\tif (this.editing && this.editing.enabled()) {\n\t\t\tthis.editing.removeHooks();\n\t\t}\n\t});\n});\n","L.Edit = L.Edit || {};\n/**\n * @class L.Edit.SimpleShape\n * @aka Edit.SimpleShape\n */\nL.Edit.SimpleShape = L.Handler.extend({\n\toptions: {\n\t\tmoveIcon: new L.DivIcon({\n\t\t\ticonSize: new L.Point(8, 8),\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move'\n\t\t}),\n\t\tresizeIcon: new L.DivIcon({\n\t\t\ticonSize: new L.Point(8, 8),\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize'\n\t\t}),\n\t\ttouchMoveIcon: new L.DivIcon({\n\t\t\ticonSize: new L.Point(20, 20),\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move leaflet-touch-icon'\n\t\t}),\n\t\ttouchResizeIcon: new L.DivIcon({\n\t\t\ticonSize: new L.Point(20, 20),\n\t\t\tclassName: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-resize leaflet-touch-icon'\n\t\t}),\n\t},\n\n\t// @method intialize(): void\n\tinitialize: function (shape, options) {\n\t\t// if touch, switch to touch icon\n\t\tif (L.Browser.touch) {\n\t\t\tthis.options.moveIcon = this.options.touchMoveIcon;\n\t\t\tthis.options.resizeIcon = this.options.touchResizeIcon;\n\t\t}\n\n\t\tthis._shape = shape;\n\t\tL.Util.setOptions(this, options);\n\t},\n\n\t// @method addHooks(): void\n\t// Add listener hooks to this handler\n\taddHooks: function () {\n\t\tvar shape = this._shape;\n\t\tif (this._shape._map) {\n\t\t\tthis._map = this._shape._map;\n\t\t\tshape.setStyle(shape.options.editing);\n\n\t\t\tif (shape._map) {\n\t\t\t\tthis._map = shape._map;\n\t\t\t\tif (!this._markerGroup) {\n\t\t\t\t\tthis._initMarkers();\n\t\t\t\t}\n\t\t\t\tthis._map.addLayer(this._markerGroup);\n\t\t\t}\n\t\t}\n\t},\n\n\t// @method removeHooks(): void\n\t// Remove listener hooks from this handler\n\tremoveHooks: function () {\n\t\tvar shape = this._shape;\n\n\t\tshape.setStyle(shape.options.original);\n\n\t\tif (shape._map) {\n\t\t\tthis._unbindMarker(this._moveMarker);\n\n\t\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\n\t\t\t\tthis._unbindMarker(this._resizeMarkers[i]);\n\t\t\t}\n\t\t\tthis._resizeMarkers = null;\n\n\t\t\tthis._map.removeLayer(this._markerGroup);\n\t\t\tdelete this._markerGroup;\n\t\t}\n\n\t\tthis._map = null;\n\t},\n\n\t// @method updateMarkers(): void\n\t// Remove the edit markers from this layer\n\tupdateMarkers: function () {\n\t\tthis._markerGroup.clearLayers();\n\t\tthis._initMarkers();\n\t},\n\n\t_initMarkers: function () {\n\t\tif (!this._markerGroup) {\n\t\t\tthis._markerGroup = new L.LayerGroup();\n\t\t}\n\n\t\t// Create center marker\n\t\tthis._createMoveMarker();\n\n\t\t// Create edge marker\n\t\tthis._createResizeMarker();\n\t},\n\n\t_createMoveMarker: function () {\n\t\t// Children override\n\t},\n\n\t_createResizeMarker: function () {\n\t\t// Children override\n\t},\n\n\t_createMarker: function (latlng, icon) {\n\t\t// Extending L.Marker in TouchEvents.js to include touch.\n\t\tvar marker = new L.Marker.Touch(latlng, {\n\t\t\tdraggable: true,\n\t\t\ticon: icon,\n\t\t\tzIndexOffset: 10\n\t\t});\n\n\t\tthis._bindMarker(marker);\n\n\t\tthis._markerGroup.addLayer(marker);\n\n\t\treturn marker;\n\t},\n\n\t_bindMarker: function (marker) {\n\t\tmarker\n\t\t\t.on('dragstart', this._onMarkerDragStart, this)\n\t\t\t.on('drag', this._onMarkerDrag, this)\n\t\t\t.on('dragend', this._onMarkerDragEnd, this)\n\t\t\t.on('touchstart', this._onTouchStart, this)\n\t\t\t.on('touchmove', this._onTouchMove, this)\n\t\t\t.on('MSPointerMove', this._onTouchMove, this)\n\t\t\t.on('touchend', this._onTouchEnd, this)\n\t\t\t.on('MSPointerUp', this._onTouchEnd, this);\n\t},\n\n\t_unbindMarker: function (marker) {\n\t\tmarker\n\t\t\t.off('dragstart', this._onMarkerDragStart, this)\n\t\t\t.off('drag', this._onMarkerDrag, this)\n\t\t\t.off('dragend', this._onMarkerDragEnd, this)\n\t\t\t.off('touchstart', this._onTouchStart, this)\n\t\t\t.off('touchmove', this._onTouchMove, this)\n\t\t\t.off('MSPointerMove', this._onTouchMove, this)\n\t\t\t.off('touchend', this._onTouchEnd, this)\n\t\t\t.off('MSPointerUp', this._onTouchEnd, this);\n\t},\n\n\t_onMarkerDragStart: function (e) {\n\t\tvar marker = e.target;\n\t\tmarker.setOpacity(0);\n\n\t\tthis._shape.fire('editstart');\n\t},\n\n\t_fireEdit: function () {\n\t\tthis._shape.edited = true;\n\t\tthis._shape.fire('edit');\n\t},\n\n\t_onMarkerDrag: function (e) {\n\t\tvar marker = e.target,\n\t\t\tlatlng = marker.getLatLng();\n\n\t\tif (marker === this._moveMarker) {\n\t\t\tthis._move(latlng);\n\t\t} else {\n\t\t\tthis._resize(latlng);\n\t\t}\n\n\t\tthis._shape.redraw();\n\t\tthis._shape.fire('editdrag');\n\t},\n\n\t_onMarkerDragEnd: function (e) {\n\t\tvar marker = e.target;\n\t\tmarker.setOpacity(1);\n\n\t\tthis._fireEdit();\n\t},\n\n\t_onTouchStart: function (e) {\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e);\n\n\t\tif (typeof(this._getCorners) === 'function') {\n\t\t\t// Save a reference to the opposite point\n\t\t\tvar corners = this._getCorners(),\n\t\t\t\tmarker = e.target,\n\t\t\t\tcurrentCornerIndex = marker._cornerIndex;\n\n\t\t\tmarker.setOpacity(0);\n\n\t\t\t// Copyed from Edit.Rectangle.js line 23 _onMarkerDragStart()\n\t\t\t// Latlng is null otherwise.\n\t\t\tthis._oppositeCorner = corners[(currentCornerIndex + 2) % 4];\n\t\t\tthis._toggleCornerMarkers(0, currentCornerIndex);\n\t\t}\n\n\t\tthis._shape.fire('editstart');\n\t},\n\n\t_onTouchMove: function (e) {\n\t\tvar layerPoint = this._map.mouseEventToLayerPoint(e.originalEvent.touches[0]),\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint),\n\t\t\tmarker = e.target;\n\n\t\tif (marker === this._moveMarker) {\n\t\t\tthis._move(latlng);\n\t\t} else {\n\t\t\tthis._resize(latlng);\n\t\t}\n\n\t\tthis._shape.redraw();\n\n\t\t// prevent touchcancel in IOS\n\t\t// e.preventDefault();\n\t\treturn false;\n\t},\n\n\t_onTouchEnd: function (e) {\n\t\tvar marker = e.target;\n\t\tmarker.setOpacity(1);\n\t\tthis.updateMarkers();\n\t\tthis._fireEdit();\n\t},\n\n\t_move: function () {\n\t\t// Children override\n\t},\n\n\t_resize: function () {\n\t\t// Children override\n\t}\n});\n","L.Edit = L.Edit || {};\n/**\n * @class L.Edit.Rectangle\n * @aka Edit.Rectangle\n * @inherits L.Edit.SimpleShape\n */\nL.Edit.Rectangle = L.Edit.SimpleShape.extend({\n\t_createMoveMarker: function () {\n\t\tvar bounds = this._shape.getBounds(),\n\t\t\tcenter = bounds.getCenter();\n\n\t\tthis._moveMarker = this._createMarker(center, this.options.moveIcon);\n\t},\n\n\t_createResizeMarker: function () {\n\t\tvar corners = this._getCorners();\n\n\t\tthis._resizeMarkers = [];\n\n\t\tfor (var i = 0, l = corners.length; i < l; i++) {\n\t\t\tthis._resizeMarkers.push(this._createMarker(corners[i], this.options.resizeIcon));\n\t\t\t// Monkey in the corner index as we will need to know this for dragging\n\t\t\tthis._resizeMarkers[i]._cornerIndex = i;\n\t\t}\n\t},\n\n\t_onMarkerDragStart: function (e) {\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragStart.call(this, e);\n\n\t\t// Save a reference to the opposite point\n\t\tvar corners = this._getCorners(),\n\t\t\tmarker = e.target,\n\t\t\tcurrentCornerIndex = marker._cornerIndex;\n\n\t\tthis._oppositeCorner = corners[(currentCornerIndex + 2) % 4];\n\n\t\tthis._toggleCornerMarkers(0, currentCornerIndex);\n\t},\n\n\t_onMarkerDragEnd: function (e) {\n\t\tvar marker = e.target,\n\t\t\tbounds, center;\n\n\t\t// Reset move marker position to the center\n\t\tif (marker === this._moveMarker) {\n\t\t\tbounds = this._shape.getBounds();\n\t\t\tcenter = bounds.getCenter();\n\n\t\t\tmarker.setLatLng(center);\n\t\t}\n\n\t\tthis._toggleCornerMarkers(1);\n\n\t\tthis._repositionCornerMarkers();\n\n\t\tL.Edit.SimpleShape.prototype._onMarkerDragEnd.call(this, e);\n\t},\n\n\t_move: function (newCenter) {\n\t\tvar latlngs = this._shape._defaultShape ? this._shape._defaultShape() : this._shape.getLatLngs(),\n\t\t\tbounds = this._shape.getBounds(),\n\t\t\tcenter = bounds.getCenter(),\n\t\t\toffset, newLatLngs = [];\n\n\t\t// Offset the latlngs to the new center\n\t\tfor (var i = 0, l = latlngs.length; i < l; i++) {\n\t\t\toffset = [latlngs[i].lat - center.lat, latlngs[i].lng - center.lng];\n\t\t\tnewLatLngs.push([newCenter.lat + offset[0], newCenter.lng + offset[1]]);\n\t\t}\n\n\t\tthis._shape.setLatLngs(newLatLngs);\n\n\t\t// Reposition the resize markers\n\t\tthis._repositionCornerMarkers();\n\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: this._shape});\n\t},\n\n\t_resize: function (latlng) {\n\t\tvar bounds;\n\n\t\t// Update the shape based on the current position of this corner and the opposite point\n\t\tthis._shape.setBounds(L.latLngBounds(latlng, this._oppositeCorner));\n\n\t\t// Reposition the move marker\n\t\tbounds = this._shape.getBounds();\n\t\tthis._moveMarker.setLatLng(bounds.getCenter());\n\n\t\tthis._map.fire(L.Draw.Event.EDITRESIZE, {layer: this._shape});\n\t},\n\n\t_getCorners: function () {\n\t\tvar bounds = this._shape.getBounds(),\n\t\t\tnw = bounds.getNorthWest(),\n\t\t\tne = bounds.getNorthEast(),\n\t\t\tse = bounds.getSouthEast(),\n\t\t\tsw = bounds.getSouthWest();\n\n\t\treturn [nw, ne, se, sw];\n\t},\n\n\t_toggleCornerMarkers: function (opacity) {\n\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\n\t\t\tthis._resizeMarkers[i].setOpacity(opacity);\n\t\t}\n\t},\n\n\t_repositionCornerMarkers: function () {\n\t\tvar corners = this._getCorners();\n\n\t\tfor (var i = 0, l = this._resizeMarkers.length; i < l; i++) {\n\t\t\tthis._resizeMarkers[i].setLatLng(corners[i]);\n\t\t}\n\t}\n});\n\nL.Rectangle.addInitHook(function () {\n\tif (L.Edit.Rectangle) {\n\t\tthis.editing = new L.Edit.Rectangle(this);\n\n\t\tif (this.options.editable) {\n\t\t\tthis.editing.enable();\n\t\t}\n\t}\n});\n","L.Edit = L.Edit || {};\n/**\n * @class L.Edit.CircleMarker\n * @aka Edit.Circle\n * @inherits L.Edit.SimpleShape\n */\nL.Edit.CircleMarker = L.Edit.SimpleShape.extend({\n\t_createMoveMarker: function () {\n\t\tvar center = this._shape.getLatLng();\n\n\t\tthis._moveMarker = this._createMarker(center, this.options.moveIcon);\n\t},\n\n\t_createResizeMarker: function () {\n\t\t// To avoid an undefined check in L.Edit.SimpleShape.removeHooks\n\t\tthis._resizeMarkers = [];\n\t},\n\n\t_move: function (latlng) {\n\t\tif (this._resizeMarkers.length) {\n\t\t\tvar resizemarkerPoint = this._getResizeMarkerPoint(latlng);\n\t\t\t// Move the resize marker\n\t\t\tthis._resizeMarkers[0].setLatLng(resizemarkerPoint);\n\t\t}\n\n\t\t// Move the circle\n\t\tthis._shape.setLatLng(latlng);\n\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: this._shape});\n\t},\n});\n\nL.CircleMarker.addInitHook(function () {\n\tif (L.Edit.CircleMarker) {\n\t\tthis.editing = new L.Edit.CircleMarker(this);\n\n\t\tif (this.options.editable) {\n\t\t\tthis.editing.enable();\n\t\t}\n\t}\n\n\tthis.on('add', function () {\n\t\tif (this.editing && this.editing.enabled()) {\n\t\t\tthis.editing.addHooks();\n\t\t}\n\t});\n\n\tthis.on('remove', function () {\n\t\tif (this.editing && this.editing.enabled()) {\n\t\t\tthis.editing.removeHooks();\n\t\t}\n\t});\n});\n","L.Edit = L.Edit || {};\n/**\n * @class L.Edit.Circle\n * @aka Edit.Circle\n * @inherits L.Edit.CircleMarker\n */\nL.Edit.Circle = L.Edit.CircleMarker.extend({\n\n\t_createResizeMarker: function () {\n\t\tvar center = this._shape.getLatLng(),\n\t\t\tresizemarkerPoint = this._getResizeMarkerPoint(center);\n\n\t\tthis._resizeMarkers = [];\n\t\tthis._resizeMarkers.push(this._createMarker(resizemarkerPoint, this.options.resizeIcon));\n\t},\n\n\t_getResizeMarkerPoint: function (latlng) {\n\t\t// From L.shape.getBounds()\n\t\tvar delta = this._shape._radius * Math.cos(Math.PI / 4),\n\t\t\tpoint = this._map.project(latlng);\n\t\treturn this._map.unproject([point.x + delta, point.y - delta]);\n\t},\n\n\t_resize: function (latlng) {\n\t\tvar moveLatLng = this._moveMarker.getLatLng();\n\n\t\t// Calculate the radius based on the version\n\t\tif (L.GeometryUtil.isVersion07x()) {\n\t\t\tradius = moveLatLng.distanceTo(latlng);\n\t\t} else {\n\t\t\tradius = this._map.distance(moveLatLng, latlng);\n\t\t}\n\t\tthis._shape.setRadius(radius);\n\n\t\tif (this._map.editTooltip) {\n\t\t\tthis._map._editTooltip.updateContent({\n\t\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.subtext + ' ' + L.drawLocal.edit.handlers.edit.tooltip.text,\n\t\t\t\tsubtext: L.drawLocal.draw.handlers.circle.radius + ': ' +\n\t\t\t\tL.GeometryUtil.readableDistance(radius, true, this.options.feet, this.options.nautic)\n\t\t\t});\n\t\t}\n\n\t\tthis._shape.setRadius(radius);\n\n\t\tthis._map.fire(L.Draw.Event.EDITRESIZE, {layer: this._shape});\n\t}\n});\n\nL.Circle.addInitHook(function () {\n\tif (L.Edit.Circle) {\n\t\tthis.editing = new L.Edit.Circle(this);\n\n\t\tif (this.options.editable) {\n\t\t\tthis.editing.enable();\n\t\t}\n\t}\n});\n","L.Map.mergeOptions({\n\ttouchExtend: true\n});\n\n/**\n * @class L.Map.TouchExtend\n * @aka TouchExtend\n */\nL.Map.TouchExtend = L.Handler.extend({\n\n\t// @method initialize(): void\n\t// Sets TouchExtend private accessor variables\n\tinitialize: function (map) {\n\t\tthis._map = map;\n\t\tthis._container = map._container;\n\t\tthis._pane = map._panes.overlayPane;\n\t},\n\n\t// @method addHooks(): void\n\t// Adds dom listener events to the map container\n\taddHooks: function () {\n\t\tL.DomEvent.on(this._container, 'touchstart', this._onTouchStart, this);\n\t\tL.DomEvent.on(this._container, 'touchend', this._onTouchEnd, this);\n\t\tL.DomEvent.on(this._container, 'touchmove', this._onTouchMove, this);\n\t\tif (this._detectIE()) {\n\t\t\tL.DomEvent.on(this._container, 'MSPointerDown', this._onTouchStart, this);\n\t\t\tL.DomEvent.on(this._container, 'MSPointerUp', this._onTouchEnd, this);\n\t\t\tL.DomEvent.on(this._container, 'MSPointerMove', this._onTouchMove, this);\n\t\t\tL.DomEvent.on(this._container, 'MSPointerCancel', this._onTouchCancel, this);\n\n\t\t} else {\n\t\t\tL.DomEvent.on(this._container, 'touchcancel', this._onTouchCancel, this);\n\t\t\tL.DomEvent.on(this._container, 'touchleave', this._onTouchLeave, this);\n\t\t}\n\t},\n\n\t// @method removeHooks(): void\n\t// Removes dom listener events from the map container\n\tremoveHooks: function () {\n\t\tL.DomEvent.off(this._container, 'touchstart', this._onTouchStart, this);\n\t\tL.DomEvent.off(this._container, 'touchend', this._onTouchEnd, this);\n\t\tL.DomEvent.off(this._container, 'touchmove', this._onTouchMove, this);\n\t\tif (this._detectIE()) {\n\t\t\tL.DomEvent.off(this._container, 'MSPointerDown', this._onTouchStart, this);\n\t\t\tL.DomEvent.off(this._container, 'MSPointerUp', this._onTouchEnd, this);\n\t\t\tL.DomEvent.off(this._container, 'MSPointerMove', this._onTouchMove, this);\n\t\t\tL.DomEvent.off(this._container, 'MSPointerCancel', this._onTouchCancel, this);\n\t\t} else {\n\t\t\tL.DomEvent.off(this._container, 'touchcancel', this._onTouchCancel, this);\n\t\t\tL.DomEvent.off(this._container, 'touchleave', this._onTouchLeave, this);\n\t\t}\n\t},\n\n\t_touchEvent: function (e, type) {\n\t\t// #TODO: fix the pageX error that is do a bug in Android where a single touch triggers two click events\n\t\t// _filterClick is what leaflet uses as a workaround.\n\t\t// This is a problem with more things than just android. Another problem is touchEnd has no touches in\n\t\t// its touch list.\n\t\tvar touchEvent = {};\n\t\tif (typeof e.touches !== 'undefined') {\n\t\t\tif (!e.touches.length) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttouchEvent = e.touches[0];\n\t\t} else if (e.pointerType === 'touch') {\n\t\t\ttouchEvent = e;\n\t\t\tif (!this._filterClick(e)) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t} else {\n\t\t\treturn;\n\t\t}\n\n\t\tvar containerPoint = this._map.mouseEventToContainerPoint(touchEvent),\n\t\t\tlayerPoint = this._map.mouseEventToLayerPoint(touchEvent),\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint);\n\n\t\tthis._map.fire(type, {\n\t\t\tlatlng: latlng,\n\t\t\tlayerPoint: layerPoint,\n\t\t\tcontainerPoint: containerPoint,\n\t\t\tpageX: touchEvent.pageX,\n\t\t\tpageY: touchEvent.pageY,\n\t\t\toriginalEvent: e\n\t\t});\n\t},\n\n\t/** Borrowed from Leaflet and modified for bool ops **/\n\t_filterClick: function (e) {\n\t\tvar timeStamp = (e.timeStamp || e.originalEvent.timeStamp),\n\t\t\telapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick);\n\n\t\t// are they closer together than 500ms yet more than 100ms?\n\t\t// Android typically triggers them ~300ms apart while multiple listeners\n\t\t// on the same event should be triggered far faster;\n\t\t// or check if click is simulated on the element, and if it is, reject any non-simulated events\n\t\tif ((elapsed && elapsed > 100 && elapsed < 500) || (e.target._simulatedClick && !e._simulated)) {\n\t\t\tL.DomEvent.stop(e);\n\t\t\treturn false;\n\t\t}\n\t\tL.DomEvent._lastClick = timeStamp;\n\t\treturn true;\n\t},\n\n\t_onTouchStart: function (e) {\n\t\tif (!this._map._loaded) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar type = 'touchstart';\n\t\tthis._touchEvent(e, type);\n\n\t},\n\n\t_onTouchEnd: function (e) {\n\t\tif (!this._map._loaded) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar type = 'touchend';\n\t\tthis._touchEvent(e, type);\n\t},\n\n\t_onTouchCancel: function (e) {\n\t\tif (!this._map._loaded) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar type = 'touchcancel';\n\t\tif (this._detectIE()) {\n\t\t\ttype = 'pointercancel';\n\t\t}\n\t\tthis._touchEvent(e, type);\n\t},\n\n\t_onTouchLeave: function (e) {\n\t\tif (!this._map._loaded) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar type = 'touchleave';\n\t\tthis._touchEvent(e, type);\n\t},\n\n\t_onTouchMove: function (e) {\n\t\tif (!this._map._loaded) {\n\t\t\treturn;\n\t\t}\n\n\t\tvar type = 'touchmove';\n\t\tthis._touchEvent(e, type);\n\t},\n\n\t_detectIE: function () {\n\t\tvar ua = window.navigator.userAgent;\n\n\t\tvar msie = ua.indexOf('MSIE ');\n\t\tif (msie > 0) {\n\t\t\t// IE 10 or older => return version number\n\t\t\treturn parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);\n\t\t}\n\n\t\tvar trident = ua.indexOf('Trident/');\n\t\tif (trident > 0) {\n\t\t\t// IE 11 => return version number\n\t\t\tvar rv = ua.indexOf('rv:');\n\t\t\treturn parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);\n\t\t}\n\n\t\tvar edge = ua.indexOf('Edge/');\n\t\tif (edge > 0) {\n\t\t\t// IE 12 => return version number\n\t\t\treturn parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);\n\t\t}\n\n\t\t// other browser\n\t\treturn false;\n\t}\n});\n\nL.Map.addInitHook('addHandler', 'touchExtend', L.Map.TouchExtend);\n\n\n/**\n * @class L.Marker.Touch\n * @aka Marker.Touch\n *\n * This isn't full Touch support. This is just to get markers to also support dom touch events after creation\n * #TODO: find a better way of getting markers to support touch.\n */\nL.Marker.Touch = L.Marker.extend({\n\n\t_initInteraction: function () {\n\t\tif (!this.addInteractiveTarget) {\n\t\t\t// 0.7.x support\n\t\t\treturn this._initInteractionLegacy();\n\t\t}\n\t\t// TODO this may need be updated to re-add touch events for 1.0+\n\t\treturn L.Marker.prototype._initInteraction.apply(this);\n\t},\n\n\t// This is an exact copy of https://github.com/Leaflet/Leaflet/blob/v0.7/src/layer/marker/Marker.js\n\t// with the addition of the touch events\n\t_initInteractionLegacy: function () {\n\n\t\tif (!this.options.clickable) {\n\t\t\treturn;\n\t\t}\n\n\t\t// TODO refactor into something shared with Map/Path/etc. to DRY it up\n\n\t\tvar icon = this._icon,\n\t\t\tevents = ['dblclick',\n\t\t\t\t'mousedown',\n\t\t\t\t'mouseover',\n\t\t\t\t'mouseout',\n\t\t\t\t'contextmenu',\n\t\t\t\t'touchstart',\n\t\t\t\t'touchend',\n\t\t\t\t'touchmove'];\n\t\tif (this._detectIE) {\n\t\t\tevents.concat(['MSPointerDown',\n\t\t\t\t'MSPointerUp',\n\t\t\t\t'MSPointerMove',\n\t\t\t\t'MSPointerCancel']);\n\t\t} else {\n\t\t\tevents.concat(['touchcancel']);\n\t\t}\n\n\t\tL.DomUtil.addClass(icon, 'leaflet-clickable');\n\t\tL.DomEvent.on(icon, 'click', this._onMouseClick, this);\n\t\tL.DomEvent.on(icon, 'keypress', this._onKeyPress, this);\n\n\t\tfor (var i = 0; i < events.length; i++) {\n\t\t\tL.DomEvent.on(icon, events[i], this._fireMouseEvent, this);\n\t\t}\n\n\t\tif (L.Handler.MarkerDrag) {\n\t\t\tthis.dragging = new L.Handler.MarkerDrag(this);\n\n\t\t\tif (this.options.draggable) {\n\t\t\t\tthis.dragging.enable();\n\t\t\t}\n\t\t}\n\t},\n\n\t_detectIE: function () {\n\t\tvar ua = window.navigator.userAgent;\n\n\t\tvar msie = ua.indexOf('MSIE ');\n\t\tif (msie > 0) {\n\t\t\t// IE 10 or older => return version number\n\t\t\treturn parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10);\n\t\t}\n\n\t\tvar trident = ua.indexOf('Trident/');\n\t\tif (trident > 0) {\n\t\t\t// IE 11 => return version number\n\t\t\tvar rv = ua.indexOf('rv:');\n\t\t\treturn parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10);\n\t\t}\n\n\t\tvar edge = ua.indexOf('Edge/');\n\t\tif (edge > 0) {\n\t\t\t// IE 12 => return version number\n\t\t\treturn parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10);\n\t\t}\n\n\t\t// other browser\n\t\treturn false;\n\t}\n});\n","/**\n * @class L.LatLngUtil\n * @aka LatLngUtil\n */\nL.LatLngUtil = {\n\t// Clones a LatLngs[], returns [][]\n\n\t// @method cloneLatLngs(LatLngs[]): L.LatLngs[]\n\t// Clone the latLng point or points or nested points and return an array with those points\n\tcloneLatLngs: function (latlngs) {\n\t\tvar clone = [];\n\t\tfor (var i = 0, l = latlngs.length; i < l; i++) {\n\t\t\t// Check for nested array (Polyline/Polygon)\n\t\t\tif (Array.isArray(latlngs[i])) {\n\t\t\t\tclone.push(L.LatLngUtil.cloneLatLngs(latlngs[i]));\n\t\t\t} else {\n\t\t\t\tclone.push(this.cloneLatLng(latlngs[i]));\n\t\t\t}\n\t\t}\n\t\treturn clone;\n\t},\n\n\t// @method cloneLatLng(LatLng): L.LatLng\n\t// Clone the latLng and return a new LatLng object.\n\tcloneLatLng: function (latlng) {\n\t\treturn L.latLng(latlng.lat, latlng.lng);\n\t}\n};\n","(function () {\n\n\tvar defaultPrecision = {\n\t\tkm: 2,\n\t\tha: 2,\n\t\tm: 0,\n\t\tmi: 2,\n\t\tac: 2,\n\t\tyd: 0,\n\t\tft: 0,\n\t\tnm: 2\n\t};\n\n\n\t/**\n\t * @class L.GeometryUtil\n\t * @aka GeometryUtil\n\t */\n\tL.GeometryUtil = L.extend(L.GeometryUtil || {}, {\n\t\t// Ported from the OpenLayers implementation. See https://github.com/openlayers/openlayers/blob/master/lib/OpenLayers/Geometry/LinearRing.js#L270\n\n\t\t// @method geodesicArea(): number\n\t\tgeodesicArea: function (latLngs) {\n\t\t\tvar pointsCount = latLngs.length,\n\t\t\t\tarea = 0.0,\n\t\t\t\td2r = Math.PI / 180,\n\t\t\t\tp1, p2;\n\n\t\t\tif (pointsCount > 2) {\n\t\t\t\tfor (var i = 0; i < pointsCount; i++) {\n\t\t\t\t\tp1 = latLngs[i];\n\t\t\t\t\tp2 = latLngs[(i + 1) % pointsCount];\n\t\t\t\t\tarea += ((p2.lng - p1.lng) * d2r) *\n\t\t\t\t\t\t(2 + Math.sin(p1.lat * d2r) + Math.sin(p2.lat * d2r));\n\t\t\t\t}\n\t\t\t\tarea = area * 6378137.0 * 6378137.0 / 2.0;\n\t\t\t}\n\n\t\t\treturn Math.abs(area);\n\t\t},\n\n\t\t// @method formattedNumber(n, precision): string\n\t\t// Returns n in specified number format (if defined) and precision\n\t\tformattedNumber: function (n, precision) {\n\t\t\tvar formatted = parseFloat(n).toFixed(precision),\n\t\t\t\tformat = L.drawLocal.format && L.drawLocal.format.numeric,\n\t\t\t\tdelimiters = format && format.delimiters,\n\t\t\t\tthousands = delimiters && delimiters.thousands,\n\t\t\t\tdecimal = delimiters && delimiters.decimal;\n\n\t\t\tif (thousands || decimal) {\n\t\t\t\tvar splitValue = formatted.split('.');\n\t\t\t\tformatted = thousands ? splitValue[0].replace(/(\\d)(?=(\\d{3})+(?!\\d))/g, '$1' + thousands) : splitValue[0];\n\t\t\t\tdecimal = decimal || '.';\n\t\t\t\tif (splitValue.length > 1) {\n\t\t\t\t\tformatted = formatted + decimal + splitValue[1];\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn formatted;\n\t\t},\n\n\t\t// @method readableArea(area, isMetric, precision): string\n\t\t// Returns a readable area string in yards or metric.\n\t\t// The value will be rounded as defined by the precision option object.\n\t\treadableArea: function (area, isMetric, precision) {\n\t\t\tvar areaStr,\n\t\t\t\tunits,\n\t\t\t\tprecision = L.Util.extend({}, defaultPrecision, precision);\n\n\t\t\tif (isMetric) {\n\t\t\t\tunits = ['ha', 'm'];\n\t\t\t\ttype = typeof isMetric;\n\t\t\t\tif (type === 'string') {\n\t\t\t\t\tunits = [isMetric];\n\t\t\t\t} else if (type !== 'boolean') {\n\t\t\t\t\tunits = isMetric;\n\t\t\t\t}\n\n\t\t\t\tif (area >= 1000000 && units.indexOf('km') !== -1) {\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area * 0.000001, precision['km']) + ' km²';\n\t\t\t\t} else if (area >= 10000 && units.indexOf('ha') !== -1) {\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area * 0.0001, precision['ha']) + ' ha';\n\t\t\t\t} else {\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area, precision['m']) + ' m²';\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tarea /= 0.836127; // Square yards in 1 meter\n\n\t\t\t\tif (area >= 3097600) { //3097600 square yards in 1 square mile\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area / 3097600, precision['mi']) + ' mi²';\n\t\t\t\t} else if (area >= 4840) { //4840 square yards in 1 acre\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area / 4840, precision['ac']) + ' acres';\n\t\t\t\t} else {\n\t\t\t\t\tareaStr = L.GeometryUtil.formattedNumber(area, precision['yd']) + ' yd²';\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn areaStr;\n\t\t},\n\n\t\t// @method readableDistance(distance, units): string\n\t\t// Converts a metric distance to one of [ feet, nauticalMile, metric or yards ] string\n\t\t//\n\t\t// @alternative\n\t\t// @method readableDistance(distance, isMetric, useFeet, isNauticalMile, precision): string\n\t\t// Converts metric distance to distance string.\n\t\t// The value will be rounded as defined by the precision option object.\n\t\treadableDistance: function (distance, isMetric, isFeet, isNauticalMile, precision) {\n\t\t\tvar distanceStr,\n\t\t\t\tunits,\n\t\t\t\tprecision = L.Util.extend({}, defaultPrecision, precision);\n\n\t\t\tif (isMetric) {\n\t\t\t\tunits = typeof isMetric == 'string' ? isMetric : 'metric';\n\t\t\t} else if (isFeet) {\n\t\t\t\tunits = 'feet';\n\t\t\t} else if (isNauticalMile) {\n\t\t\t\tunits = 'nauticalMile';\n\t\t\t} else {\n\t\t\t\tunits = 'yards';\n\t\t\t}\n\n\t\t\tswitch (units) {\n\t\t\t\tcase 'metric':\n\t\t\t\t\t// show metres when distance is < 1km, then show km\n\t\t\t\t\tif (distance > 1000) {\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1000, precision['km']) + ' km';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['m']) + ' m';\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'feet':\n\t\t\t\t\tdistance *= 1.09361 * 3;\n\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['ft']) + ' ft';\n\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'nauticalMile':\n\t\t\t\t\tdistance *= 0.53996;\n\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1000, precision['nm']) + ' nm';\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'yards':\n\t\t\t\tdefault:\n\t\t\t\t\tdistance *= 1.09361;\n\n\t\t\t\t\tif (distance > 1760) {\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance / 1760, precision['mi']) + ' miles';\n\t\t\t\t\t} else {\n\t\t\t\t\t\tdistanceStr = L.GeometryUtil.formattedNumber(distance, precision['yd']) + ' yd';\n\t\t\t\t\t}\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t\treturn distanceStr;\n\t\t},\n\n\t\t// @method isVersion07x(): boolean\n\t\t// Returns true if the Leaflet version is 0.7.x, false otherwise.\n\t\tisVersion07x: function () {\n\t\t\tvar version = L.version.split('.');\n\t\t\t//If Version is == 0.7.*\n\t\t\treturn parseInt(version[0], 10) === 0 && parseInt(version[1], 10) === 7;\n\t\t},\n\t});\n\n})();\n","/**\n * @class L.LineUtil\n * @aka Util\n * @aka L.Utils\n */\nL.Util.extend(L.LineUtil, {\n\n\t// @method segmentsIntersect(): boolean\n\t// Checks to see if two line segments intersect. Does not handle degenerate cases.\n\t// http://compgeom.cs.uiuc.edu/~jeffe/teaching/373/notes/x06-sweepline.pdf\n\tsegmentsIntersect: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2, /*Point*/ p3) {\n\t\treturn this._checkCounterclockwise(p, p2, p3) !==\n\t\t\tthis._checkCounterclockwise(p1, p2, p3) &&\n\t\t\tthis._checkCounterclockwise(p, p1, p2) !==\n\t\t\tthis._checkCounterclockwise(p, p1, p3);\n\t},\n\n\t// check to see if points are in counterclockwise order\n\t_checkCounterclockwise: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2) {\n\t\treturn (p2.y - p.y) * (p1.x - p.x) > (p1.y - p.y) * (p2.x - p.x);\n\t}\n});\n","/**\n * @class L.Polyline\n * @aka Polyline\n */\nL.Polyline.include({\n\n\t// @method intersects(): boolean\n\t// Check to see if this polyline has any linesegments that intersect.\n\t// NOTE: does not support detecting intersection for degenerate cases.\n\tintersects: function () {\n\t\tvar points = this._getProjectedPoints(),\n\t\t\tlen = points ? points.length : 0,\n\t\t\ti, p, p1;\n\n\t\tif (this._tooFewPointsForIntersection()) {\n\t\t\treturn false;\n\t\t}\n\n\t\tfor (i = len - 1; i >= 3; i--) {\n\t\t\tp = points[i - 1];\n\t\t\tp1 = points[i];\n\n\n\t\t\tif (this._lineSegmentsIntersectsRange(p, p1, i - 2)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t},\n\n\t// @method newLatLngIntersects(): boolean\n\t// Check for intersection if new latlng was added to this polyline.\n\t// NOTE: does not support detecting intersection for degenerate cases.\n\tnewLatLngIntersects: function (latlng, skipFirst) {\n\t\t// Cannot check a polyline for intersecting lats/lngs when not added to the map\n\t\tif (!this._map) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this.newPointIntersects(this._map.latLngToLayerPoint(latlng), skipFirst);\n\t},\n\n\t// @method newPointIntersects(): boolean\n\t// Check for intersection if new point was added to this polyline.\n\t// newPoint must be a layer point.\n\t// NOTE: does not support detecting intersection for degenerate cases.\n\tnewPointIntersects: function (newPoint, skipFirst) {\n\t\tvar points = this._getProjectedPoints(),\n\t\t\tlen = points ? points.length : 0,\n\t\t\tlastPoint = points ? points[len - 1] : null,\n\t\t\t// The previous previous line segment. Previous line segment doesn't need testing.\n\t\t\tmaxIndex = len - 2;\n\n\t\tif (this._tooFewPointsForIntersection(1)) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn this._lineSegmentsIntersectsRange(lastPoint, newPoint, maxIndex, skipFirst ? 1 : 0);\n\t},\n\n\t// Polylines with 2 sides can only intersect in cases where points are collinear (we don't support detecting these).\n\t// Cannot have intersection when < 3 line segments (< 4 points)\n\t_tooFewPointsForIntersection: function (extraPoints) {\n\t\tvar points = this._getProjectedPoints(),\n\t\t\tlen = points ? points.length : 0;\n\t\t// Increment length by extraPoints if present\n\t\tlen += extraPoints || 0;\n\n\t\treturn !points || len <= 3;\n\t},\n\n\t// Checks a line segment intersections with any line segments before its predecessor.\n\t// Don't need to check the predecessor as will never intersect.\n\t_lineSegmentsIntersectsRange: function (p, p1, maxIndex, minIndex) {\n\t\tvar points = this._getProjectedPoints(),\n\t\t\tp2, p3;\n\n\t\tminIndex = minIndex || 0;\n\n\t\t// Check all previous line segments (beside the immediately previous) for intersections\n\t\tfor (var j = maxIndex; j > minIndex; j--) {\n\t\t\tp2 = points[j - 1];\n\t\t\tp3 = points[j];\n\n\t\t\tif (L.LineUtil.segmentsIntersect(p, p1, p2, p3)) {\n\t\t\t\treturn true;\n\t\t\t}\n\t\t}\n\n\t\treturn false;\n\t},\n\n\t_getProjectedPoints: function () {\n\t\tif (!this._defaultShape) {\n\t\t\treturn this._originalPoints;\n\t\t}\n\t\tvar points = [],\n\t\t\t_shape = this._defaultShape();\n\n\t\tfor (var i = 0; i < _shape.length; i++) {\n\t\t\tpoints.push(this._map.latLngToLayerPoint(_shape[i]));\n\t\t}\n\t\treturn points;\n\t}\n});\n","/**\n * @class L.Polygon\n * @aka Polygon\n */\nL.Polygon.include({\n\n\t// @method intersects(): boolean\n\t// Checks a polygon for any intersecting line segments. Ignores holes.\n\tintersects: function () {\n\t\tvar polylineIntersects,\n\t\t\tpoints = this._getProjectedPoints(),\n\t\t\tlen, firstPoint, lastPoint, maxIndex;\n\n\t\tif (this._tooFewPointsForIntersection()) {\n\t\t\treturn false;\n\t\t}\n\n\t\tpolylineIntersects = L.Polyline.prototype.intersects.call(this);\n\n\t\t// If already found an intersection don't need to check for any more.\n\t\tif (polylineIntersects) {\n\t\t\treturn true;\n\t\t}\n\n\t\tlen = points.length;\n\t\tfirstPoint = points[0];\n\t\tlastPoint = points[len - 1];\n\t\tmaxIndex = len - 2;\n\n\t\t// Check the line segment between last and first point. Don't need to check the first line segment (minIndex = 1)\n\t\treturn this._lineSegmentsIntersectsRange(lastPoint, firstPoint, maxIndex, 1);\n\t}\n});\n","/**\n * @class L.Control.Draw\n * @aka L.Draw\n */\nL.Control.Draw = L.Control.extend({\n\n\t// Options\n\toptions: {\n\t\tposition: 'topleft',\n\t\tdraw: {},\n\t\tedit: false\n\t},\n\n\t// @method initialize(): void\n\t// Initializes draw control, toolbars from the options\n\tinitialize: function (options) {\n\t\tif (L.version < '0.7') {\n\t\t\tthrow new Error('Leaflet.draw 0.2.3+ requires Leaflet 0.7.0+. Download latest from https://github.com/Leaflet/Leaflet/');\n\t\t}\n\n\t\tL.Control.prototype.initialize.call(this, options);\n\n\t\tvar toolbar;\n\n\t\tthis._toolbars = {};\n\n\t\t// Initialize toolbars\n\t\tif (L.DrawToolbar && this.options.draw) {\n\t\t\ttoolbar = new L.DrawToolbar(this.options.draw);\n\n\t\t\tthis._toolbars[L.DrawToolbar.TYPE] = toolbar;\n\n\t\t\t// Listen for when toolbar is enabled\n\t\t\tthis._toolbars[L.DrawToolbar.TYPE].on('enable', this._toolbarEnabled, this);\n\t\t}\n\n\t\tif (L.EditToolbar && this.options.edit) {\n\t\t\ttoolbar = new L.EditToolbar(this.options.edit);\n\n\t\t\tthis._toolbars[L.EditToolbar.TYPE] = toolbar;\n\n\t\t\t// Listen for when toolbar is enabled\n\t\t\tthis._toolbars[L.EditToolbar.TYPE].on('enable', this._toolbarEnabled, this);\n\t\t}\n\t\tL.toolbar = this; //set global var for editing the toolbar\n\t},\n\n\t// @method onAdd(): container\n\t// Adds the toolbar container to the map\n\tonAdd: function (map) {\n\t\tvar container = L.DomUtil.create('div', 'leaflet-draw'),\n\t\t\taddedTopClass = false,\n\t\t\ttopClassName = 'leaflet-draw-toolbar-top',\n\t\t\ttoolbarContainer;\n\n\t\tfor (var toolbarId in this._toolbars) {\n\t\t\tif (this._toolbars.hasOwnProperty(toolbarId)) {\n\t\t\t\ttoolbarContainer = this._toolbars[toolbarId].addToolbar(map);\n\n\t\t\t\tif (toolbarContainer) {\n\t\t\t\t\t// Add class to the first toolbar to remove the margin\n\t\t\t\t\tif (!addedTopClass) {\n\t\t\t\t\t\tif (!L.DomUtil.hasClass(toolbarContainer, topClassName)) {\n\t\t\t\t\t\t\tL.DomUtil.addClass(toolbarContainer.childNodes[0], topClassName);\n\t\t\t\t\t\t}\n\t\t\t\t\t\taddedTopClass = true;\n\t\t\t\t\t}\n\n\t\t\t\t\tcontainer.appendChild(toolbarContainer);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\treturn container;\n\t},\n\n\t// @method onRemove(): void\n\t// Removes the toolbars from the map toolbar container\n\tonRemove: function () {\n\t\tfor (var toolbarId in this._toolbars) {\n\t\t\tif (this._toolbars.hasOwnProperty(toolbarId)) {\n\t\t\t\tthis._toolbars[toolbarId].removeToolbar();\n\t\t\t}\n\t\t}\n\t},\n\n\t// @method setDrawingOptions(options): void\n\t// Sets options to all toolbar instances\n\tsetDrawingOptions: function (options) {\n\t\tfor (var toolbarId in this._toolbars) {\n\t\t\tif (this._toolbars[toolbarId] instanceof L.DrawToolbar) {\n\t\t\t\tthis._toolbars[toolbarId].setOptions(options);\n\t\t\t}\n\t\t}\n\t},\n\n\t_toolbarEnabled: function (e) {\n\t\tvar enabledToolbar = e.target;\n\n\t\tfor (var toolbarId in this._toolbars) {\n\t\t\tif (this._toolbars[toolbarId] !== enabledToolbar) {\n\t\t\t\tthis._toolbars[toolbarId].disable();\n\t\t\t}\n\t\t}\n\t}\n});\n\nL.Map.mergeOptions({\n\tdrawControlTooltips: true,\n\tdrawControl: false\n});\n\nL.Map.addInitHook(function () {\n\tif (this.options.drawControl) {\n\t\tthis.drawControl = new L.Control.Draw();\n\t\tthis.addControl(this.drawControl);\n\t}\n});\n","/**\n * @class L.Draw.Toolbar\n * @aka Toolbar\n *\n * The toolbar class of the API — it is used to create the ui\n * This will be depreciated\n *\n * @example\n *\n * ```js\n * var toolbar = L.Toolbar();\n * toolbar.addToolbar(map);\n * ```\n *\n * ### Disabling a toolbar\n *\n * If you do not want a particular toolbar in your app you can turn it off by setting the toolbar to false.\n *\n * ```js\n * var drawControl = new L.Control.Draw({\n * draw: false,\n * edit: {\n * featureGroup: editableLayers\n * }\n * });\n * ```\n *\n * ### Disabling a toolbar item\n *\n * If you want to turn off a particular toolbar item, set it to false. The following disables drawing polygons and\n * markers. It also turns off the ability to edit layers.\n *\n * ```js\n * var drawControl = new L.Control.Draw({\n * draw: {\n * polygon: false,\n * marker: false\n * },\n * edit: {\n * featureGroup: editableLayers,\n * edit: false\n * }\n * });\n * ```\n */\nL.Toolbar = L.Class.extend({\n\t// @section Methods for modifying the toolbar\n\n\t// @method initialize(options): void\n\t// Toolbar constructor\n\tinitialize: function (options) {\n\t\tL.setOptions(this, options);\n\n\t\tthis._modes = {};\n\t\tthis._actionButtons = [];\n\t\tthis._activeMode = null;\n\n\t\tvar version = L.version.split('.');\n\t\t//If Version is >= 1.2.0\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\n\t\t\tL.Toolbar.include(L.Evented.prototype);\n\t\t} else {\n\t\t\tL.Toolbar.include(L.Mixin.Events);\n\t\t}\n\t},\n\n\t// @method enabled(): boolean\n\t// Gets a true/false of whether the toolbar is enabled\n\tenabled: function () {\n\t\treturn this._activeMode !== null;\n\t},\n\n\t// @method disable(): void\n\t// Disables the toolbar\n\tdisable: function () {\n\t\tif (!this.enabled()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._activeMode.handler.disable();\n\t},\n\n\t// @method addToolbar(map): L.DomUtil\n\t// Adds the toolbar to the map and returns the toolbar dom element\n\taddToolbar: function (map) {\n\t\tvar container = L.DomUtil.create('div', 'leaflet-draw-section'),\n\t\t\tbuttonIndex = 0,\n\t\t\tbuttonClassPrefix = this._toolbarClass || '',\n\t\t\tmodeHandlers = this.getModeHandlers(map),\n\t\t\ti;\n\n\t\tthis._toolbarContainer = L.DomUtil.create('div', 'leaflet-draw-toolbar leaflet-bar');\n\t\tthis._map = map;\n\n\t\tfor (i = 0; i < modeHandlers.length; i++) {\n\t\t\tif (modeHandlers[i].enabled) {\n\t\t\t\tthis._initModeHandler(\n\t\t\t\t\tmodeHandlers[i].handler,\n\t\t\t\t\tthis._toolbarContainer,\n\t\t\t\t\tbuttonIndex++,\n\t\t\t\t\tbuttonClassPrefix,\n\t\t\t\t\tmodeHandlers[i].title\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\t// if no buttons were added, do not add the toolbar\n\t\tif (!buttonIndex) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Save button index of the last button, -1 as we would have ++ after the last button\n\t\tthis._lastButtonIndex = --buttonIndex;\n\n\t\t// Create empty actions part of the toolbar\n\t\tthis._actionsContainer = L.DomUtil.create('ul', 'leaflet-draw-actions');\n\n\t\t// Add draw and cancel containers to the control container\n\t\tcontainer.appendChild(this._toolbarContainer);\n\t\tcontainer.appendChild(this._actionsContainer);\n\n\t\treturn container;\n\t},\n\n\t// @method removeToolbar(): void\n\t// Removes the toolbar and drops the handler event listeners\n\tremoveToolbar: function () {\n\t\t// Dispose each handler\n\t\tfor (var handlerId in this._modes) {\n\t\t\tif (this._modes.hasOwnProperty(handlerId)) {\n\t\t\t\t// Unbind handler button\n\t\t\t\tthis._disposeButton(\n\t\t\t\t\tthis._modes[handlerId].button,\n\t\t\t\t\tthis._modes[handlerId].handler.enable,\n\t\t\t\t\tthis._modes[handlerId].handler\n\t\t\t\t);\n\n\t\t\t\t// Make sure is disabled\n\t\t\t\tthis._modes[handlerId].handler.disable();\n\n\t\t\t\t// Unbind handler\n\t\t\t\tthis._modes[handlerId].handler\n\t\t\t\t\t.off('enabled', this._handlerActivated, this)\n\t\t\t\t\t.off('disabled', this._handlerDeactivated, this);\n\t\t\t}\n\t\t}\n\t\tthis._modes = {};\n\n\t\t// Dispose the actions toolbar\n\t\tfor (var i = 0, l = this._actionButtons.length; i < l; i++) {\n\t\t\tthis._disposeButton(\n\t\t\t\tthis._actionButtons[i].button,\n\t\t\t\tthis._actionButtons[i].callback,\n\t\t\t\tthis\n\t\t\t);\n\t\t}\n\t\tthis._actionButtons = [];\n\t\tthis._actionsContainer = null;\n\t},\n\n\t_initModeHandler: function (handler, container, buttonIndex, classNamePredix, buttonTitle) {\n\t\tvar type = handler.type;\n\n\t\tthis._modes[type] = {};\n\n\t\tthis._modes[type].handler = handler;\n\n\t\tthis._modes[type].button = this._createButton({\n\t\t\ttype: type,\n\t\t\ttitle: buttonTitle,\n\t\t\tclassName: classNamePredix + '-' + type,\n\t\t\tcontainer: container,\n\t\t\tcallback: this._modes[type].handler.enable,\n\t\t\tcontext: this._modes[type].handler\n\t\t});\n\n\t\tthis._modes[type].buttonIndex = buttonIndex;\n\n\t\tthis._modes[type].handler\n\t\t\t.on('enabled', this._handlerActivated, this)\n\t\t\t.on('disabled', this._handlerDeactivated, this);\n\t},\n\n\t/* Detect iOS based on browser User Agent, based on:\n\t * http://stackoverflow.com/a/9039885 */\n\t_detectIOS: function () {\n\t\tvar iOS = (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream);\n\t\treturn iOS;\n\t},\n\n\t_createButton: function (options) {\n\n\t\tvar link = L.DomUtil.create('a', options.className || '', options.container);\n\t\t// Screen reader tag\n\t\tvar sr = L.DomUtil.create('span', 'sr-only', options.container);\n\n\t\tlink.href = '#';\n\t\tlink.appendChild(sr);\n\n\t\tif (options.title) {\n\t\t\tlink.title = options.title;\n\t\t\tsr.innerHTML = options.title;\n\t\t}\n\n\t\tif (options.text) {\n\t\t\tlink.innerHTML = options.text;\n\t\t\tsr.innerHTML = options.text;\n\t\t}\n\n\t\t/* iOS does not use click events */\n\t\tvar buttonEvent = this._detectIOS() ? 'touchstart' : 'click';\n\n\t\tL.DomEvent\n\t\t\t.on(link, 'click', L.DomEvent.stopPropagation)\n\t\t\t.on(link, 'mousedown', L.DomEvent.stopPropagation)\n\t\t\t.on(link, 'dblclick', L.DomEvent.stopPropagation)\n\t\t\t.on(link, 'touchstart', L.DomEvent.stopPropagation)\n\t\t\t.on(link, 'click', L.DomEvent.preventDefault)\n\t\t\t.on(link, buttonEvent, options.callback, options.context);\n\n\t\treturn link;\n\t},\n\n\t_disposeButton: function (button, callback) {\n\t\t/* iOS does not use click events */\n\t\tvar buttonEvent = this._detectIOS() ? 'touchstart' : 'click';\n\n\t\tL.DomEvent\n\t\t\t.off(button, 'click', L.DomEvent.stopPropagation)\n\t\t\t.off(button, 'mousedown', L.DomEvent.stopPropagation)\n\t\t\t.off(button, 'dblclick', L.DomEvent.stopPropagation)\n\t\t\t.off(button, 'touchstart', L.DomEvent.stopPropagation)\n\t\t\t.off(button, 'click', L.DomEvent.preventDefault)\n\t\t\t.off(button, buttonEvent, callback);\n\t},\n\n\t_handlerActivated: function (e) {\n\t\t// Disable active mode (if present)\n\t\tthis.disable();\n\n\t\t// Cache new active feature\n\t\tthis._activeMode = this._modes[e.handler];\n\n\t\tL.DomUtil.addClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled');\n\n\t\tthis._showActionsToolbar();\n\n\t\tthis.fire('enable');\n\t},\n\n\t_handlerDeactivated: function () {\n\t\tthis._hideActionsToolbar();\n\n\t\tL.DomUtil.removeClass(this._activeMode.button, 'leaflet-draw-toolbar-button-enabled');\n\n\t\tthis._activeMode = null;\n\n\t\tthis.fire('disable');\n\t},\n\n\t_createActions: function (handler) {\n\t\tvar container = this._actionsContainer,\n\t\t\tbuttons = this.getActions(handler),\n\t\t\tl = buttons.length,\n\t\t\tli, di, dl, button;\n\n\t\t// Dispose the actions toolbar (todo: dispose only not used buttons)\n\t\tfor (di = 0, dl = this._actionButtons.length; di < dl; di++) {\n\t\t\tthis._disposeButton(this._actionButtons[di].button, this._actionButtons[di].callback);\n\t\t}\n\t\tthis._actionButtons = [];\n\n\t\t// Remove all old buttons\n\t\twhile (container.firstChild) {\n\t\t\tcontainer.removeChild(container.firstChild);\n\t\t}\n\n\t\tfor (var i = 0; i < l; i++) {\n\t\t\tif ('enabled' in buttons[i] && !buttons[i].enabled) {\n\t\t\t\tcontinue;\n\t\t\t}\n\n\t\t\tli = L.DomUtil.create('li', '', container);\n\n\t\t\tbutton = this._createButton({\n\t\t\t\ttitle: buttons[i].title,\n\t\t\t\ttext: buttons[i].text,\n\t\t\t\tcontainer: li,\n\t\t\t\tcallback: buttons[i].callback,\n\t\t\t\tcontext: buttons[i].context\n\t\t\t});\n\n\t\t\tthis._actionButtons.push({\n\t\t\t\tbutton: button,\n\t\t\t\tcallback: buttons[i].callback\n\t\t\t});\n\t\t}\n\t},\n\n\t_showActionsToolbar: function () {\n\t\tvar buttonIndex = this._activeMode.buttonIndex,\n\t\t\tlastButtonIndex = this._lastButtonIndex,\n\t\t\ttoolbarPosition = this._activeMode.button.offsetTop - 1;\n\n\t\t// Recreate action buttons on every click\n\t\tthis._createActions(this._activeMode.handler);\n\n\t\t// Correctly position the cancel button\n\t\tthis._actionsContainer.style.top = toolbarPosition + 'px';\n\n\t\tif (buttonIndex === 0) {\n\t\t\tL.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop');\n\t\t\tL.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-top');\n\t\t}\n\n\t\tif (buttonIndex === lastButtonIndex) {\n\t\t\tL.DomUtil.addClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom');\n\t\t\tL.DomUtil.addClass(this._actionsContainer, 'leaflet-draw-actions-bottom');\n\t\t}\n\n\t\tthis._actionsContainer.style.display = 'block';\n\t\tthis._map.fire(L.Draw.Event.TOOLBAROPENED);\n\t},\n\n\t_hideActionsToolbar: function () {\n\t\tthis._actionsContainer.style.display = 'none';\n\n\t\tL.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-notop');\n\t\tL.DomUtil.removeClass(this._toolbarContainer, 'leaflet-draw-toolbar-nobottom');\n\t\tL.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-top');\n\t\tL.DomUtil.removeClass(this._actionsContainer, 'leaflet-draw-actions-bottom');\n\t\tthis._map.fire(L.Draw.Event.TOOLBARCLOSED);\n\t}\n});\n","L.Draw = L.Draw || {};\n/**\n * @class L.Draw.Tooltip\n * @aka Tooltip\n *\n * The tooltip class — it is used to display the tooltip while drawing\n * This will be depreciated\n *\n * @example\n *\n * ```js\n * var tooltip = L.Draw.Tooltip();\n * ```\n *\n */\nL.Draw.Tooltip = L.Class.extend({\n\n\t// @section Methods for modifying draw state\n\n\t// @method initialize(map): void\n\t// Tooltip constructor\n\tinitialize: function (map) {\n\t\tthis._map = map;\n\t\tthis._popupPane = map._panes.popupPane;\n\t\tthis._visible = false;\n\n\t\tthis._container = map.options.drawControlTooltips ?\n\t\t\tL.DomUtil.create('div', 'leaflet-draw-tooltip', this._popupPane) : null;\n\t\tthis._singleLineLabel = false;\n\n\t\tthis._map.on('mouseout', this._onMouseOut, this);\n\t},\n\n\t// @method dispose(): void\n\t// Remove Tooltip DOM and unbind events\n\tdispose: function () {\n\t\tthis._map.off('mouseout', this._onMouseOut, this);\n\n\t\tif (this._container) {\n\t\t\tthis._popupPane.removeChild(this._container);\n\t\t\tthis._container = null;\n\t\t}\n\t},\n\n\t// @method updateContent(labelText): this\n\t// Changes the tooltip text to string in function call\n\tupdateContent: function (labelText) {\n\t\tif (!this._container) {\n\t\t\treturn this;\n\t\t}\n\t\tlabelText.subtext = labelText.subtext || '';\n\n\t\t// update the vertical position (only if changed)\n\t\tif (labelText.subtext.length === 0 && !this._singleLineLabel) {\n\t\t\tL.DomUtil.addClass(this._container, 'leaflet-draw-tooltip-single');\n\t\t\tthis._singleLineLabel = true;\n\t\t}\n\t\telse if (labelText.subtext.length > 0 && this._singleLineLabel) {\n\t\t\tL.DomUtil.removeClass(this._container, 'leaflet-draw-tooltip-single');\n\t\t\tthis._singleLineLabel = false;\n\t\t}\n\n\t\tthis._container.innerHTML =\n\t\t\t(labelText.subtext.length > 0 ?\n\t\t\t\t'' + labelText.subtext + ' ' + ' ' : '') +\n\t\t\t'' + labelText.text + ' ';\n\n\t\tif (!labelText.text && !labelText.subtext) {\n\t\t\tthis._visible = false;\n\t\t\tthis._container.style.visibility = 'hidden';\n\t\t} else {\n\t\t\tthis._visible = true;\n\t\t\tthis._container.style.visibility = 'inherit';\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t// @method updatePosition(latlng): this\n\t// Changes the location of the tooltip\n\tupdatePosition: function (latlng) {\n\t\tvar pos = this._map.latLngToLayerPoint(latlng),\n\t\t\ttooltipContainer = this._container;\n\n\t\tif (this._container) {\n\t\t\tif (this._visible) {\n\t\t\t\ttooltipContainer.style.visibility = 'inherit';\n\t\t\t}\n\t\t\tL.DomUtil.setPosition(tooltipContainer, pos);\n\t\t}\n\n\t\treturn this;\n\t},\n\n\t// @method showAsError(): this\n\t// Applies error class to tooltip\n\tshowAsError: function () {\n\t\tif (this._container) {\n\t\t\tL.DomUtil.addClass(this._container, 'leaflet-error-draw-tooltip');\n\t\t}\n\t\treturn this;\n\t},\n\n\t// @method removeError(): this\n\t// Removes the error class from the tooltip\n\tremoveError: function () {\n\t\tif (this._container) {\n\t\t\tL.DomUtil.removeClass(this._container, 'leaflet-error-draw-tooltip');\n\t\t}\n\t\treturn this;\n\t},\n\n\t_onMouseOut: function () {\n\t\tif (this._container) {\n\t\t\tthis._container.style.visibility = 'hidden';\n\t\t}\n\t}\n});\n","/**\n * @class L.DrawToolbar\n * @aka Toolbar\n */\nL.DrawToolbar = L.Toolbar.extend({\n\n\tstatics: {\n\t\tTYPE: 'draw'\n\t},\n\n\toptions: {\n\t\tpolyline: {},\n\t\tpolygon: {},\n\t\trectangle: {},\n\t\tcircle: {},\n\t\tmarker: {},\n\t\tcirclemarker: {}\n\t},\n\n\t// @method initialize(): void\n\tinitialize: function (options) {\n\t\t// Ensure that the options are merged correctly since L.extend is only shallow\n\t\tfor (var type in this.options) {\n\t\t\tif (this.options.hasOwnProperty(type)) {\n\t\t\t\tif (options[type]) {\n\t\t\t\t\toptions[type] = L.extend({}, this.options[type], options[type]);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tthis._toolbarClass = 'leaflet-draw-draw';\n\t\tL.Toolbar.prototype.initialize.call(this, options);\n\t},\n\n\t// @method getModeHandlers(): object\n\t// Get mode handlers information\n\tgetModeHandlers: function (map) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tenabled: this.options.polyline,\n\t\t\t\thandler: new L.Draw.Polyline(map, this.options.polyline),\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.polyline\n\t\t\t},\n\t\t\t{\n\t\t\t\tenabled: this.options.polygon,\n\t\t\t\thandler: new L.Draw.Polygon(map, this.options.polygon),\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.polygon\n\t\t\t},\n\t\t\t{\n\t\t\t\tenabled: this.options.rectangle,\n\t\t\t\thandler: new L.Draw.Rectangle(map, this.options.rectangle),\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.rectangle\n\t\t\t},\n\t\t\t{\n\t\t\t\tenabled: this.options.circle,\n\t\t\t\thandler: new L.Draw.Circle(map, this.options.circle),\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.circle\n\t\t\t},\n\t\t\t{\n\t\t\t\tenabled: this.options.marker,\n\t\t\t\thandler: new L.Draw.Marker(map, this.options.marker),\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.marker\n\t\t\t},\n\t\t\t{\n\t\t\t\tenabled: this.options.circlemarker,\n\t\t\t\thandler: new L.Draw.CircleMarker(map, this.options.circlemarker),\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.buttons.circlemarker\n\t\t\t}\n\t\t];\n\t},\n\n\t// @method getActions(): object\n\t// Get action information\n\tgetActions: function (handler) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tenabled: handler.completeShape,\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.finish.title,\n\t\t\t\ttext: L.drawLocal.draw.toolbar.finish.text,\n\t\t\t\tcallback: handler.completeShape,\n\t\t\t\tcontext: handler\n\t\t\t},\n\t\t\t{\n\t\t\t\tenabled: handler.deleteLastVertex,\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.undo.title,\n\t\t\t\ttext: L.drawLocal.draw.toolbar.undo.text,\n\t\t\t\tcallback: handler.deleteLastVertex,\n\t\t\t\tcontext: handler\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: L.drawLocal.draw.toolbar.actions.title,\n\t\t\t\ttext: L.drawLocal.draw.toolbar.actions.text,\n\t\t\t\tcallback: this.disable,\n\t\t\t\tcontext: this\n\t\t\t}\n\t\t];\n\t},\n\n\t// @method setOptions(): void\n\t// Sets the options to the toolbar\n\tsetOptions: function (options) {\n\t\tL.setOptions(this, options);\n\n\t\tfor (var type in this._modes) {\n\t\t\tif (this._modes.hasOwnProperty(type) && options.hasOwnProperty(type)) {\n\t\t\t\tthis._modes[type].handler.setOptions(options[type]);\n\t\t\t}\n\t\t}\n\t}\n});\n","/*L.Map.mergeOptions({\n editControl: true\n });*/\n/**\n * @class L.EditToolbar\n * @aka EditToolbar\n */\nL.EditToolbar = L.Toolbar.extend({\n\tstatics: {\n\t\tTYPE: 'edit'\n\t},\n\n\toptions: {\n\t\tedit: {\n\t\t\tselectedPathOptions: {\n\t\t\t\tdashArray: '10, 10',\n\n\t\t\t\tfill: true,\n\t\t\t\tfillColor: '#fe57a1',\n\t\t\t\tfillOpacity: 0.1,\n\n\t\t\t\t// Whether to user the existing layers color\n\t\t\t\tmaintainColor: false\n\t\t\t}\n\t\t},\n\t\tremove: {},\n\t\tpoly: null,\n\t\tfeatureGroup: null /* REQUIRED! TODO: perhaps if not set then all layers on the map are selectable? */\n\t},\n\n\t// @method intialize(): void\n\tinitialize: function (options) {\n\t\t// Need to set this manually since null is an acceptable value here\n\t\tif (options.edit) {\n\t\t\tif (typeof options.edit.selectedPathOptions === 'undefined') {\n\t\t\t\toptions.edit.selectedPathOptions = this.options.edit.selectedPathOptions;\n\t\t\t}\n\t\t\toptions.edit.selectedPathOptions = L.extend({}, this.options.edit.selectedPathOptions, options.edit.selectedPathOptions);\n\t\t}\n\n\t\tif (options.remove) {\n\t\t\toptions.remove = L.extend({}, this.options.remove, options.remove);\n\t\t}\n\n\t\tif (options.poly) {\n\t\t\toptions.poly = L.extend({}, this.options.poly, options.poly);\n\t\t}\n\n\t\tthis._toolbarClass = 'leaflet-draw-edit';\n\t\tL.Toolbar.prototype.initialize.call(this, options);\n\n\t\tthis._selectedFeatureCount = 0;\n\t},\n\n\t// @method getModeHandlers(): object\n\t// Get mode handlers information\n\tgetModeHandlers: function (map) {\n\t\tvar featureGroup = this.options.featureGroup;\n\t\treturn [\n\t\t\t{\n\t\t\t\tenabled: this.options.edit,\n\t\t\t\thandler: new L.EditToolbar.Edit(map, {\n\t\t\t\t\tfeatureGroup: featureGroup,\n\t\t\t\t\tselectedPathOptions: this.options.edit.selectedPathOptions,\n\t\t\t\t\tpoly: this.options.poly\n\t\t\t\t}),\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.buttons.edit\n\t\t\t},\n\t\t\t{\n\t\t\t\tenabled: this.options.remove,\n\t\t\t\thandler: new L.EditToolbar.Delete(map, {\n\t\t\t\t\tfeatureGroup: featureGroup\n\t\t\t\t}),\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.buttons.remove\n\t\t\t}\n\t\t];\n\t},\n\n\t// @method getActions(): object\n\t// Get actions information\n\tgetActions: function (handler) {\n\t\tvar actions = [\n\t\t\t{\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.actions.save.title,\n\t\t\t\ttext: L.drawLocal.edit.toolbar.actions.save.text,\n\t\t\t\tcallback: this._save,\n\t\t\t\tcontext: this\n\t\t\t},\n\t\t\t{\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.actions.cancel.title,\n\t\t\t\ttext: L.drawLocal.edit.toolbar.actions.cancel.text,\n\t\t\t\tcallback: this.disable,\n\t\t\t\tcontext: this\n\t\t\t}\n\t\t];\n\n\t\tif (handler.removeAllLayers) {\n\t\t\tactions.push({\n\t\t\t\ttitle: L.drawLocal.edit.toolbar.actions.clearAll.title,\n\t\t\t\ttext: L.drawLocal.edit.toolbar.actions.clearAll.text,\n\t\t\t\tcallback: this._clearAllLayers,\n\t\t\t\tcontext: this\n\t\t\t});\n\t\t}\n\n\t\treturn actions;\n\t},\n\n\t// @method addToolbar(map): L.DomUtil\n\t// Adds the toolbar to the map\n\taddToolbar: function (map) {\n\t\tvar container = L.Toolbar.prototype.addToolbar.call(this, map);\n\n\t\tthis._checkDisabled();\n\n\t\tthis.options.featureGroup.on('layeradd layerremove', this._checkDisabled, this);\n\n\t\treturn container;\n\t},\n\n\t// @method removeToolbar(): void\n\t// Removes the toolbar from the map\n\tremoveToolbar: function () {\n\t\tthis.options.featureGroup.off('layeradd layerremove', this._checkDisabled, this);\n\n\t\tL.Toolbar.prototype.removeToolbar.call(this);\n\t},\n\n\t// @method disable(): void\n\t// Disables the toolbar\n\tdisable: function () {\n\t\tif (!this.enabled()) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._activeMode.handler.revertLayers();\n\n\t\tL.Toolbar.prototype.disable.call(this);\n\t},\n\n\t_save: function () {\n\t\tthis._activeMode.handler.save();\n\t\tif (this._activeMode) {\n\t\t\tthis._activeMode.handler.disable();\n\t\t}\n\t},\n\n\t_clearAllLayers: function () {\n\t\tthis._activeMode.handler.removeAllLayers();\n\t\tif (this._activeMode) {\n\t\t\tthis._activeMode.handler.disable();\n\t\t}\n\t},\n\n\t_checkDisabled: function () {\n\t\tvar featureGroup = this.options.featureGroup,\n\t\t\thasLayers = featureGroup.getLayers().length !== 0,\n\t\t\tbutton;\n\n\t\tif (this.options.edit) {\n\t\t\tbutton = this._modes[L.EditToolbar.Edit.TYPE].button;\n\n\t\t\tif (hasLayers) {\n\t\t\t\tL.DomUtil.removeClass(button, 'leaflet-disabled');\n\t\t\t} else {\n\t\t\t\tL.DomUtil.addClass(button, 'leaflet-disabled');\n\t\t\t}\n\n\t\t\tbutton.setAttribute(\n\t\t\t\t'title',\n\t\t\t\thasLayers ?\n\t\t\t\t\tL.drawLocal.edit.toolbar.buttons.edit\n\t\t\t\t\t: L.drawLocal.edit.toolbar.buttons.editDisabled\n\t\t\t);\n\t\t}\n\n\t\tif (this.options.remove) {\n\t\t\tbutton = this._modes[L.EditToolbar.Delete.TYPE].button;\n\n\t\t\tif (hasLayers) {\n\t\t\t\tL.DomUtil.removeClass(button, 'leaflet-disabled');\n\t\t\t} else {\n\t\t\t\tL.DomUtil.addClass(button, 'leaflet-disabled');\n\t\t\t}\n\n\t\t\tbutton.setAttribute(\n\t\t\t\t'title',\n\t\t\t\thasLayers ?\n\t\t\t\t\tL.drawLocal.edit.toolbar.buttons.remove\n\t\t\t\t\t: L.drawLocal.edit.toolbar.buttons.removeDisabled\n\t\t\t);\n\t\t}\n\t}\n});\n","/**\n * @class L.EditToolbar.Edit\n * @aka EditToolbar.Edit\n */\nL.EditToolbar.Edit = L.Handler.extend({\n\tstatics: {\n\t\tTYPE: 'edit'\n\t},\n\n\t// @method intialize(): void\n\tinitialize: function (map, options) {\n\t\tL.Handler.prototype.initialize.call(this, map);\n\n\t\tL.setOptions(this, options);\n\n\t\t// Store the selectable layer group for ease of access\n\t\tthis._featureGroup = options.featureGroup;\n\n\t\tif (!(this._featureGroup instanceof L.FeatureGroup)) {\n\t\t\tthrow new Error('options.featureGroup must be a L.FeatureGroup');\n\t\t}\n\n\t\tthis._uneditedLayerProps = {};\n\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\n\t\tthis.type = L.EditToolbar.Edit.TYPE;\n\n\t\tvar version = L.version.split('.');\n\t\t//If Version is >= 1.2.0\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\n\t\t\tL.EditToolbar.Edit.include(L.Evented.prototype);\n\t\t} else {\n\t\t\tL.EditToolbar.Edit.include(L.Mixin.Events);\n\t\t}\n\t},\n\n\t// @method enable(): void\n\t// Enable the edit toolbar\n\tenable: function () {\n\t\tif (this._enabled || !this._hasAvailableLayers()) {\n\t\t\treturn;\n\t\t}\n\t\tthis.fire('enabled', {handler: this.type});\n\t\t//this disable other handlers\n\n\t\tthis._map.fire(L.Draw.Event.EDITSTART, {handler: this.type});\n\t\t//allow drawLayer to be updated before beginning edition.\n\n\t\tL.Handler.prototype.enable.call(this);\n\t\tthis._featureGroup\n\t\t\t.on('layeradd', this._enableLayerEdit, this)\n\t\t\t.on('layerremove', this._disableLayerEdit, this);\n\t},\n\n\t// @method disable(): void\n\t// Disable the edit toolbar\n\tdisable: function () {\n\t\tif (!this._enabled) {\n\t\t\treturn;\n\t\t}\n\t\tthis._featureGroup\n\t\t\t.off('layeradd', this._enableLayerEdit, this)\n\t\t\t.off('layerremove', this._disableLayerEdit, this);\n\t\tL.Handler.prototype.disable.call(this);\n\t\tthis._map.fire(L.Draw.Event.EDITSTOP, {handler: this.type});\n\t\tthis.fire('disabled', {handler: this.type});\n\t},\n\n\t// @method addHooks(): void\n\t// Add listener hooks for this handler\n\taddHooks: function () {\n\t\tvar map = this._map;\n\n\t\tif (map) {\n\t\t\tmap.getContainer().focus();\n\n\t\t\tthis._featureGroup.eachLayer(this._enableLayerEdit, this);\n\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\n\t\t\tthis._tooltip.updateContent({\n\t\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\n\t\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\n\t\t\t});\n\n\t\t\t// Quickly access the tooltip to update for intersection checking\n\t\t\tmap._editTooltip = this._tooltip;\n\n\t\t\tthis._updateTooltip();\n\n\t\t\tthis._map\n\t\t\t\t.on('mousemove', this._onMouseMove, this)\n\t\t\t\t.on('touchmove', this._onMouseMove, this)\n\t\t\t\t.on('MSPointerMove', this._onMouseMove, this)\n\t\t\t\t.on(L.Draw.Event.EDITVERTEX, this._updateTooltip, this);\n\t\t}\n\t},\n\n\t// @method removeHooks(): void\n\t// Remove listener hooks for this handler\n\tremoveHooks: function () {\n\t\tif (this._map) {\n\t\t\t// Clean up selected layers.\n\t\t\tthis._featureGroup.eachLayer(this._disableLayerEdit, this);\n\n\t\t\t// Clear the backups of the original layers\n\t\t\tthis._uneditedLayerProps = {};\n\n\t\t\tthis._tooltip.dispose();\n\t\t\tthis._tooltip = null;\n\n\t\t\tthis._map\n\t\t\t\t.off('mousemove', this._onMouseMove, this)\n\t\t\t\t.off('touchmove', this._onMouseMove, this)\n\t\t\t\t.off('MSPointerMove', this._onMouseMove, this)\n\t\t\t\t.off(L.Draw.Event.EDITVERTEX, this._updateTooltip, this);\n\t\t}\n\t},\n\n\t// @method revertLayers(): void\n\t// Revert each layer's geometry changes\n\trevertLayers: function () {\n\t\tthis._featureGroup.eachLayer(function (layer) {\n\t\t\tthis._revertLayer(layer);\n\t\t}, this);\n\t},\n\n\t// @method save(): void\n\t// Save the layer geometries\n\tsave: function () {\n\t\tvar editedLayers = new L.LayerGroup();\n\t\tthis._featureGroup.eachLayer(function (layer) {\n\t\t\tif (layer.edited) {\n\t\t\t\teditedLayers.addLayer(layer);\n\t\t\t\tlayer.edited = false;\n\t\t\t}\n\t\t});\n\t\tthis._map.fire(L.Draw.Event.EDITED, {layers: editedLayers});\n\t},\n\n\t_backupLayer: function (layer) {\n\t\tvar id = L.Util.stamp(layer);\n\n\t\tif (!this._uneditedLayerProps[id]) {\n\t\t\t// Polyline, Polygon or Rectangle\n\t\t\tif (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) {\n\t\t\t\tthis._uneditedLayerProps[id] = {\n\t\t\t\t\tlatlngs: L.LatLngUtil.cloneLatLngs(layer.getLatLngs())\n\t\t\t\t};\n\t\t\t} else if (layer instanceof L.Circle) {\n\t\t\t\tthis._uneditedLayerProps[id] = {\n\t\t\t\t\tlatlng: L.LatLngUtil.cloneLatLng(layer.getLatLng()),\n\t\t\t\t\tradius: layer.getRadius()\n\t\t\t\t};\n\t\t\t} else if (layer instanceof L.Marker || layer instanceof L.CircleMarker) { // Marker\n\t\t\t\tthis._uneditedLayerProps[id] = {\n\t\t\t\t\tlatlng: L.LatLngUtil.cloneLatLng(layer.getLatLng())\n\t\t\t\t};\n\t\t\t}\n\t\t}\n\t},\n\n\t_getTooltipText: function () {\n\t\treturn ({\n\t\t\ttext: L.drawLocal.edit.handlers.edit.tooltip.text,\n\t\t\tsubtext: L.drawLocal.edit.handlers.edit.tooltip.subtext\n\t\t});\n\t},\n\n\t_updateTooltip: function () {\n\t\tthis._tooltip.updateContent(this._getTooltipText());\n\t},\n\n\t_revertLayer: function (layer) {\n\t\tvar id = L.Util.stamp(layer);\n\t\tlayer.edited = false;\n\t\tif (this._uneditedLayerProps.hasOwnProperty(id)) {\n\t\t\t// Polyline, Polygon or Rectangle\n\t\t\tif (layer instanceof L.Polyline || layer instanceof L.Polygon || layer instanceof L.Rectangle) {\n\t\t\t\tlayer.setLatLngs(this._uneditedLayerProps[id].latlngs);\n\t\t\t} else if (layer instanceof L.Circle) {\n\t\t\t\tlayer.setLatLng(this._uneditedLayerProps[id].latlng);\n\t\t\t\tlayer.setRadius(this._uneditedLayerProps[id].radius);\n\t\t\t} else if (layer instanceof L.Marker || layer instanceof L.CircleMarker) { // Marker or CircleMarker\n\t\t\t\tlayer.setLatLng(this._uneditedLayerProps[id].latlng);\n\t\t\t}\n\n\t\t\tlayer.fire('revert-edited', {layer: layer});\n\t\t}\n\t},\n\n\t_enableLayerEdit: function (e) {\n\t\tvar layer = e.layer || e.target || e,\n\t\t\tpathOptions, poly;\n\n\t\t// Back up this layer (if haven't before)\n\t\tthis._backupLayer(layer);\n\n\t\tif (this.options.poly) {\n\t\t\tpoly = L.Util.extend({}, this.options.poly);\n\t\t\tlayer.options.poly = poly;\n\t\t}\n\n\t\t// Set different style for editing mode\n\t\tif (this.options.selectedPathOptions) {\n\t\t\tpathOptions = L.Util.extend({}, this.options.selectedPathOptions);\n\n\t\t\t// Use the existing color of the layer\n\t\t\tif (pathOptions.maintainColor) {\n\t\t\t\tpathOptions.color = layer.options.color;\n\t\t\t\tpathOptions.fillColor = layer.options.fillColor;\n\t\t\t}\n\n\t\t\tlayer.options.original = L.extend({}, layer.options);\n\t\t\tlayer.options.editing = pathOptions;\n\n\t\t}\n\n\t\tif (layer instanceof L.Marker) {\n\t\t\tif (layer.editing) {\n\t\t\t\tlayer.editing.enable();\n\t\t\t}\n\t\t\tlayer.dragging.enable();\n\t\t\tlayer\n\t\t\t\t.on('dragend', this._onMarkerDragEnd)\n\t\t\t\t// #TODO: remove when leaflet finally fixes their draggable so it's touch friendly again.\n\t\t\t\t.on('touchmove', this._onTouchMove, this)\n\t\t\t\t.on('MSPointerMove', this._onTouchMove, this)\n\t\t\t\t.on('touchend', this._onMarkerDragEnd, this)\n\t\t\t\t.on('MSPointerUp', this._onMarkerDragEnd, this);\n\t\t} else {\n\t\t\tlayer.editing.enable();\n\t\t}\n\t},\n\n\t_disableLayerEdit: function (e) {\n\t\tvar layer = e.layer || e.target || e;\n\n\t\tlayer.edited = false;\n\t\tif (layer.editing) {\n\t\t\tlayer.editing.disable();\n\t\t}\n\n\t\tdelete layer.options.editing;\n\t\tdelete layer.options.original;\n\t\t// Reset layer styles to that of before select\n\t\tif (this._selectedPathOptions) {\n\t\t\tif (layer instanceof L.Marker) {\n\t\t\t\tthis._toggleMarkerHighlight(layer);\n\t\t\t} else {\n\t\t\t\t// reset the layer style to what is was before being selected\n\t\t\t\tlayer.setStyle(layer.options.previousOptions);\n\t\t\t\t// remove the cached options for the layer object\n\t\t\t\tdelete layer.options.previousOptions;\n\t\t\t}\n\t\t}\n\n\t\tif (layer instanceof L.Marker) {\n\t\t\tlayer.dragging.disable();\n\t\t\tlayer\n\t\t\t\t.off('dragend', this._onMarkerDragEnd, this)\n\t\t\t\t.off('touchmove', this._onTouchMove, this)\n\t\t\t\t.off('MSPointerMove', this._onTouchMove, this)\n\t\t\t\t.off('touchend', this._onMarkerDragEnd, this)\n\t\t\t\t.off('MSPointerUp', this._onMarkerDragEnd, this);\n\t\t} else {\n\t\t\tlayer.editing.disable();\n\t\t}\n\t},\n\n\t_onMouseMove: function (e) {\n\t\tthis._tooltip.updatePosition(e.latlng);\n\t},\n\n\t_onMarkerDragEnd: function (e) {\n\t\tvar layer = e.target;\n\t\tlayer.edited = true;\n\t\tthis._map.fire(L.Draw.Event.EDITMOVE, {layer: layer});\n\t},\n\n\t_onTouchMove: function (e) {\n\t\tvar touchEvent = e.originalEvent.changedTouches[0],\n\t\t\tlayerPoint = this._map.mouseEventToLayerPoint(touchEvent),\n\t\t\tlatlng = this._map.layerPointToLatLng(layerPoint);\n\t\te.target.setLatLng(latlng);\n\t},\n\n\t_hasAvailableLayers: function () {\n\t\treturn this._featureGroup.getLayers().length !== 0;\n\t}\n});\n","/**\n * @class L.EditToolbar.Delete\n * @aka EditToolbar.Delete\n */\nL.EditToolbar.Delete = L.Handler.extend({\n\tstatics: {\n\t\tTYPE: 'remove' // not delete as delete is reserved in js\n\t},\n\n\t// @method intialize(): void\n\tinitialize: function (map, options) {\n\t\tL.Handler.prototype.initialize.call(this, map);\n\n\t\tL.Util.setOptions(this, options);\n\n\t\t// Store the selectable layer group for ease of access\n\t\tthis._deletableLayers = this.options.featureGroup;\n\n\t\tif (!(this._deletableLayers instanceof L.FeatureGroup)) {\n\t\t\tthrow new Error('options.featureGroup must be a L.FeatureGroup');\n\t\t}\n\n\t\t// Save the type so super can fire, need to do this as cannot do this.TYPE :(\n\t\tthis.type = L.EditToolbar.Delete.TYPE;\n\n\t\tvar version = L.version.split('.');\n\t\t//If Version is >= 1.2.0\n\t\tif (parseInt(version[0], 10) === 1 && parseInt(version[1], 10) >= 2) {\n\t\t\tL.EditToolbar.Delete.include(L.Evented.prototype);\n\t\t} else {\n\t\t\tL.EditToolbar.Delete.include(L.Mixin.Events);\n\t\t}\n\n\t},\n\n\t// @method enable(): void\n\t// Enable the delete toolbar\n\tenable: function () {\n\t\tif (this._enabled || !this._hasAvailableLayers()) {\n\t\t\treturn;\n\t\t}\n\t\tthis.fire('enabled', {handler: this.type});\n\n\t\tthis._map.fire(L.Draw.Event.DELETESTART, {handler: this.type});\n\n\t\tL.Handler.prototype.enable.call(this);\n\n\t\tthis._deletableLayers\n\t\t\t.on('layeradd', this._enableLayerDelete, this)\n\t\t\t.on('layerremove', this._disableLayerDelete, this);\n\t},\n\n\t// @method disable(): void\n\t// Disable the delete toolbar\n\tdisable: function () {\n\t\tif (!this._enabled) {\n\t\t\treturn;\n\t\t}\n\n\t\tthis._deletableLayers\n\t\t\t.off('layeradd', this._enableLayerDelete, this)\n\t\t\t.off('layerremove', this._disableLayerDelete, this);\n\n\t\tL.Handler.prototype.disable.call(this);\n\n\t\tthis._map.fire(L.Draw.Event.DELETESTOP, {handler: this.type});\n\n\t\tthis.fire('disabled', {handler: this.type});\n\t},\n\n\t// @method addHooks(): void\n\t// Add listener hooks to this handler\n\taddHooks: function () {\n\t\tvar map = this._map;\n\n\t\tif (map) {\n\t\t\tmap.getContainer().focus();\n\n\t\t\tthis._deletableLayers.eachLayer(this._enableLayerDelete, this);\n\t\t\tthis._deletedLayers = new L.LayerGroup();\n\n\t\t\tthis._tooltip = new L.Draw.Tooltip(this._map);\n\t\t\tthis._tooltip.updateContent({text: L.drawLocal.edit.handlers.remove.tooltip.text});\n\n\t\t\tthis._map.on('mousemove', this._onMouseMove, this);\n\t\t}\n\t},\n\n\t// @method removeHooks(): void\n\t// Remove listener hooks from this handler\n\tremoveHooks: function () {\n\t\tif (this._map) {\n\t\t\tthis._deletableLayers.eachLayer(this._disableLayerDelete, this);\n\t\t\tthis._deletedLayers = null;\n\n\t\t\tthis._tooltip.dispose();\n\t\t\tthis._tooltip = null;\n\n\t\t\tthis._map.off('mousemove', this._onMouseMove, this);\n\t\t}\n\t},\n\n\t// @method revertLayers(): void\n\t// Revert the deleted layers back to their prior state.\n\trevertLayers: function () {\n\t\t// Iterate of the deleted layers and add them back into the featureGroup\n\t\tthis._deletedLayers.eachLayer(function (layer) {\n\t\t\tthis._deletableLayers.addLayer(layer);\n\t\t\tlayer.fire('revert-deleted', {layer: layer});\n\t\t}, this);\n\t},\n\n\t// @method save(): void\n\t// Save deleted layers\n\tsave: function () {\n\t\tthis._map.fire(L.Draw.Event.DELETED, {layers: this._deletedLayers});\n\t},\n\n\t// @method removeAllLayers(): void\n\t// Remove all delateable layers\n\tremoveAllLayers: function () {\n\t\t// Iterate of the delateable layers and add remove them\n\t\tthis._deletableLayers.eachLayer(function (layer) {\n\t\t\tthis._removeLayer({layer: layer});\n\t\t}, this);\n\t\tthis.save();\n\t},\n\n\t_enableLayerDelete: function (e) {\n\t\tvar layer = e.layer || e.target || e;\n\n\t\tlayer.on('click', this._removeLayer, this);\n\t},\n\n\t_disableLayerDelete: function (e) {\n\t\tvar layer = e.layer || e.target || e;\n\n\t\tlayer.off('click', this._removeLayer, this);\n\n\t\t// Remove from the deleted layers so we can't accidentally revert if the user presses cancel\n\t\tthis._deletedLayers.removeLayer(layer);\n\t},\n\n\t_removeLayer: function (e) {\n\t\tvar layer = e.layer || e.target || e;\n\n\t\tthis._deletableLayers.removeLayer(layer);\n\n\t\tthis._deletedLayers.addLayer(layer);\n\n\t\tlayer.fire('deleted');\n\t},\n\n\t_onMouseMove: function (e) {\n\t\tthis._tooltip.updatePosition(e.latlng);\n\t},\n\n\t_hasAvailableLayers: function () {\n\t\treturn this._deletableLayers.getLayers().length !== 0;\n\t}\n});\n"]}
\ No newline at end of file
diff --git a/node_modules/leaflet-draw/dist/leaflet.draw.css b/node_modules/leaflet-draw/dist/leaflet.draw.css
new file mode 100644
index 00000000..a0194106
--- /dev/null
+++ b/node_modules/leaflet-draw/dist/leaflet.draw.css
@@ -0,0 +1,10 @@
+.leaflet-draw-section{position:relative}.leaflet-draw-toolbar{margin-top:12px}.leaflet-draw-toolbar-top{margin-top:0}.leaflet-draw-toolbar-notop a:first-child{border-top-right-radius:0}.leaflet-draw-toolbar-nobottom a:last-child{border-bottom-right-radius:0}.leaflet-draw-toolbar a{background-image:url('images/spritesheet.png');background-image:linear-gradient(transparent,transparent),url('images/spritesheet.svg');background-repeat:no-repeat;background-size:300px 30px;background-clip:padding-box}.leaflet-retina .leaflet-draw-toolbar a{background-image:url('images/spritesheet-2x.png');background-image:linear-gradient(transparent,transparent),url('images/spritesheet.svg')}
+.leaflet-draw a{display:block;text-align:center;text-decoration:none}.leaflet-draw a .sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0}.leaflet-draw-actions{display:none;list-style:none;margin:0;padding:0;position:absolute;left:26px;top:0;white-space:nowrap}.leaflet-touch .leaflet-draw-actions{left:32px}.leaflet-right .leaflet-draw-actions{right:26px;left:auto}.leaflet-touch .leaflet-right .leaflet-draw-actions{right:32px;left:auto}.leaflet-draw-actions li{display:inline-block}
+.leaflet-draw-actions li:first-child a{border-left:0}.leaflet-draw-actions li:last-child a{-webkit-border-radius:0 4px 4px 0;border-radius:0 4px 4px 0}.leaflet-right .leaflet-draw-actions li:last-child a{-webkit-border-radius:0;border-radius:0}.leaflet-right .leaflet-draw-actions li:first-child a{-webkit-border-radius:4px 0 0 4px;border-radius:4px 0 0 4px}.leaflet-draw-actions a{background-color:#919187;border-left:1px solid #AAA;color:#FFF;font:11px/19px "Helvetica Neue",Arial,Helvetica,sans-serif;line-height:28px;text-decoration:none;padding-left:10px;padding-right:10px;height:28px}
+.leaflet-touch .leaflet-draw-actions a{font-size:12px;line-height:30px;height:30px}.leaflet-draw-actions-bottom{margin-top:0}.leaflet-draw-actions-top{margin-top:1px}.leaflet-draw-actions-top a,.leaflet-draw-actions-bottom a{height:27px;line-height:27px}.leaflet-draw-actions a:hover{background-color:#a0a098}.leaflet-draw-actions-top.leaflet-draw-actions-bottom a{height:26px;line-height:26px}.leaflet-draw-toolbar .leaflet-draw-draw-polyline{background-position:-2px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-polyline{background-position:0 -1px}
+.leaflet-draw-toolbar .leaflet-draw-draw-polygon{background-position:-31px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-polygon{background-position:-29px -1px}.leaflet-draw-toolbar .leaflet-draw-draw-rectangle{background-position:-62px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-rectangle{background-position:-60px -1px}.leaflet-draw-toolbar .leaflet-draw-draw-circle{background-position:-92px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-circle{background-position:-90px -1px}
+.leaflet-draw-toolbar .leaflet-draw-draw-marker{background-position:-122px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-marker{background-position:-120px -1px}.leaflet-draw-toolbar .leaflet-draw-draw-circlemarker{background-position:-273px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-draw-circlemarker{background-position:-271px -1px}.leaflet-draw-toolbar .leaflet-draw-edit-edit{background-position:-152px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-edit-edit{background-position:-150px -1px}
+.leaflet-draw-toolbar .leaflet-draw-edit-remove{background-position:-182px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-edit-remove{background-position:-180px -1px}.leaflet-draw-toolbar .leaflet-draw-edit-edit.leaflet-disabled{background-position:-212px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-edit-edit.leaflet-disabled{background-position:-210px -1px}.leaflet-draw-toolbar .leaflet-draw-edit-remove.leaflet-disabled{background-position:-242px -2px}.leaflet-touch .leaflet-draw-toolbar .leaflet-draw-edit-remove.leaflet-disabled{background-position:-240px -2px}
+.leaflet-mouse-marker{background-color:#fff;cursor:crosshair}.leaflet-draw-tooltip{background:#363636;background:rgba(0,0,0,0.5);border:1px solid transparent;-webkit-border-radius:4px;border-radius:4px;color:#fff;font:12px/18px "Helvetica Neue",Arial,Helvetica,sans-serif;margin-left:20px;margin-top:-21px;padding:4px 8px;position:absolute;visibility:hidden;white-space:nowrap;z-index:6}.leaflet-draw-tooltip:before{border-right:6px solid black;border-right-color:rgba(0,0,0,0.5);border-top:6px solid transparent;border-bottom:6px solid transparent;content:"";position:absolute;top:7px;left:-7px}
+.leaflet-error-draw-tooltip{background-color:#f2dede;border:1px solid #e6b6bd;color:#b94a48}.leaflet-error-draw-tooltip:before{border-right-color:#e6b6bd}.leaflet-draw-tooltip-single{margin-top:-12px}.leaflet-draw-tooltip-subtext{color:#f8d5e4}.leaflet-draw-guide-dash{font-size:1%;opacity:.6;position:absolute;width:5px;height:5px}.leaflet-edit-marker-selected{background-color:rgba(254,87,161,0.1);border:4px dashed rgba(254,87,161,0.6);-webkit-border-radius:4px;border-radius:4px;box-sizing:content-box}
+.leaflet-edit-move{cursor:move}.leaflet-edit-resize{cursor:pointer}.leaflet-oldie .leaflet-draw-toolbar{border:1px solid #999}
\ No newline at end of file
diff --git a/node_modules/leaflet-draw/dist/leaflet.draw.js b/node_modules/leaflet-draw/dist/leaflet.draw.js
new file mode 100644
index 00000000..71aeb33b
--- /dev/null
+++ b/node_modules/leaflet-draw/dist/leaflet.draw.js
@@ -0,0 +1,10 @@
+/*
+ Leaflet.draw 1.0.4, a plugin that adds drawing and editing tools to Leaflet powered maps.
+ (c) 2012-2017, Jacob Toye, Jon West, Smartrak, Leaflet
+
+ https://github.com/Leaflet/Leaflet.draw
+ http://leafletjs.com
+ */
+!function(t,e,i){function o(t,e){for(;(t=t.parentElement)&&!t.classList.contains(e););return t}L.drawVersion="1.0.4",L.Draw={},L.drawLocal={draw:{toolbar:{actions:{title:"Cancel drawing",text:"Cancel"},finish:{title:"Finish drawing",text:"Finish"},undo:{title:"Delete last point drawn",text:"Delete last point"},buttons:{polyline:"Draw a polyline",polygon:"Draw a polygon",rectangle:"Draw a rectangle",circle:"Draw a circle",marker:"Draw a marker",circlemarker:"Draw a circlemarker"}},handlers:{circle:{tooltip:{start:"Click and drag to draw circle."},radius:"Radius"},circlemarker:{tooltip:{start:"Click map to place circle marker."}},marker:{tooltip:{start:"Click map to place marker."}},polygon:{tooltip:{start:"Click to start drawing shape.",cont:"Click to continue drawing shape.",end:"Click first point to close this shape."}},polyline:{error:"Error: shape edges cannot cross!",tooltip:{start:"Click to start drawing line.",cont:"Click to continue drawing line.",end:"Click last point to finish line."}},rectangle:{tooltip:{start:"Click and drag to draw rectangle."}},simpleshape:{tooltip:{end:"Release mouse to finish drawing."}}}},edit:{toolbar:{actions:{save:{title:"Save changes",text:"Save"},cancel:{title:"Cancel editing, discards all changes",text:"Cancel"},clearAll:{title:"Clear all layers",text:"Clear All"}},buttons:{edit:"Edit layers",editDisabled:"No layers to edit",remove:"Delete layers",removeDisabled:"No layers to delete"}},handlers:{edit:{tooltip:{text:"Drag handles or markers to edit features.",subtext:"Click cancel to undo changes."}},remove:{tooltip:{text:"Click on a feature to remove."}}}}},L.Draw.Event={},L.Draw.Event.CREATED="draw:created",L.Draw.Event.EDITED="draw:edited",L.Draw.Event.DELETED="draw:deleted",L.Draw.Event.DRAWSTART="draw:drawstart",L.Draw.Event.DRAWSTOP="draw:drawstop",L.Draw.Event.DRAWVERTEX="draw:drawvertex",L.Draw.Event.EDITSTART="draw:editstart",L.Draw.Event.EDITMOVE="draw:editmove",L.Draw.Event.EDITRESIZE="draw:editresize",L.Draw.Event.EDITVERTEX="draw:editvertex",L.Draw.Event.EDITSTOP="draw:editstop",L.Draw.Event.DELETESTART="draw:deletestart",L.Draw.Event.DELETESTOP="draw:deletestop",L.Draw.Event.TOOLBAROPENED="draw:toolbaropened",L.Draw.Event.TOOLBARCLOSED="draw:toolbarclosed",L.Draw.Event.MARKERCONTEXT="draw:markercontext",L.Draw=L.Draw||{},L.Draw.Feature=L.Handler.extend({initialize:function(t,e){this._map=t,this._container=t._container,this._overlayPane=t._panes.overlayPane,this._popupPane=t._panes.popupPane,e&&e.shapeOptions&&(e.shapeOptions=L.Util.extend({},this.options.shapeOptions,e.shapeOptions)),L.setOptions(this,e);var i=L.version.split(".");1===parseInt(i[0],10)&&parseInt(i[1],10)>=2?L.Draw.Feature.include(L.Evented.prototype):L.Draw.Feature.include(L.Mixin.Events)},enable:function(){this._enabled||(L.Handler.prototype.enable.call(this),this.fire("enabled",{handler:this.type}),this._map.fire(L.Draw.Event.DRAWSTART,{layerType:this.type}))},disable:function(){this._enabled&&(L.Handler.prototype.disable.call(this),this._map.fire(L.Draw.Event.DRAWSTOP,{layerType:this.type}),this.fire("disabled",{handler:this.type}))},addHooks:function(){var t=this._map;t&&(L.DomUtil.disableTextSelection(),t.getContainer().focus(),this._tooltip=new L.Draw.Tooltip(this._map),L.DomEvent.on(this._container,"keyup",this._cancelDrawing,this))},removeHooks:function(){this._map&&(L.DomUtil.enableTextSelection(),this._tooltip.dispose(),this._tooltip=null,L.DomEvent.off(this._container,"keyup",this._cancelDrawing,this))},setOptions:function(t){L.setOptions(this,t)},_fireCreatedEvent:function(t){this._map.fire(L.Draw.Event.CREATED,{layer:t,layerType:this.type})},_cancelDrawing:function(t){27===t.keyCode&&(this._map.fire("draw:canceled",{layerType:this.type}),this.disable())}}),L.Draw.Polyline=L.Draw.Feature.extend({statics:{TYPE:"polyline"},Poly:L.Polyline,options:{allowIntersection:!0,repeatMode:!1,drawError:{color:"#b00b00",timeout:2500},icon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon"}),touchIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-touch-icon"}),guidelineDistance:20,maxGuideLineLength:4e3,shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!1,clickable:!0},metric:!0,feet:!0,nautic:!1,showLength:!0,zIndexOffset:2e3,factor:1,maxPoints:0},initialize:function(t,e){L.Browser.touch&&(this.options.icon=this.options.touchIcon),this.options.drawError.message=L.drawLocal.draw.handlers.polyline.error,e&&e.drawError&&(e.drawError=L.Util.extend({},this.options.drawError,e.drawError)),this.type=L.Draw.Polyline.TYPE,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._markers=[],this._markerGroup=new L.LayerGroup,this._map.addLayer(this._markerGroup),this._poly=new L.Polyline([],this.options.shapeOptions),this._tooltip.updateContent(this._getTooltipText()),this._mouseMarker||(this._mouseMarker=L.marker(this._map.getCenter(),{icon:L.divIcon({className:"leaflet-mouse-marker",iconAnchor:[20,20],iconSize:[40,40]}),opacity:0,zIndexOffset:this.options.zIndexOffset})),this._mouseMarker.on("mouseout",this._onMouseOut,this).on("mousemove",this._onMouseMove,this).on("mousedown",this._onMouseDown,this).on("mouseup",this._onMouseUp,this).addTo(this._map),this._map.on("mouseup",this._onMouseUp,this).on("mousemove",this._onMouseMove,this).on("zoomlevelschange",this._onZoomEnd,this).on("touchstart",this._onTouch,this).on("zoomend",this._onZoomEnd,this))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),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)){var t=this._markers.pop(),e=this._poly,i=e.getLatLngs(),o=i.splice(-1,1)[0];this._poly.setLatLngs(i),this._markerGroup.removeLayer(t),e.getLatLngs().length<2&&this._map.removeLayer(e),this._vertexChanged(o,!1)}},addVertex:function(t){if(this._markers.length>=2&&!this.options.allowIntersection&&this._poly.newLatLngIntersects(t))return void this._showErrorTooltip();this._errorShown&&this._hideErrorTooltip(),this._markers.push(this._createMarker(t)),this._poly.addLatLng(t),2===this._poly.getLatLngs().length&&this._map.addLayer(this._poly),this._vertexChanged(t,!0)},completeShape:function(){this._markers.length<=1||!this._shapeIsValid()||(this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable())},_finishShape:function(){var t=this._poly._defaultShape?this._poly._defaultShape():this._poly.getLatLngs(),e=this._poly.newLatLngIntersects(t[t.length-1]);if(!this.options.allowIntersection&&e||!this._shapeIsValid())return void this._showErrorTooltip();this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()},_shapeIsValid:function(){return!0},_onZoomEnd:function(){null!==this._markers&&this._updateGuide()},_onMouseMove:function(t){var e=this._map.mouseEventToLayerPoint(t.originalEvent),i=this._map.layerPointToLatLng(e);this._currentLatLng=i,this._updateTooltip(i),this._updateGuide(e),this._mouseMarker.setLatLng(i),L.DomEvent.preventDefault(t.originalEvent)},_vertexChanged:function(t,e){this._map.fire(L.Draw.Event.DRAWVERTEX,{layers:this._markerGroup}),this._updateFinishHandler(),this._updateRunningMeasure(t,e),this._clearGuides(),this._updateTooltip()},_onMouseDown:function(t){if(!this._clickHandled&&!this._touchHandled&&!this._disableMarkers){this._onMouseMove(t),this._clickHandled=!0,this._disableNewMarkers();var e=t.originalEvent,i=e.clientX,o=e.clientY;this._startPoint.call(this,i,o)}},_startPoint:function(t,e){this._mouseDownOrigin=L.point(t,e)},_onMouseUp:function(t){var e=t.originalEvent,i=e.clientX,o=e.clientY;this._endPoint.call(this,i,o,t),this._clickHandled=null},_endPoint:function(e,i,o){if(this._mouseDownOrigin){var a=L.point(e,i).distanceTo(this._mouseDownOrigin),n=this._calculateFinishDistance(o.latlng);this.options.maxPoints>1&&this.options.maxPoints==this._markers.length+1?(this.addVertex(o.latlng),this._finishShape()):n<10&&L.Browser.touch?this._finishShape():Math.abs(a)<9*(t.devicePixelRatio||1)&&this.addVertex(o.latlng),this._enableNewMarkers()}this._mouseDownOrigin=null},_onTouch:function(t){var e,i,o=t.originalEvent;!o.touches||!o.touches[0]||this._clickHandled||this._touchHandled||this._disableMarkers||(e=o.touches[0].clientX,i=o.touches[0].clientY,this._disableNewMarkers(),this._touchHandled=!0,this._startPoint.call(this,e,i),this._endPoint.call(this,e,i,t),this._touchHandled=null),this._clickHandled=null},_onMouseOut:function(){this._tooltip&&this._tooltip._onMouseOut.call(this._tooltip)},_calculateFinishDistance:function(t){var e;if(this._markers.length>0){var i;if(this.type===L.Draw.Polyline.TYPE)i=this._markers[this._markers.length-1];else{if(this.type!==L.Draw.Polygon.TYPE)return 1/0;i=this._markers[0]}var o=this._map.latLngToContainerPoint(i.getLatLng()),a=new L.Marker(t,{icon:this.options.icon,zIndexOffset:2*this.options.zIndexOffset}),n=this._map.latLngToContainerPoint(a.getLatLng());e=o.distanceTo(n)}else e=1/0;return e},_updateFinishHandler:function(){var t=this._markers.length;t>1&&this._markers[t-1].on("click",this._finishShape,this),t>2&&this._markers[t-2].off("click",this._finishShape,this)},_createMarker:function(t){var e=new L.Marker(t,{icon:this.options.icon,zIndexOffset:2*this.options.zIndexOffset});return this._markerGroup.addLayer(e),e},_updateGuide:function(t){var e=this._markers?this._markers.length:0;e>0&&(t=t||this._map.latLngToLayerPoint(this._currentLatLng),this._clearGuides(),this._drawGuide(this._map.latLngToLayerPoint(this._markers[e-1].getLatLng()),t))},_updateTooltip:function(t){var e=this._getTooltipText();t&&this._tooltip.updatePosition(t),this._errorShown||this._tooltip.updateContent(e)},_drawGuide:function(t,e){var i,o,a,n=Math.floor(Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))),s=this.options.guidelineDistance,r=this.options.maxGuideLineLength,l=n>r?n-r:s;for(this._guidesContainer||(this._guidesContainer=L.DomUtil.create("div","leaflet-draw-guides",this._overlayPane));l1&&this._markers[this._markers.length-1].off("click",this._finishShape,this)},_fireCreatedEvent:function(){var t=new this.Poly(this._poly.getLatLngs(),this.options.shapeOptions);L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)}}),L.Draw.Polygon=L.Draw.Polyline.extend({statics:{TYPE:"polygon"},Poly:L.Polygon,options:{showArea:!1,showLength:!1,shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},metric:!0,feet:!0,nautic:!1,precision:{}},initialize:function(t,e){L.Draw.Polyline.prototype.initialize.call(this,t,e),this.type=L.Draw.Polygon.TYPE},_updateFinishHandler:function(){var t=this._markers.length;1===t&&this._markers[0].on("click",this._finishShape,this),t>2&&(this._markers[t-1].on("dblclick",this._finishShape,this),t>3&&this._markers[t-2].off("dblclick",this._finishShape,this))},_getTooltipText:function(){var t,e;return 0===this._markers.length?t=L.drawLocal.draw.handlers.polygon.tooltip.start:this._markers.length<3?(t=L.drawLocal.draw.handlers.polygon.tooltip.cont,e=this._getMeasurementString()):(t=L.drawLocal.draw.handlers.polygon.tooltip.end,e=this._getMeasurementString()),{text:t,subtext:e}},_getMeasurementString:function(){var t=this._area,e="";return t||this.options.showLength?(this.options.showLength&&(e=L.Draw.Polyline.prototype._getMeasurementString.call(this)),t&&(e+=" "+L.GeometryUtil.readableArea(t,this.options.metric,this.options.precision)),e):null},_shapeIsValid:function(){return this._markers.length>=3},_vertexChanged:function(t,e){var i;!this.options.allowIntersection&&this.options.showArea&&(i=this._poly.getLatLngs(),this._area=L.GeometryUtil.geodesicArea(i)),L.Draw.Polyline.prototype._vertexChanged.call(this,t,e)},_cleanUpShape:function(){var t=this._markers.length;t>0&&(this._markers[0].off("click",this._finishShape,this),t>2&&this._markers[t-1].off("dblclick",this._finishShape,this))}}),L.SimpleShape={},L.Draw.SimpleShape=L.Draw.Feature.extend({options:{repeatMode:!1},initialize:function(t,e){this._endLabelText=L.drawLocal.draw.handlers.simpleshape.tooltip.end,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._mapDraggable=this._map.dragging.enabled(),this._mapDraggable&&this._map.dragging.disable(),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),e.addEventListener("touchstart",L.DomEvent.preventDefault,{passive:!1}))},removeHooks:function(){L.Draw.Feature.prototype.removeHooks.call(this),this._map&&(this._mapDraggable&&this._map.dragging.enable(),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),L.DomEvent.off(e,"mouseup",this._onMouseUp,this),L.DomEvent.off(e,"touchend",this._onMouseUp,this),e.removeEventListener("touchstart",L.DomEvent.preventDefault),this._shape&&(this._map.removeLayer(this._shape),delete this._shape)),this._isDrawing=!1},_getTooltipText:function(){return{text:this._endLabelText}},_onMouseDown:function(t){this._isDrawing=!0,this._startLatLng=t.latlng,L.DomEvent.on(e,"mouseup",this._onMouseUp,this).on(e,"touchend",this._onMouseUp,this).preventDefault(t.originalEvent)},_onMouseMove:function(t){var e=t.latlng;this._tooltip.updatePosition(e),this._isDrawing&&(this._tooltip.updateContent(this._getTooltipText()),this._drawShape(e))},_onMouseUp:function(){this._shape&&this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()}}),L.Draw.Rectangle=L.Draw.SimpleShape.extend({statics:{TYPE:"rectangle"},options:{shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},showArea:!0,metric:!0},initialize:function(t,e){this.type=L.Draw.Rectangle.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.rectangle.tooltip.start,L.Draw.SimpleShape.prototype.initialize.call(this,t,e)},disable:function(){this._enabled&&(this._isCurrentlyTwoClickDrawing=!1,L.Draw.SimpleShape.prototype.disable.call(this))},_onMouseUp:function(t){if(!this._shape&&!this._isCurrentlyTwoClickDrawing)return void(this._isCurrentlyTwoClickDrawing=!0);this._isCurrentlyTwoClickDrawing&&!o(t.target,"leaflet-pane")||L.Draw.SimpleShape.prototype._onMouseUp.call(this)},_drawShape:function(t){this._shape?this._shape.setBounds(new L.LatLngBounds(this._startLatLng,t)):(this._shape=new L.Rectangle(new L.LatLngBounds(this._startLatLng,t),this.options.shapeOptions),this._map.addLayer(this._shape))},_fireCreatedEvent:function(){var t=new L.Rectangle(this._shape.getBounds(),this.options.shapeOptions);L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this,t)},_getTooltipText:function(){var t,e,i,o=L.Draw.SimpleShape.prototype._getTooltipText.call(this),a=this._shape,n=this.options.showArea;return a&&(t=this._shape._defaultShape?this._shape._defaultShape():this._shape.getLatLngs(),e=L.GeometryUtil.geodesicArea(t),i=n?L.GeometryUtil.readableArea(e,this.options.metric):""),{text:o.text,subtext:i}}}),L.Draw.Marker=L.Draw.Feature.extend({statics:{TYPE:"marker"},options:{icon:new L.Icon.Default,repeatMode:!1,zIndexOffset:2e3},initialize:function(t,e){this.type=L.Draw.Marker.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.marker.tooltip.start,L.Draw.Feature.prototype.initialize.call(this,t,e)},addHooks:function(){L.Draw.Feature.prototype.addHooks.call(this),this._map&&(this._tooltip.updateContent({text:this._initialLabelText}),this._mouseMarker||(this._mouseMarker=L.marker(this._map.getCenter(),{icon:L.divIcon({className:"leaflet-mouse-marker",iconAnchor:[20,20],iconSize:[40,40]}),opacity:0,zIndexOffset:this.options.zIndexOffset})),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(){L.Draw.Feature.prototype.removeHooks.call(this),this._map&&(this._map.off("click",this._onClick,this).off("click",this._onTouch,this),this._marker&&(this._marker.off("click",this._onClick,this),this._map.removeLayer(this._marker),delete this._marker),this._mouseMarker.off("click",this._onClick,this),this._map.removeLayer(this._mouseMarker),delete this._mouseMarker,this._map.off("mousemove",this._onMouseMove,this))},_onMouseMove:function(t){var e=t.latlng;this._tooltip.updatePosition(e),this._mouseMarker.setLatLng(e),this._marker?(e=this._mouseMarker.getLatLng(),this._marker.setLatLng(e)):(this._marker=this._createMarker(e),this._marker.on("click",this._onClick,this),this._map.on("click",this._onClick,this).addLayer(this._marker))},_createMarker:function(t){return new L.Marker(t,{icon:this.options.icon,zIndexOffset:this.options.zIndexOffset})},_onClick:function(){this._fireCreatedEvent(),this.disable(),this.options.repeatMode&&this.enable()},_onTouch:function(t){this._onMouseMove(t),this._onClick()},_fireCreatedEvent:function(){var t=new L.Marker.Touch(this._marker.getLatLng(),{icon:this.options.icon});L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)}}),L.Draw.CircleMarker=L.Draw.Marker.extend({statics:{TYPE:"circlemarker"},options:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0,zIndexOffset:2e3},initialize:function(t,e){this.type=L.Draw.CircleMarker.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.circlemarker.tooltip.start,L.Draw.Feature.prototype.initialize.call(this,t,e)},_fireCreatedEvent:function(){var t=new L.CircleMarker(this._marker.getLatLng(),this.options);L.Draw.Feature.prototype._fireCreatedEvent.call(this,t)},_createMarker:function(t){return new L.CircleMarker(t,this.options)}}),L.Draw.Circle=L.Draw.SimpleShape.extend({statics:{TYPE:"circle"},options:{shapeOptions:{stroke:!0,color:"#3388ff",weight:4,opacity:.5,fill:!0,fillColor:null,fillOpacity:.2,clickable:!0},showRadius:!0,metric:!0,feet:!0,nautic:!1},initialize:function(t,e){this.type=L.Draw.Circle.TYPE,this._initialLabelText=L.drawLocal.draw.handlers.circle.tooltip.start,L.Draw.SimpleShape.prototype.initialize.call(this,t,e)},_drawShape:function(t){if(L.GeometryUtil.isVersion07x())var e=this._startLatLng.distanceTo(t);else var e=this._map.distance(this._startLatLng,t);this._shape?this._shape.setRadius(e):(this._shape=new L.Circle(this._startLatLng,e,this.options.shapeOptions),this._map.addLayer(this._shape))},_fireCreatedEvent:function(){var t=new L.Circle(this._startLatLng,this._shape.getRadius(),this.options.shapeOptions);L.Draw.SimpleShape.prototype._fireCreatedEvent.call(this,t)},_onMouseMove:function(t){var e,i=t.latlng,o=this.options.showRadius,a=this.options.metric;if(this._tooltip.updatePosition(i),this._isDrawing){this._drawShape(i),e=this._shape.getRadius().toFixed(1);var n="";o&&(n=L.drawLocal.draw.handlers.circle.radius+": "+L.GeometryUtil.readableDistance(e,a,this.options.feet,this.options.nautic)),this._tooltip.updateContent({text:this._endLabelText,subtext:n})}}}),L.Edit=L.Edit||{},L.Edit.Marker=L.Handler.extend({initialize:function(t,e){this._marker=t,L.setOptions(this,e)},addHooks:function(){var t=this._marker;t.dragging.enable(),t.on("dragend",this._onDragEnd,t),this._toggleMarkerHighlight()},removeHooks:function(){var t=this._marker;t.dragging.disable(),t.off("dragend",this._onDragEnd,t),this._toggleMarkerHighlight()},_onDragEnd:function(t){var e=t.target;e.edited=!0,this._map.fire(L.Draw.Event.EDITMOVE,{layer:e})},_toggleMarkerHighlight:function(){var t=this._marker._icon;t&&(t.style.display="none",L.DomUtil.hasClass(t,"leaflet-edit-marker-selected")?(L.DomUtil.removeClass(t,"leaflet-edit-marker-selected"),this._offsetMarker(t,-4)):(L.DomUtil.addClass(t,"leaflet-edit-marker-selected"),this._offsetMarker(t,4)),t.style.display="")},_offsetMarker:function(t,e){var i=parseInt(t.style.marginTop,10)-e,o=parseInt(t.style.marginLeft,10)-e;t.style.marginTop=i+"px",t.style.marginLeft=o+"px"}}),L.Marker.addInitHook(function(){L.Edit.Marker&&(this.editing=new L.Edit.Marker(this),this.options.editable&&this.editing.enable())}),L.Edit=L.Edit||{},L.Edit.Poly=L.Handler.extend({initialize:function(t){this.latlngs=[t._latlngs],t._holes&&(this.latlngs=this.latlngs.concat(t._holes)),this._poly=t,this._poly.on("revert-edited",this._updateLatLngs,this)},_defaultShape:function(){return L.Polyline._flat?L.Polyline._flat(this._poly._latlngs)?this._poly._latlngs:this._poly._latlngs[0]:this._poly._latlngs},_eachVertexHandler:function(t){for(var e=0;et&&(i._index+=e)})},_createMiddleMarker:function(t,e){var i,o,a,n=this._getMiddleLatLng(t,e),s=this._createMarker(n);s.setOpacity(.6),t._middleRight=e._middleLeft=s,o=function(){s.off("touchmove",o,this);var a=e._index;s._index=a,s.off("click",i,this).on("click",this._onMarkerClick,this),n.lat=s.getLatLng().lat,n.lng=s.getLatLng().lng,this._spliceLatLngs(a,0,n),this._markers.splice(a,0,s),s.setOpacity(1),this._updateIndexes(a,1),e._index++,this._updatePrevNext(t,s),this._updatePrevNext(s,e),this._poly.fire("editstart")},a=function(){s.off("dragstart",o,this),s.off("dragend",a,this),s.off("touchmove",o,this),this._createMiddleMarker(t,s),this._createMiddleMarker(s,e)},i=function(){o.call(this),a.call(this),this._fireEdit()},s.on("click",i,this).on("dragstart",o,this).on("dragend",a,this).on("touchmove",o,this),this._markerGroup.addLayer(s)},_updatePrevNext:function(t,e){t&&(t._next=e),e&&(e._prev=t)},_getMiddleLatLng:function(t,e){var i=this._poly._map,o=i.project(t.getLatLng()),a=i.project(e.getLatLng());return i.unproject(o._add(a)._divideBy(2))}}),L.Polyline.addInitHook(function(){this.editing||(L.Edit.Poly&&(this.editing=new L.Edit.Poly(this),this.options.editable&&this.editing.enable()),this.on("add",function(){this.editing&&this.editing.enabled()&&this.editing.addHooks()}),this.on("remove",function(){this.editing&&this.editing.enabled()&&this.editing.removeHooks()}))}),L.Edit=L.Edit||{},L.Edit.SimpleShape=L.Handler.extend({options:{moveIcon:new L.DivIcon({iconSize:new L.Point(8,8),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-move"}),resizeIcon:new L.DivIcon({iconSize:new L.Point(8,8),
+className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-resize"}),touchMoveIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-move leaflet-touch-icon"}),touchResizeIcon:new L.DivIcon({iconSize:new L.Point(20,20),className:"leaflet-div-icon leaflet-editing-icon leaflet-edit-resize leaflet-touch-icon"})},initialize:function(t,e){L.Browser.touch&&(this.options.moveIcon=this.options.touchMoveIcon,this.options.resizeIcon=this.options.touchResizeIcon),this._shape=t,L.Util.setOptions(this,e)},addHooks:function(){var t=this._shape;this._shape._map&&(this._map=this._shape._map,t.setStyle(t.options.editing),t._map&&(this._map=t._map,this._markerGroup||this._initMarkers(),this._map.addLayer(this._markerGroup)))},removeHooks:function(){var t=this._shape;if(t.setStyle(t.options.original),t._map){this._unbindMarker(this._moveMarker);for(var e=0,i=this._resizeMarkers.length;e "+L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.draw.handlers.circle.radius+": "+L.GeometryUtil.readableDistance(radius,!0,this.options.feet,this.options.nautic)}),this._shape.setRadius(radius),this._map.fire(L.Draw.Event.EDITRESIZE,{layer:this._shape})}}),L.Circle.addInitHook(function(){L.Edit.Circle&&(this.editing=new L.Edit.Circle(this),this.options.editable&&this.editing.enable())}),L.Map.mergeOptions({touchExtend:!0}),L.Map.TouchExtend=L.Handler.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane},addHooks:function(){L.DomEvent.on(this._container,"touchstart",this._onTouchStart,this),L.DomEvent.on(this._container,"touchend",this._onTouchEnd,this),L.DomEvent.on(this._container,"touchmove",this._onTouchMove,this),this._detectIE()?(L.DomEvent.on(this._container,"MSPointerDown",this._onTouchStart,this),L.DomEvent.on(this._container,"MSPointerUp",this._onTouchEnd,this),L.DomEvent.on(this._container,"MSPointerMove",this._onTouchMove,this),L.DomEvent.on(this._container,"MSPointerCancel",this._onTouchCancel,this)):(L.DomEvent.on(this._container,"touchcancel",this._onTouchCancel,this),L.DomEvent.on(this._container,"touchleave",this._onTouchLeave,this))},removeHooks:function(){L.DomEvent.off(this._container,"touchstart",this._onTouchStart,this),L.DomEvent.off(this._container,"touchend",this._onTouchEnd,this),L.DomEvent.off(this._container,"touchmove",this._onTouchMove,this),this._detectIE()?(L.DomEvent.off(this._container,"MSPointerDown",this._onTouchStart,this),L.DomEvent.off(this._container,"MSPointerUp",this._onTouchEnd,this),L.DomEvent.off(this._container,"MSPointerMove",this._onTouchMove,this),L.DomEvent.off(this._container,"MSPointerCancel",this._onTouchCancel,this)):(L.DomEvent.off(this._container,"touchcancel",this._onTouchCancel,this),L.DomEvent.off(this._container,"touchleave",this._onTouchLeave,this))},_touchEvent:function(t,e){var i={};if(void 0!==t.touches){if(!t.touches.length)return;i=t.touches[0]}else{if("touch"!==t.pointerType)return;if(i=t,!this._filterClick(t))return}var o=this._map.mouseEventToContainerPoint(i),a=this._map.mouseEventToLayerPoint(i),n=this._map.layerPointToLatLng(a);this._map.fire(e,{latlng:n,layerPoint:a,containerPoint:o,pageX:i.pageX,pageY:i.pageY,originalEvent:t})},_filterClick:function(t){var e=t.timeStamp||t.originalEvent.timeStamp,i=L.DomEvent._lastClick&&e-L.DomEvent._lastClick;return i&&i>100&&i<500||t.target._simulatedClick&&!t._simulated?(L.DomEvent.stop(t),!1):(L.DomEvent._lastClick=e,!0)},_onTouchStart:function(t){if(this._map._loaded){this._touchEvent(t,"touchstart")}},_onTouchEnd:function(t){if(this._map._loaded){this._touchEvent(t,"touchend")}},_onTouchCancel:function(t){if(this._map._loaded){var e="touchcancel";this._detectIE()&&(e="pointercancel"),this._touchEvent(t,e)}},_onTouchLeave:function(t){if(this._map._loaded){this._touchEvent(t,"touchleave")}},_onTouchMove:function(t){if(this._map._loaded){this._touchEvent(t,"touchmove")}},_detectIE:function(){var e=t.navigator.userAgent,i=e.indexOf("MSIE ");if(i>0)return parseInt(e.substring(i+5,e.indexOf(".",i)),10);if(e.indexOf("Trident/")>0){var o=e.indexOf("rv:");return parseInt(e.substring(o+3,e.indexOf(".",o)),10)}var a=e.indexOf("Edge/");return a>0&&parseInt(e.substring(a+5,e.indexOf(".",a)),10)}}),L.Map.addInitHook("addHandler","touchExtend",L.Map.TouchExtend),L.Marker.Touch=L.Marker.extend({_initInteraction:function(){return this.addInteractiveTarget?L.Marker.prototype._initInteraction.apply(this):this._initInteractionLegacy()},_initInteractionLegacy:function(){if(this.options.clickable){var t=this._icon,e=["dblclick","mousedown","mouseover","mouseout","contextmenu","touchstart","touchend","touchmove"];this._detectIE?e.concat(["MSPointerDown","MSPointerUp","MSPointerMove","MSPointerCancel"]):e.concat(["touchcancel"]),L.DomUtil.addClass(t,"leaflet-clickable"),L.DomEvent.on(t,"click",this._onMouseClick,this),L.DomEvent.on(t,"keypress",this._onKeyPress,this);for(var i=0;i0)return parseInt(e.substring(i+5,e.indexOf(".",i)),10);if(e.indexOf("Trident/")>0){var o=e.indexOf("rv:");return parseInt(e.substring(o+3,e.indexOf(".",o)),10)}var a=e.indexOf("Edge/");return a>0&&parseInt(e.substring(a+5,e.indexOf(".",a)),10)}}),L.LatLngUtil={cloneLatLngs:function(t){for(var e=[],i=0,o=t.length;i2){for(var s=0;s1&&(i=i+s+r[1])}return i},readableArea:function(e,i,o){var a,n,o=L.Util.extend({},t,o);return i?(n=["ha","m"],type=typeof i,"string"===type?n=[i]:"boolean"!==type&&(n=i),a=e>=1e6&&-1!==n.indexOf("km")?L.GeometryUtil.formattedNumber(1e-6*e,o.km)+" km²":e>=1e4&&-1!==n.indexOf("ha")?L.GeometryUtil.formattedNumber(1e-4*e,o.ha)+" ha":L.GeometryUtil.formattedNumber(e,o.m)+" m²"):(e/=.836127,a=e>=3097600?L.GeometryUtil.formattedNumber(e/3097600,o.mi)+" mi²":e>=4840?L.GeometryUtil.formattedNumber(e/4840,o.ac)+" acres":L.GeometryUtil.formattedNumber(e,o.yd)+" yd²"),a},readableDistance:function(e,i,o,a,n){var s,n=L.Util.extend({},t,n);switch(i?"string"==typeof i?i:"metric":o?"feet":a?"nauticalMile":"yards"){case"metric":s=e>1e3?L.GeometryUtil.formattedNumber(e/1e3,n.km)+" km":L.GeometryUtil.formattedNumber(e,n.m)+" m";break;case"feet":e*=3.28083,s=L.GeometryUtil.formattedNumber(e,n.ft)+" ft";break;case"nauticalMile":e*=.53996,s=L.GeometryUtil.formattedNumber(e/1e3,n.nm)+" nm";break;case"yards":default:e*=1.09361,s=e>1760?L.GeometryUtil.formattedNumber(e/1760,n.mi)+" miles":L.GeometryUtil.formattedNumber(e,n.yd)+" yd"}return s},isVersion07x:function(){var t=L.version.split(".");return 0===parseInt(t[0],10)&&7===parseInt(t[1],10)}})}(),L.Util.extend(L.LineUtil,{segmentsIntersect:function(t,e,i,o){return this._checkCounterclockwise(t,i,o)!==this._checkCounterclockwise(e,i,o)&&this._checkCounterclockwise(t,e,i)!==this._checkCounterclockwise(t,e,o)},_checkCounterclockwise:function(t,e,i){return(i.y-t.y)*(e.x-t.x)>(e.y-t.y)*(i.x-t.x)}}),L.Polyline.include({intersects:function(){var t,e,i,o=this._getProjectedPoints(),a=o?o.length:0;if(this._tooFewPointsForIntersection())return!1;for(t=a-1;t>=3;t--)if(e=o[t-1],i=o[t],this._lineSegmentsIntersectsRange(e,i,t-2))return!0;return!1},newLatLngIntersects:function(t,e){return!!this._map&&this.newPointIntersects(this._map.latLngToLayerPoint(t),e)},newPointIntersects:function(t,e){var i=this._getProjectedPoints(),o=i?i.length:0,a=i?i[o-1]:null,n=o-2;return!this._tooFewPointsForIntersection(1)&&this._lineSegmentsIntersectsRange(a,t,n,e?1:0)},_tooFewPointsForIntersection:function(t){var e=this._getProjectedPoints(),i=e?e.length:0;return i+=t||0,!e||i<=3},_lineSegmentsIntersectsRange:function(t,e,i,o){var a,n,s=this._getProjectedPoints();o=o||0;for(var r=i;r>o;r--)if(a=s[r-1],n=s[r],L.LineUtil.segmentsIntersect(t,e,a,n))return!0;return!1},_getProjectedPoints:function(){if(!this._defaultShape)return this._originalPoints;for(var t=[],e=this._defaultShape(),i=0;i=2?L.Toolbar.include(L.Evented.prototype):L.Toolbar.include(L.Mixin.Events)},enabled:function(){return null!==this._activeMode},disable:function(){this.enabled()&&this._activeMode.handler.disable()},addToolbar:function(t){var e,i=L.DomUtil.create("div","leaflet-draw-section"),o=0,a=this._toolbarClass||"",n=this.getModeHandlers(t);for(this._toolbarContainer=L.DomUtil.create("div","leaflet-draw-toolbar leaflet-bar"),this._map=t,e=0;e0&&this._singleLineLabel&&(L.DomUtil.removeClass(this._container,"leaflet-draw-tooltip-single"),this._singleLineLabel=!1):(L.DomUtil.addClass(this._container,"leaflet-draw-tooltip-single"),this._singleLineLabel=!0),this._container.innerHTML=(t.subtext.length>0?''+t.subtext+" ":"")+""+t.text+" ",t.text||t.subtext?(this._visible=!0,this._container.style.visibility="inherit"):(this._visible=!1,this._container.style.visibility="hidden"),this):this},updatePosition:function(t){var e=this._map.latLngToLayerPoint(t),i=this._container;return this._container&&(this._visible&&(i.style.visibility="inherit"),L.DomUtil.setPosition(i,e)),this},showAsError:function(){return this._container&&L.DomUtil.addClass(this._container,"leaflet-error-draw-tooltip"),this},removeError:function(){return this._container&&L.DomUtil.removeClass(this._container,"leaflet-error-draw-tooltip"),this},_onMouseOut:function(){this._container&&(this._container.style.visibility="hidden")}}),L.DrawToolbar=L.Toolbar.extend({statics:{TYPE:"draw"},options:{polyline:{},polygon:{},rectangle:{},circle:{},marker:{},circlemarker:{}},initialize:function(t){for(var e in this.options)this.options.hasOwnProperty(e)&&t[e]&&(t[e]=L.extend({},this.options[e],t[e]));this._toolbarClass="leaflet-draw-draw",L.Toolbar.prototype.initialize.call(this,t)},getModeHandlers:function(t){return[{enabled:this.options.polyline,handler:new L.Draw.Polyline(t,this.options.polyline),title:L.drawLocal.draw.toolbar.buttons.polyline},{enabled:this.options.polygon,handler:new L.Draw.Polygon(t,this.options.polygon),title:L.drawLocal.draw.toolbar.buttons.polygon},{enabled:this.options.rectangle,handler:new L.Draw.Rectangle(t,this.options.rectangle),title:L.drawLocal.draw.toolbar.buttons.rectangle},{enabled:this.options.circle,handler:new L.Draw.Circle(t,this.options.circle),title:L.drawLocal.draw.toolbar.buttons.circle},{enabled:this.options.marker,handler:new L.Draw.Marker(t,this.options.marker),title:L.drawLocal.draw.toolbar.buttons.marker},{enabled:this.options.circlemarker,handler:new L.Draw.CircleMarker(t,this.options.circlemarker),title:L.drawLocal.draw.toolbar.buttons.circlemarker}]},getActions:function(t){return[{enabled:t.completeShape,title:L.drawLocal.draw.toolbar.finish.title,text:L.drawLocal.draw.toolbar.finish.text,callback:t.completeShape,context:t},{enabled:t.deleteLastVertex,title:L.drawLocal.draw.toolbar.undo.title,text:L.drawLocal.draw.toolbar.undo.text,callback:t.deleteLastVertex,context:t},{title:L.drawLocal.draw.toolbar.actions.title,text:L.drawLocal.draw.toolbar.actions.text,callback:this.disable,context:this}]},setOptions:function(t){L.setOptions(this,t);for(var e in this._modes)this._modes.hasOwnProperty(e)&&t.hasOwnProperty(e)&&this._modes[e].handler.setOptions(t[e])}}),L.EditToolbar=L.Toolbar.extend({statics:{TYPE:"edit"},options:{edit:{selectedPathOptions:{dashArray:"10, 10",fill:!0,fillColor:"#fe57a1",fillOpacity:.1,maintainColor:!1}},remove:{},poly:null,featureGroup:null},initialize:function(t){t.edit&&(void 0===t.edit.selectedPathOptions&&(t.edit.selectedPathOptions=this.options.edit.selectedPathOptions),t.edit.selectedPathOptions=L.extend({},this.options.edit.selectedPathOptions,t.edit.selectedPathOptions)),t.remove&&(t.remove=L.extend({},this.options.remove,t.remove)),t.poly&&(t.poly=L.extend({},this.options.poly,t.poly)),this._toolbarClass="leaflet-draw-edit",L.Toolbar.prototype.initialize.call(this,t),this._selectedFeatureCount=0},getModeHandlers:function(t){var e=this.options.featureGroup;return[{enabled:this.options.edit,handler:new L.EditToolbar.Edit(t,{featureGroup:e,selectedPathOptions:this.options.edit.selectedPathOptions,poly:this.options.poly}),title:L.drawLocal.edit.toolbar.buttons.edit},{enabled:this.options.remove,handler:new L.EditToolbar.Delete(t,{featureGroup:e}),title:L.drawLocal.edit.toolbar.buttons.remove}]},getActions:function(t){var e=[{title:L.drawLocal.edit.toolbar.actions.save.title,text:L.drawLocal.edit.toolbar.actions.save.text,callback:this._save,context:this},{title:L.drawLocal.edit.toolbar.actions.cancel.title,text:L.drawLocal.edit.toolbar.actions.cancel.text,callback:this.disable,context:this}];return t.removeAllLayers&&e.push({title:L.drawLocal.edit.toolbar.actions.clearAll.title,text:L.drawLocal.edit.toolbar.actions.clearAll.text,callback:this._clearAllLayers,context:this}),e},addToolbar:function(t){var e=L.Toolbar.prototype.addToolbar.call(this,t);return this._checkDisabled(),this.options.featureGroup.on("layeradd layerremove",this._checkDisabled,this),e},removeToolbar:function(){this.options.featureGroup.off("layeradd layerremove",this._checkDisabled,this),L.Toolbar.prototype.removeToolbar.call(this)},disable:function(){this.enabled()&&(this._activeMode.handler.revertLayers(),L.Toolbar.prototype.disable.call(this))},_save:function(){this._activeMode.handler.save(),this._activeMode&&this._activeMode.handler.disable()},_clearAllLayers:function(){this._activeMode.handler.removeAllLayers(),this._activeMode&&this._activeMode.handler.disable()},_checkDisabled:function(){var t,e=this.options.featureGroup,i=0!==e.getLayers().length;this.options.edit&&(t=this._modes[L.EditToolbar.Edit.TYPE].button,i?L.DomUtil.removeClass(t,"leaflet-disabled"):L.DomUtil.addClass(t,"leaflet-disabled"),t.setAttribute("title",i?L.drawLocal.edit.toolbar.buttons.edit:L.drawLocal.edit.toolbar.buttons.editDisabled)),this.options.remove&&(t=this._modes[L.EditToolbar.Delete.TYPE].button,i?L.DomUtil.removeClass(t,"leaflet-disabled"):L.DomUtil.addClass(t,"leaflet-disabled"),t.setAttribute("title",i?L.drawLocal.edit.toolbar.buttons.remove:L.drawLocal.edit.toolbar.buttons.removeDisabled))}}),L.EditToolbar.Edit=L.Handler.extend({statics:{TYPE:"edit"},initialize:function(t,e){if(L.Handler.prototype.initialize.call(this,t),L.setOptions(this,e),this._featureGroup=e.featureGroup,!(this._featureGroup instanceof L.FeatureGroup))throw new Error("options.featureGroup must be a L.FeatureGroup");this._uneditedLayerProps={},this.type=L.EditToolbar.Edit.TYPE;var i=L.version.split(".");1===parseInt(i[0],10)&&parseInt(i[1],10)>=2?L.EditToolbar.Edit.include(L.Evented.prototype):L.EditToolbar.Edit.include(L.Mixin.Events)},enable:function(){!this._enabled&&this._hasAvailableLayers()&&(this.fire("enabled",{handler:this.type}),this._map.fire(L.Draw.Event.EDITSTART,{handler:this.type}),L.Handler.prototype.enable.call(this),this._featureGroup.on("layeradd",this._enableLayerEdit,this).on("layerremove",this._disableLayerEdit,this))},disable:function(){this._enabled&&(this._featureGroup.off("layeradd",this._enableLayerEdit,this).off("layerremove",this._disableLayerEdit,this),L.Handler.prototype.disable.call(this),this._map.fire(L.Draw.Event.EDITSTOP,{handler:this.type}),this.fire("disabled",{handler:this.type}))},addHooks:function(){var t=this._map;t&&(t.getContainer().focus(),this._featureGroup.eachLayer(this._enableLayerEdit,this),this._tooltip=new L.Draw.Tooltip(this._map),this._tooltip.updateContent({text:L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.edit.handlers.edit.tooltip.subtext}),t._editTooltip=this._tooltip,this._updateTooltip(),this._map.on("mousemove",this._onMouseMove,this).on("touchmove",this._onMouseMove,this).on("MSPointerMove",this._onMouseMove,this).on(L.Draw.Event.EDITVERTEX,this._updateTooltip,this))},removeHooks:function(){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(L.Draw.Event.EDITVERTEX,this._updateTooltip,this))},revertLayers:function(){this._featureGroup.eachLayer(function(t){this._revertLayer(t)},this)},save:function(){var t=new L.LayerGroup;this._featureGroup.eachLayer(function(e){e.edited&&(t.addLayer(e),e.edited=!1)}),this._map.fire(L.Draw.Event.EDITED,{layers:t})},_backupLayer:function(t){var e=L.Util.stamp(t);this._uneditedLayerProps[e]||(t instanceof L.Polyline||t instanceof L.Polygon||t instanceof L.Rectangle?this._uneditedLayerProps[e]={latlngs:L.LatLngUtil.cloneLatLngs(t.getLatLngs())}:t instanceof L.Circle?this._uneditedLayerProps[e]={latlng:L.LatLngUtil.cloneLatLng(t.getLatLng()),radius:t.getRadius()}:(t instanceof L.Marker||t instanceof L.CircleMarker)&&(this._uneditedLayerProps[e]={latlng:L.LatLngUtil.cloneLatLng(t.getLatLng())}))},_getTooltipText:function(){return{text:L.drawLocal.edit.handlers.edit.tooltip.text,subtext:L.drawLocal.edit.handlers.edit.tooltip.subtext}},_updateTooltip:function(){this._tooltip.updateContent(this._getTooltipText())},_revertLayer:function(t){var e=L.Util.stamp(t);t.edited=!1,this._uneditedLayerProps.hasOwnProperty(e)&&(t instanceof L.Polyline||t instanceof L.Polygon||t instanceof L.Rectangle?t.setLatLngs(this._uneditedLayerProps[e].latlngs):t instanceof L.Circle?(t.setLatLng(this._uneditedLayerProps[e].latlng),t.setRadius(this._uneditedLayerProps[e].radius)):(t instanceof L.Marker||t instanceof L.CircleMarker)&&t.setLatLng(this._uneditedLayerProps[e].latlng),t.fire("revert-edited",{layer:t}))},_enableLayerEdit:function(t){var e,i,o=t.layer||t.target||t;this._backupLayer(o),this.options.poly&&(i=L.Util.extend({},this.options.poly),o.options.poly=i),this.options.selectedPathOptions&&(e=L.Util.extend({},this.options.selectedPathOptions),e.maintainColor&&(e.color=o.options.color,e.fillColor=o.options.fillColor),o.options.original=L.extend({},o.options),o.options.editing=e),o instanceof L.Marker?(o.editing&&o.editing.enable(),o.dragging.enable(),o.on("dragend",this._onMarkerDragEnd).on("touchmove",this._onTouchMove,this).on("MSPointerMove",this._onTouchMove,this).on("touchend",this._onMarkerDragEnd,this).on("MSPointerUp",this._onMarkerDragEnd,this)):o.editing.enable()},_disableLayerEdit:function(t){var e=t.layer||t.target||t;e.edited=!1,e.editing&&e.editing.disable(),delete e.options.editing,delete e.options.original,
+this._selectedPathOptions&&(e instanceof L.Marker?this._toggleMarkerHighlight(e):(e.setStyle(e.options.previousOptions),delete e.options.previousOptions)),e instanceof L.Marker?(e.dragging.disable(),e.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)):e.editing.disable()},_onMouseMove:function(t){this._tooltip.updatePosition(t.latlng)},_onMarkerDragEnd:function(t){var e=t.target;e.edited=!0,this._map.fire(L.Draw.Event.EDITMOVE,{layer:e})},_onTouchMove:function(t){var e=t.originalEvent.changedTouches[0],i=this._map.mouseEventToLayerPoint(e),o=this._map.layerPointToLatLng(i);t.target.setLatLng(o)},_hasAvailableLayers:function(){return 0!==this._featureGroup.getLayers().length}}),L.EditToolbar.Delete=L.Handler.extend({statics:{TYPE:"remove"},initialize:function(t,e){if(L.Handler.prototype.initialize.call(this,t),L.Util.setOptions(this,e),this._deletableLayers=this.options.featureGroup,!(this._deletableLayers instanceof L.FeatureGroup))throw new Error("options.featureGroup must be a L.FeatureGroup");this.type=L.EditToolbar.Delete.TYPE;var i=L.version.split(".");1===parseInt(i[0],10)&&parseInt(i[1],10)>=2?L.EditToolbar.Delete.include(L.Evented.prototype):L.EditToolbar.Delete.include(L.Mixin.Events)},enable:function(){!this._enabled&&this._hasAvailableLayers()&&(this.fire("enabled",{handler:this.type}),this._map.fire(L.Draw.Event.DELETESTART,{handler:this.type}),L.Handler.prototype.enable.call(this),this._deletableLayers.on("layeradd",this._enableLayerDelete,this).on("layerremove",this._disableLayerDelete,this))},disable:function(){this._enabled&&(this._deletableLayers.off("layeradd",this._enableLayerDelete,this).off("layerremove",this._disableLayerDelete,this),L.Handler.prototype.disable.call(this),this._map.fire(L.Draw.Event.DELETESTOP,{handler:this.type}),this.fire("disabled",{handler:this.type}))},addHooks:function(){var t=this._map;t&&(t.getContainer().focus(),this._deletableLayers.eachLayer(this._enableLayerDelete,this),this._deletedLayers=new L.LayerGroup,this._tooltip=new L.Draw.Tooltip(this._map),this._tooltip.updateContent({text:L.drawLocal.edit.handlers.remove.tooltip.text}),this._map.on("mousemove",this._onMouseMove,this))},removeHooks:function(){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(t){this._deletableLayers.addLayer(t),t.fire("revert-deleted",{layer:t})},this)},save:function(){this._map.fire(L.Draw.Event.DELETED,{layers:this._deletedLayers})},removeAllLayers:function(){this._deletableLayers.eachLayer(function(t){this._removeLayer({layer:t})},this),this.save()},_enableLayerDelete:function(t){(t.layer||t.target||t).on("click",this._removeLayer,this)},_disableLayerDelete:function(t){var e=t.layer||t.target||t;e.off("click",this._removeLayer,this),this._deletedLayers.removeLayer(e)},_removeLayer:function(t){var e=t.layer||t.target||t;this._deletableLayers.removeLayer(e),this._deletedLayers.addLayer(e),e.fire("deleted")},_onMouseMove:function(t){this._tooltip.updatePosition(t.latlng)},_hasAvailableLayers:function(){return 0!==this._deletableLayers.getLayers().length}})}(window,document);
\ No newline at end of file
diff --git a/node_modules/leaflet-draw/docs/css/main.css b/node_modules/leaflet-draw/docs/css/main.css
new file mode 100644
index 00000000..e2d89fb4
--- /dev/null
+++ b/node_modules/leaflet-draw/docs/css/main.css
@@ -0,0 +1,1087 @@
+
+/* general styles */
+
+html, body, input, select, button, textarea, table {
+ font-size: 100%;
+ font-family: 'Open Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
+ -webkit-font-smoothing: antialiased;
+ -moz-osx-font-smoothing: grayscale;
+ text-rendering: optimizeLegibility;
+}
+
+body {
+ line-height: 1.5;
+ color: #333;
+}
+
+p {
+ margin: 24px 0;
+}
+
+a, a span.hljs-string {
+ color: #1EB300;
+}
+
+a:hover, a:focus {
+ color: #160;
+}
+
+hr {
+ background: #ddd;
+ color: #ddd;
+ height: 1px;
+ margin: 0 0 1.4em;
+ border: none;
+ clear: both;
+}
+
+.clearfix:before,
+.clearfix:after {
+ content: " ";
+ display: table;
+}
+
+.clearfix:after {
+ clear: both;
+}
+
+table {
+ width: 100%;
+ border-collapse: collapse;
+ margin-bottom: 2em;
+}
+
+th, td {
+ text-align: left;
+ border: 0;
+ border: 1px solid #eee;
+ padding: 0.5em 1em 0.5em 1em;
+}
+
+table th {
+ background: #eee;
+}
+
+table td {
+ color: #666;
+}
+
+table td:first-child {
+ color: #777;
+}
+
+table td:last-child {
+ color: black;
+}
+
+table td code i {
+ color: #00A707;
+}
+
+table td code b {
+ color: black;
+ font-weight: normal;
+}
+
+
+/* headings */
+
+h2 {
+ font-weight: 400;
+ font-size: 2em;
+ font-weight: 300;
+ color: black;
+ margin-top: 1.6em;
+ padding-top: .2em;
+}
+
+h2:first-child {
+ margin-top: 1em;
+}
+
+h2:target {
+ color: #1EB300;
+}
+
+h3 {
+ margin-top: 1.5em;
+ padding-top: .5em;
+ color: black;
+ font-weight: 500;
+ font-size: 1.4em;
+}
+
+.blog-page h3 {
+ padding-top: 0;
+}
+
+h4 {
+ font-size: 1.1em;
+ font-weight: 500;
+ margin: 1em 0 1em;
+}
+
+
+/* general layout */
+
+.container {
+ max-width: 54em;
+ padding: 0 6em 1.5em;
+ margin: 0 auto;
+}
+.footer {
+ margin-top: 50px;
+ color: #777;
+}
+
+
+/* header */
+
+h1 {
+ margin: 1.25em 0 1.5em;
+ text-align: center;
+}
+
+h1 a {
+ display: block;
+ margin: auto;
+ padding: 0 2em;
+ -webkit-transition: 0.8s all;
+ -webkit-animation: leafanim 3s ease 3s 1 normal none;
+ transition: 0.8s all;
+ animation: leafanim 3s ease 3s 1 normal none;
+}
+
+@-webkit-keyframes leafanim {
+ 50% { -webkit-filter: hue-rotate(-70deg) saturate(1.2); }
+}
+
+@keyframes leafanim {
+ 50% { -webkit-filter: hue-rotate(-70deg) saturate(1.2); }
+}
+
+h1 a img {
+ display: block;
+ margin: auto;
+ max-width: 100%;
+}
+
+h1 a:hover, h1 a:focus {
+ -webkit-filter: hue-rotate(-70deg) saturate(1.5);
+}
+
+h3.tagline {
+ font-weight: 300;
+ font-size: 1.5em;
+ margin-top: -.75em;
+ padding: 0;
+ color: #777;
+ text-align: center;
+ margin-bottom: 30px;
+}
+
+.nav {
+ overflow: hidden;
+ list-style: none;
+ padding: 0 30px;
+ text-align: center;
+ font-size: 1.25em;
+ margin-bottom: 40px;
+ border-bottom: 1px solid #ddd;
+ padding-bottom: 40px;
+}
+
+.nav li {
+ display: inline-block;
+ padding: .333em .5em;
+ color: #999;
+}
+
+.nav li a {
+ font-weight: 400;
+ text-decoration: none;
+}
+
+.ext-links {
+ position: fixed;
+ top: 1.5em;
+ right: 1.5em;
+}
+
+.ext-link {
+ display: block;
+ opacity: 0.5;
+ -webkit-animation: fadein 1s;
+ animation: fadein 1s;
+}
+.ext-link:hover {
+ opacity: 1;
+}
+@-webkit-keyframes fadein {
+ from { opacity: 0; }
+ to { opacity: 0.5; }
+}
+@keyframes fadein {
+ from { opacity: 0; }
+ to { opacity: 0.5; }
+}
+
+
+/* content */
+
+.container code, .container pre code {
+ font-family: "Consolas", "Menlo", "Lucida Console", "Courier New", monospace;
+ -webkit-font-smoothing: subpixel-antialiased;
+}
+.container pre code {
+ font-size: 14px;
+ padding: .75em 1em;
+ border-radius: 5px;
+ white-space: pre;
+ overflow: auto;
+}
+.container pre {
+ border-radius: 5px;
+}
+
+.container .map {
+ border: 1px solid #ccc;
+}
+.container .map:focus {
+ border-color: #999;
+}
+
+.quiet {
+ color: #999;
+}
+
+
+/* frontpage */
+
+.map-home {
+ height: 300px;
+ margin-top: 50px;
+ margin-bottom: 50px;
+}
+
+.usedby-title {
+ text-align: center;
+ background-color: #f5f5f5;
+ padding: 1.5em 1em 0.5em;
+ margin: 0;
+}
+
+.usedby {
+ margin: 0 0 3em;
+ text-align: center;
+ padding: 0 3em 2em;
+ background-color: #f5f5f5;
+}
+
+.logo {
+ display: inline-block;
+ opacity: 0.6;
+ height: 32px;
+ overflow: hidden;
+ text-indent: -9999px;
+ margin: 1em;
+ background-repeat: no-repeat;
+ background-size: 100%;
+ vertical-align: middle;
+ -webkit-transition: opacity .15s ease;
+ transition: opacity .15s ease;
+}
+
+.logo:hover { opacity: 1; }
+
+.logo-foursquare {
+ background-position: 50% -4px;
+ width: 135px;
+}
+
+.logo-pinterest {
+ background-position: 50% -39px;
+ width: 115px;
+}
+
+.logo-500px {
+ background-position: 50% -48px;
+ width: 52px;
+ background-size: 80px;
+}
+
+.logo-evernote {
+ background-position: 50% -169px;
+ width: 170px;
+ height: 43px;
+}
+
+.logo-ftimes {
+ background-position: 50% -190px;
+ width: 112px;
+ height: 40px;
+ background-size: 145px;
+}
+
+.logo-github {
+ background-position: 50% -178px;
+ width: 110px;
+}
+
+.logo-wpost {
+ background-position: 50% -327px;
+ width: 170px;
+}
+
+.logo-npr {
+ background-position: 50% -214px;
+ width: 100px;
+ height: 34px;
+}
+
+.logo-usatoday {
+ background-position: 50% -299px;
+ width: 120px;
+ height: 30px;
+}
+
+.logo-facebook {
+ background-position: 50% -356px;
+ width: 130px;
+}
+
+.logo-flickr {
+ background-position: 50% -277px;
+ width: 92px;
+ height: 29px;
+}
+
+.logo-datagov {
+ background-position: 50% -452px;
+ width: 135px;
+ height: 26px;
+}
+
+.logo-ign {
+ background-position: 50% -393px;
+ width: 110px;
+}
+
+.logo-etsy {
+ background-position: 50% -428px;
+ width: 57px;
+ background-size: 110px;
+}
+
+.logo-european-commission {
+ background-position: 50% -526px;
+ width: 125px;
+}
+
+.logo-nps {
+ background-position: 50% -483px;
+ width: 32px;
+ height: 40px;
+ margin-top: .5em;
+ margin-bottom: .5em;
+ background-size: 106px;
+}
+
+.features {
+ -webkit-column-count: 3;
+ -moz-column-count: 3;
+ column-count: 3;
+}
+.features ul {
+ padding-left: 1.6em;
+ margin: 0 0 1.8em;
+}
+.features h3 {
+ margin: 0 0 0.8em;
+ padding: 0;
+}
+.features h4 {
+ margin: 0 0 0.3em;
+}
+
+
+/* tutorials */
+
+.example-img {
+ float: left;
+ width: 14em;
+ max-width: 100%;
+ border-radius: 5px;
+ margin: 0 1.5em 1.5em 0;
+ border: thin solid #ccc;
+}
+
+.examples .container h3 {
+ margin-top: 0;
+}
+.post-date {
+ float: left;
+ width: 130px;
+ line-height: 1.6;
+ color: #999;
+ font-size: 18px;
+}
+.post-info {
+ overflow: hidden;
+}
+.post-title {
+ margin-top: 0;
+}
+
+
+/* plugins */
+
+.plugins td:first-child,
+.plugins td:last-child a {
+ white-space: nowrap;
+}
+
+table.plugins td:first-child a {
+ font-weight: bold;
+}
+
+.plugins-page .toc-col {
+ float: left;
+ width: 25%;
+}
+
+
+/* API docs */
+
+.api-page .toc-col {
+ position: relative;
+ float: left;
+ width: 20%;
+ padding-right: 1em;
+ margin: 0;
+ box-sizing: border-box;
+}
+
+.api-page .toc-col.map-col {
+ border-right: thin solid #eee;
+}
+
+.api-page .toc-col.map-col ~ .toc-col {
+ right: -1.5em;
+}
+
+.api-page #toc ~ h2 {
+ font-weight: 700;
+ font-size: 1.75em;
+ color: #333;
+ border-bottom: 3px solid #555;
+ transition: border-color .25s ease;
+}
+.api-page #toc ~ h2:target {
+ border-color: #1EB300;
+}
+.api-page h2:first-child {
+ border: none;
+}
+
+#toc h4 {
+ margin-top: 0;
+}
+
+#toc ul {
+ padding: 0;
+ list-style: none;
+ margin-top: 0;
+ margin-bottom: 25px;
+}
+
+#toc .colborder {
+ padding-right: 14px;
+}
+
+#toc .span-3 {
+ margin: 0;
+ padding-right: 3em;
+ width: 16.825%;
+ box-sizing: border-box;
+}
+
+#toc .span-3.last {
+ padding-right: 0;
+}
+
+#toc-copy {
+ display: none;
+}
+
+#toc-copy div {
+ border: 0;
+ margin: 0;
+ padding: 0;
+ width: auto;
+ float: none;
+}
+
+#toc-copy h4 {
+ margin: 0;
+ padding-bottom: .333em;
+}
+
+#toc-copy hr {
+ background-color: transparent;
+ margin: 0 0 .5em;
+}
+
+#toc-copy ul {
+ display: none;
+ list-style: none;
+}
+
+#toc-copy ul li {
+ white-space: nowrap;
+}
+
+#toc-copy ul li a {
+ position: relative;
+ padding: .25em .5em 0;
+ z-index: 10;
+}
+
+#toc-copy .toc-col {
+ position: static;
+}
+
+@media screen and (max-width: 1350px) {
+ #toc-copy {
+ display: block;
+ position: fixed;
+ top: 0.1em;
+ left: 0.25em;
+ width: 32px;
+ height: 32px;
+ opacity: 0;
+ cursor: pointer;
+ -webkit-transition: opacity .2s ease;
+ transition: opacity .2s ease;
+ }
+
+ #toc-copy > div { display: none; }
+
+ .scrolled #toc-copy {
+ opacity: 1;
+ background: white;
+ }
+
+ #toc-copy.active {
+ background-color: white;
+ background-color: rgba(255, 255, 255, 0.9);
+ padding: 2em;
+ width: 100%;
+ height: 100%;
+ overflow-x: hidden;
+ overflow-y: scroll;
+ cursor: default;
+ box-sizing: border-box;
+ }
+
+ #toc-copy:before,
+ #toc-copy:after {
+ content: '';
+ position: absolute;
+ left: 5px;
+ width: 22px;
+ height: 14px;
+ border-top: 2px solid black;
+ cursor: pointer;
+ box-sizing: border-box;
+ -webkit-transition: -webkit-transform .25s ease;
+ transition: transform .25s ease;
+ }
+
+ #toc-copy:before {
+ top: 9px;
+ border-bottom: 2px solid black;
+ }
+
+ #toc-copy:after {
+ top: 15px;
+ }
+
+ #toc-copy.active:before {
+ top: 5px;
+ left: 9px;
+ border-bottom: 0;
+ -webkit-transform: rotate(-135deg);
+ transform: rotate(-135deg);
+ }
+
+ #toc-copy.active:after {
+ top: 13px;
+ left: 9px;
+ -webkit-transform: rotate(-45deg);
+ transform: rotate(-45deg);
+ }
+
+ #toc-copy.active div { display: block; }
+
+ #toc-copy h4.active, #toc-copy h4:hover {
+ color: black;
+ cursor: pointer;
+ }
+
+ #toc-copy h4.active + ul {
+ display: block;
+ padding: 0;
+ margin: 0 0 .5em;
+ }
+
+ #toc-copy ul li a { padding: .25em 0; }
+}
+
+@media screen and (min-width: 900px) and (max-width: 1350px) {
+ #toc-copy {
+ width: 40px;
+ height: 40px;
+ }
+
+ #toc-copy.active {
+ padding: 2.5em;
+ }
+
+ #toc-copy:before,
+ #toc-copy:after {
+ left: 8px;
+ }
+
+ #toc-copy:before { top: 13px; }
+
+ #toc-copy:after { top: 19px; }
+
+ #toc-copy.active:before {
+ top: 7px;
+ left: 10px;
+ }
+
+ #toc-copy.active:after {
+ top: 15px;
+ left: 10px;
+ }
+}
+
+@media screen and (min-width: 1350px) and (min-height: 600px) {
+ #toc-copy {
+ display: block;
+ position: fixed;
+ top: 0;
+ left: 0;
+ width: auto;
+ height: auto;
+ padding: 2em;
+ opacity: 0;
+ transition: opacity .25s ease;
+ -webkit-transition: opacity .25s ease;
+ }
+
+ #toc-copy:before {
+ content: 'Table of contents';
+ display: block;
+ margin: -.25em 0 1em;
+ font-size: 75%;
+ font-weight: 300;
+ text-transform: uppercase;
+ }
+
+ .scrolled #toc-copy { opacity: 1; }
+
+ #toc-copy h4 { padding-right: 5em; }
+
+ #toc-copy ul {
+ position: absolute;
+ left: 100%;
+ margin: -4.9em 0 0 -4.5em;
+ padding: 3em 6em 3em 0;
+ }
+
+ #toc-copy h4:hover + ul,
+ #toc-copy ul:hover {
+ display: block;
+ }
+
+ #toc-copy h4:hover + ul:before,
+ #toc-copy ul:hover:before {
+ content: '';
+ position: absolute;
+ top: 3.775em;
+ right: 100%;
+ margin-right: .25em;
+ width: 1em;
+ height: 1em;
+ border-top: 2px solid #eee;
+ }
+
+ #toc-copy h4:hover + ul:after,
+ #toc-copy ul:hover:after {
+ content: '';
+ position: absolute;
+ z-index: -1;
+ top: -1000px;
+ bottom: -1000px;
+ left: 0;
+ width: 12.5em;
+ background: white;
+ background: rgba(255,255,255,0.9);
+ }
+
+ .plugins-page #toc-copy h4:hover + ul:after,
+ .plugins-page #toc-copy ul:hover:after {
+ width: 17em;
+ }
+
+ #toc-copy h4:hover, #toc-copy h4.hover {
+ color: black;
+ cursor: pointer;
+ }
+}
+
+/* API docs - tables */
+
+.api-page table td {
+ color: #666;
+}
+.api-page table td:first-child {
+ color: #777;
+}
+.api-page table td:last-child {
+ color: black;
+}
+.api-page table td:last-child code {
+ word-break: break-word;
+ white-space: pre-wrap;
+}
+.api-page table td code i {
+ color: #9a9;
+}
+.api-page table td code b {
+ color: black;
+ font-weight: normal;
+}
+.api-page table td,
+.api-page table th {
+ font-size: 14px;
+}
+
+.api-page p {
+ margin-top: 0;
+}
+
+tr:target {
+ background: yellow;
+ -webkit-animation: highlight 2s ease 0.5s 1 normal forwards;
+ animation: highlight 2s ease 0.5s 1 normal forwards;
+}
+
+@-webkit-keyframes highlight {
+ 0% { background: yellow; }
+ 100% { background: white; }
+}
+@keyframes highlight {
+ 0% { background: yellow; }
+ 100% { background: white; }
+}
+
+.api-page h2[id]:before,
+.api-page tr[id] td:first-child:before {
+ content: 'Permalink';
+ display: inline-block;
+ margin: 0px 5px 0px -35px;
+ width: 30px;
+ height: 0;
+ overflow: hidden;
+ padding-top: 20px;
+ line-height: 20px;
+ vertical-align: baseline;
+ background: url(../images/sprite.png) -0px -0px no-repeat;
+ opacity: 0.2;
+ border-radius: 50%;
+ cursor: pointer;
+ position: absolute;
+ z-index: 1;
+}
+
+.api-page h2[id]:before {
+ margin-left: -32px;
+ margin-top: 14px;
+}
+
+.api-page tr[id] td:first-child:before {
+ opacity: 0;
+}
+
+.api-page tr[id]:hover td:first-child:before {
+ opacity: 1;
+}
+
+.api-page h2[id]:hover:before { opacity: 1; }
+
+@media (-webkit-min-device-pixel-ratio: 1.25),(min-resolution: 120dpi) {
+ .api-page h2[id]:before,
+ .api-page tr[id] td:first-child:before {
+ background-image: url(../images/sprite.svg);
+ }
+}
+
+@media screen and (max-width: 767px) {
+ #toc .colborder {
+ padding: 0;
+ }
+
+ .colborder {
+ margin: 0;
+ border: 0;
+ }
+
+ #toc .toc-col {
+ width: 50%;
+ float: none;
+ position: static;
+ display: inline-block;
+ margin: 0;
+ border: 0;
+ padding-right: .5em;
+ margin-right: -.25em;
+ vertical-align: top;
+ box-sizing: border-box;
+ }
+
+ .toc-col.last-col {
+ clear: both;
+ }
+
+ th,
+ td {
+ border: 0;
+ }
+
+ tr {
+ border-bottom: 1px solid #eee;
+ }
+
+ table.plugins tbody tr {
+ display: block;
+ padding-bottom: 1em;
+ }
+
+ table.plugins tbody tr td {
+ white-space: normal;
+ display: inline-block;
+ padding-bottom: 0;
+ }
+
+ table.plugins tr:first-child {
+ padding-bottom: 0;
+ }
+
+ table.plugins tr:first-child th {
+ display: block;
+ }
+
+ table.plugins tr:first-child th ~ th {
+ display: none;
+ }
+
+ table.plugins td:first-child {
+ display: block;
+ white-space: normal;
+ }
+
+ .api-page table tbody tr {
+ display: block;
+ }
+
+ .api-page table tbody tr th,
+ .api-page table tbody tr td {
+ display: inline-block;
+ background-color: transparent;
+ width: auto;
+ }
+
+ .api-page table tr:first-child th ~ th {
+ display: none;
+ }
+
+ .api-page table tbody tr th:nth-child(2),
+ .api-page table tbody tr th:nth-child(3) {
+ display: inline-block;
+ }
+
+ .api-page table tr th:last-child {
+ display: none !important;
+ }
+
+ .api-page table tbody tr td:last-child {
+ display: block;
+ border-top: thin dashed #ddd;
+ padding: 1em;
+ }
+
+ /*.api-page table tbody tr td:last-child:before {
+ content: 'Description';
+ display: block;
+ text-transform: uppercase;
+ font-size: 90%;
+ margin-bottom: .75em;
+ color: #666;
+ }*/
+
+ td code {
+ word-break: break-word;
+ }
+}
+
+@media screen and (max-width: 56em) {
+ .container {
+ padding: 0 2em 1.5em;
+ }
+
+ .footer, .social-buttons {
+ text-align: center;
+ }
+
+ .footer {
+ margin-top: 2em;
+ }
+
+ .ext-links {
+ position: static;
+ margin: 0 auto 2em;
+ text-align: center;
+ clear: both;
+ }
+
+ .ext-link {
+ display: inline-block;
+ vertical-align: middle;
+ margin: .25em;
+ }
+
+ .features {
+ -webkit-column-count: 2;
+ -moz-column-count: 2;
+ column-count: 2;
+ }
+}
+
+@media screen and (max-width: 500px) {
+ .nav {
+ font-size: 1.25em;
+ padding-bottom: 1em;
+ line-height: 1;
+ }
+
+ h1 {
+ margin: 1em 0;
+ }
+
+ h3.tagline {
+ font-size: 1.05em;
+ margin: 0 1em;
+ }
+
+ .container {
+ padding: 0 1.5em 1.5em;
+ }
+
+ .logo {
+ margin: 0.6em;
+ }
+
+ .usedby-title {
+ padding-top: 1em;
+ padding-bottom: 0.5em;
+ font-size: 1.8em;
+ }
+
+ .usedby {
+ padding-left: 0;
+ padding-right: 0;
+ padding-bottom: 0;
+ }
+
+ .features {
+ -webkit-column-count: 1;
+ -moz-column-count: 1;
+ column-count: 1;
+ }
+
+ .example-img {
+ float: none;
+ display: block;
+ width: auto;
+ margin: 0 0 -.25em;
+ border: 0;
+ }
+
+ .post-date {
+ float: none;
+ width: auto;
+ margin: 0 0 .333em;
+ }
+
+ .api-page h2[id] { text-indent: 24px; }
+ .api-page h2[id]:before { margin-left: -28px; }
+}
+
+.width250 {
+ width: 250px;
+}
+.width200 {
+ width: 200px;
+}
+.width300 {
+ width: 300px;
+}
+.width100 {
+ width: 100px;
+}
+.width140 {
+ width: 140px;
+}
+.minwidth {
+ width: 1px;
+}
+
+.download-page table td a {
+ white-space: nowrap;
+}
+
+.tutorials-back {
+ margin-bottom: -3em;
+}
+
+.post-page h2 {
+ margin-top: 0;
+}
+
+.post-meta {
+ color: #888;
+ margin-top: -1em;
+}
+
+iframe[src*='youtube.com'] {
+ max-width: 100% !important;
+}
+
+#disqus_thread {
+ margin-top: 3em;
+}
+
+.no-break {
+ display: inline-block;
+ width: 100%;
+}
+
+.announcement {
+ background: #eee;
+ padding: 5px 10px;
+ border-radius: 10px;
+}
diff --git a/node_modules/leaflet-draw/docs/css/normalize.css b/node_modules/leaflet-draw/docs/css/normalize.css
new file mode 100644
index 00000000..f4b0e0a6
--- /dev/null
+++ b/node_modules/leaflet-draw/docs/css/normalize.css
@@ -0,0 +1,426 @@
+/*! normalize.css v3.0.1 | MIT License | git.io/normalize */
+
+/**
+ * 1. Set default font family to sans-serif.
+ * 2. Prevent iOS text size adjust after orientation change, without disabling
+ * user zoom.
+ */
+
+html {
+ font-family: sans-serif; /* 1 */
+ -ms-text-size-adjust: 100%; /* 2 */
+ -webkit-text-size-adjust: 100%; /* 2 */
+}
+
+/**
+ * Remove default margin.
+ */
+
+body {
+ margin: 0;
+}
+
+/* HTML5 display definitions
+ ========================================================================== */
+
+/**
+ * Correct `block` display not defined for any HTML5 element in IE 8/9.
+ * Correct `block` display not defined for `details` or `summary` in IE 10/11 and Firefox.
+ * Correct `block` display not defined for `main` in IE 11.
+ */
+
+article,
+aside,
+details,
+figcaption,
+figure,
+footer,
+header,
+hgroup,
+main,
+nav,
+section,
+summary {
+ display: block;
+}
+
+/**
+ * 1. Correct `inline-block` display not defined in IE 8/9.
+ * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.
+ */
+
+audio,
+canvas,
+progress,
+video {
+ display: inline-block; /* 1 */
+ vertical-align: baseline; /* 2 */
+}
+
+/**
+ * Prevent modern browsers from displaying `audio` without controls.
+ * Remove excess height in iOS 5 devices.
+ */
+
+audio:not([controls]) {
+ display: none;
+ height: 0;
+}
+
+/**
+ * Address `[hidden]` styling not present in IE 8/9/10.
+ * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22.
+ */
+
+[hidden],
+template {
+ display: none;
+}
+
+/* Links
+ ========================================================================== */
+
+/**
+ * Remove the gray background color from active links in IE 10.
+ */
+
+a {
+ background: transparent;
+}
+
+/**
+ * Improve readability when focused and also mouse hovered in all browsers.
+ */
+
+a:active,
+a:hover {
+ outline: 0;
+}
+
+/* Text-level semantics
+ ========================================================================== */
+
+/**
+ * Address styling not present in IE 8/9/10/11, Safari, and Chrome.
+ */
+
+abbr[title] {
+ border-bottom: 1px dotted;
+ text-decoration: none;
+}
+
+/**
+ * Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
+ */
+
+b,
+strong {
+ font-weight: bold;
+}
+
+/**
+ * Address styling not present in Safari and Chrome.
+ */
+
+dfn {
+ font-style: italic;
+}
+
+/**
+ * Address variable `h1` font-size and margin within `section` and `article`
+ * contexts in Firefox 4+, Safari, and Chrome.
+ */
+
+h1 {
+ font-size: 2em;
+ margin: 0.67em 0;
+}
+
+/**
+ * Address styling not present in IE 8/9.
+ */
+
+mark {
+ background: #ff0;
+ color: #000;
+}
+
+/**
+ * Address inconsistent and variable font size in all browsers.
+ */
+
+small {
+ font-size: 80%;
+}
+
+/**
+ * Prevent `sub` and `sup` affecting `line-height` in all browsers.
+ */
+
+sub,
+sup {
+ font-size: 75%;
+ line-height: 0;
+ position: relative;
+ vertical-align: baseline;
+}
+
+sup {
+ top: -0.5em;
+}
+
+sub {
+ bottom: -0.25em;
+}
+
+/* Embedded content
+ ========================================================================== */
+
+/**
+ * Remove border when inside `a` element in IE 8/9/10.
+ */
+
+img {
+ border: 0;
+}
+
+/**
+ * Correct overflow not hidden in IE 9/10/11.
+ */
+
+svg:not(:root) {
+ overflow: hidden;
+}
+
+/* Grouping content
+ ========================================================================== */
+
+/**
+ * Address margin not present in IE 8/9 and Safari.
+ */
+
+figure {
+ margin: 1em 40px;
+}
+
+/**
+ * Address differences between Firefox and other browsers.
+ */
+
+hr {
+ -moz-box-sizing: content-box;
+ box-sizing: content-box;
+ height: 0;
+}
+
+/**
+ * Contain overflow in all browsers.
+ */
+
+pre {
+ overflow: auto;
+}
+
+/**
+ * Address odd `em`-unit font size rendering in all browsers.
+ */
+
+code,
+kbd,
+pre,
+samp {
+ font-family: monospace, monospace;
+ font-size: 1em;
+}
+
+/* Forms
+ ========================================================================== */
+
+/**
+ * Known limitation: by default, Chrome and Safari on OS X allow very limited
+ * styling of `select`, unless a `border` property is set.
+ */
+
+/**
+ * 1. Correct color not being inherited.
+ * Known issue: affects color of disabled elements.
+ * 2. Correct font properties not being inherited.
+ * 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
+ */
+
+button,
+input,
+optgroup,
+select,
+textarea {
+ color: inherit; /* 1 */
+ font: inherit; /* 2 */
+ margin: 0; /* 3 */
+}
+
+/**
+ * Address `overflow` set to `hidden` in IE 8/9/10/11.
+ */
+
+button {
+ overflow: visible;
+}
+
+/**
+ * Address inconsistent `text-transform` inheritance for `button` and `select`.
+ * All other form control elements do not inherit `text-transform` values.
+ * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
+ * Correct `select` style inheritance in Firefox.
+ */
+
+button,
+select {
+ text-transform: none;
+}
+
+/**
+ * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
+ * and `video` controls.
+ * 2. Correct inability to style clickable `input` types in iOS.
+ * 3. Improve usability and consistency of cursor style between image-type
+ * `input` and others.
+ */
+
+button,
+html input[type="button"], /* 1 */
+input[type="reset"],
+input[type="submit"] {
+ -webkit-appearance: button; /* 2 */
+ cursor: pointer; /* 3 */
+}
+
+/**
+ * Re-set default cursor for disabled elements.
+ */
+
+button[disabled],
+html input[disabled] {
+ cursor: default;
+}
+
+/**
+ * Remove inner padding and border in Firefox 4+.
+ */
+
+button::-moz-focus-inner,
+input::-moz-focus-inner {
+ border: 0;
+ padding: 0;
+}
+
+/**
+ * Address Firefox 4+ setting `line-height` on `input` using `!important` in
+ * the UA stylesheet.
+ */
+
+input {
+ line-height: normal;
+}
+
+/**
+ * It's recommended that you don't attempt to style these elements.
+ * Firefox's implementation doesn't respect box-sizing, padding, or width.
+ *
+ * 1. Address box sizing set to `content-box` in IE 8/9/10.
+ * 2. Remove excess padding in IE 8/9/10.
+ */
+
+input[type="checkbox"],
+input[type="radio"] {
+ box-sizing: border-box; /* 1 */
+ padding: 0; /* 2 */
+}
+
+/**
+ * Fix the cursor style for Chrome's increment/decrement buttons. For certain
+ * `font-size` values of the `input`, it causes the cursor style of the
+ * decrement button to change from `default` to `text`.
+ */
+
+input[type="number"]::-webkit-inner-spin-button,
+input[type="number"]::-webkit-outer-spin-button {
+ height: auto;
+}
+
+/**
+ * 1. Address `appearance` set to `searchfield` in Safari and Chrome.
+ * 2. Address `box-sizing` set to `border-box` in Safari and Chrome
+ * (include `-moz` to future-proof).
+ */
+
+input[type="search"] {
+ -webkit-appearance: textfield; /* 1 */
+ -moz-box-sizing: content-box;
+ -webkit-box-sizing: content-box; /* 2 */
+ box-sizing: content-box;
+}
+
+/**
+ * Remove inner padding and search cancel button in Safari and Chrome on OS X.
+ * Safari (but not Chrome) clips the cancel button when the search input has
+ * padding (and `textfield` appearance).
+ */
+
+input[type="search"]::-webkit-search-cancel-button,
+input[type="search"]::-webkit-search-decoration {
+ -webkit-appearance: none;
+}
+
+/**
+ * Define consistent border, margin, and padding.
+ */
+
+fieldset {
+ border: 1px solid #c0c0c0;
+ margin: 0 2px;
+ padding: 0.35em 0.625em 0.75em;
+}
+
+/**
+ * 1. Correct `color` not being inherited in IE 8/9/10/11.
+ * 2. Remove padding so people aren't caught out if they zero out fieldsets.
+ */
+
+legend {
+ border: 0; /* 1 */
+ padding: 0; /* 2 */
+}
+
+/**
+ * Remove default vertical scrollbar in IE 8/9/10/11.
+ */
+
+textarea {
+ overflow: auto;
+}
+
+/**
+ * Don't inherit the `font-weight` (applied by a rule above).
+ * NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
+ */
+
+optgroup {
+ font-weight: bold;
+}
+
+/* Tables
+ ========================================================================== */
+
+/**
+ * Remove most spacing between table cells.
+ */
+
+table {
+ border-collapse: collapse;
+ border-spacing: 0;
+}
+
+td,
+th {
+ padding: 0;
+}
diff --git a/node_modules/leaflet-draw/docs/examples-0.7.x/basic.html b/node_modules/leaflet-draw/docs/examples-0.7.x/basic.html
new file mode 100644
index 00000000..10b3d896
--- /dev/null
+++ b/node_modules/leaflet-draw/docs/examples-0.7.x/basic.html
@@ -0,0 +1,108 @@
+
+
+
+ Leaflet.draw drawing and editing tools
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Rectangle -> Blue
+
+
+
diff --git a/node_modules/leaflet-draw/docs/examples-0.7.x/edithandlers.html b/node_modules/leaflet-draw/docs/examples-0.7.x/edithandlers.html
new file mode 100644
index 00000000..4d6326ca
--- /dev/null
+++ b/node_modules/leaflet-draw/docs/examples-0.7.x/edithandlers.html
@@ -0,0 +1,79 @@
+
+
+
+ Leaflet.draw vector editing handlers
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/node_modules/leaflet-draw/docs/examples-0.7.x/full.html b/node_modules/leaflet-draw/docs/examples-0.7.x/full.html
new file mode 100644
index 00000000..f8f2b832
--- /dev/null
+++ b/node_modules/leaflet-draw/docs/examples-0.7.x/full.html
@@ -0,0 +1,85 @@
+
+
+
+ Leaflet.draw vector editing handlers
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/node_modules/leaflet-draw/docs/examples-0.7.x/libs/Leaflet.draw.drag-src.js b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/Leaflet.draw.drag-src.js
new file mode 100644
index 00000000..c7468241
--- /dev/null
+++ b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/Leaflet.draw.drag-src.js
@@ -0,0 +1,894 @@
+/**
+ * Matrix transform path for SVG/VML
+ * TODO: adapt to Leaflet 0.8 upon release
+ */
+
+"use strict";
+
+if (L.Browser.svg) { // SVG transformation
+
+ L.Path.include({
+
+ /**
+ * Reset transform matrix
+ */
+ _resetTransform: function() {
+ this._container.setAttributeNS(null, 'transform', '');
+ },
+
+ /**
+ * Applies matrix transformation to SVG
+ * @param {Array.} matrix
+ */
+ _applyTransform: function(matrix) {
+ this._container.setAttributeNS(null, "transform",
+ 'matrix(' + matrix.join(' ') + ')');
+ }
+
+ });
+
+} else { // VML transform routines
+
+ L.Path.include({
+
+ /**
+ * Reset transform matrix
+ */
+ _resetTransform: function() {
+ if (this._skew) {
+ // super important! workaround for a 'jumping' glitch:
+ // disable transform before removing it
+ this._skew.on = false;
+ this._container.removeChild(this._skew);
+ this._skew = null;
+ }
+ },
+
+ /**
+ * Applies matrix transformation to VML
+ * @param {Array.} matrix
+ */
+ _applyTransform: function(matrix) {
+ var skew = this._skew;
+
+ if (!skew) {
+ skew = this._createElement('skew');
+ this._container.appendChild(skew);
+ skew.style.behavior = 'url(#default#VML)';
+ this._skew = skew;
+ }
+
+ // handle skew/translate separately, cause it's broken
+ var mt = matrix[0].toFixed(8) + " " + matrix[1].toFixed(8) + " " +
+ matrix[2].toFixed(8) + " " + matrix[3].toFixed(8) + " 0 0";
+ var offset = Math.floor(matrix[4]).toFixed() + ", " +
+ Math.floor(matrix[5]).toFixed() + "";
+
+ var s = this._container.style;
+ var l = parseFloat(s.left);
+ var t = parseFloat(s.top);
+ var w = parseFloat(s.width);
+ var h = parseFloat(s.height);
+
+ if (isNaN(l)) l = 0;
+ if (isNaN(t)) t = 0;
+ if (isNaN(w) || !w) w = 1;
+ if (isNaN(h) || !h) h = 1;
+
+ var origin = (-l / w - 0.5).toFixed(8) + " " + (-t / h - 0.5).toFixed(8);
+
+ skew.on = "f";
+ skew.matrix = mt;
+ skew.origin = origin;
+ skew.offset = offset;
+ skew.on = true;
+ }
+
+ });
+}
+
+// Renderer-independent
+L.Path.include({
+
+ /**
+ * Check if the feature was dragged, that'll supress the click event
+ * on mouseup. That fixes popups for example
+ *
+ * @param {MouseEvent} e
+ */
+ _onMouseClick: function(e) {
+ if ((this.dragging && this.dragging.moved()) ||
+ (this._map.dragging && this._map.dragging.moved())) {
+ return;
+ }
+
+ this._fireMouseEvent(e);
+ }
+});
+/**
+ * Leaflet vector features drag functionality
+ * @preserve
+ */
+
+"use strict";
+
+/**
+ * Drag handler
+ * @class L.Path.Drag
+ * @extends {L.Handler}
+ */
+L.Handler.PathDrag = L.Handler.extend( /** @lends L.Path.Drag.prototype */ {
+
+ /**
+ * @param {L.Path} path
+ * @constructor
+ */
+ initialize: function(path) {
+
+ /**
+ * @type {L.Path}
+ */
+ this._path = path;
+
+ /**
+ * @type {Array.}
+ */
+ this._matrix = null;
+
+ /**
+ * @type {L.Point}
+ */
+ this._startPoint = null;
+
+ /**
+ * @type {L.Point}
+ */
+ this._dragStartPoint = null;
+
+ },
+
+ /**
+ * Enable dragging
+ */
+ addHooks: function() {
+ this._path.on('mousedown', this._onDragStart, this);
+ L.DomUtil.addClass(this._path._container, 'leaflet-path-draggable');
+ },
+
+ /**
+ * Disable dragging
+ */
+ removeHooks: function() {
+ this._path.off('mousedown', this._onDragStart, this);
+ L.DomUtil.removeClass(this._path._container, 'leaflet-path-draggable');
+ },
+
+ /**
+ * @return {Boolean}
+ */
+ moved: function() {
+ return this._path._dragMoved;
+ },
+
+ /**
+ * Start drag
+ * @param {L.MouseEvent} evt
+ */
+ _onDragStart: function(evt) {
+ this._startPoint = evt.containerPoint.clone();
+ this._dragStartPoint = evt.containerPoint.clone();
+ this._matrix = [1, 0, 0, 1, 0, 0];
+
+ this._path._map
+ .on('mousemove', this._onDrag, this)
+ .on('mouseup', this._onDragEnd, this)
+ this._path._dragMoved = false;
+ },
+
+ /**
+ * Dragging
+ * @param {L.MouseEvent} evt
+ */
+ _onDrag: function(evt) {
+ var x = evt.containerPoint.x;
+ var y = evt.containerPoint.y;
+
+ var dx = x - this._startPoint.x;
+ var dy = y - this._startPoint.y;
+
+ if (!this._path._dragMoved && (dx || dy)) {
+ this._path._dragMoved = true;
+ this._path.fire('dragstart');
+ }
+
+ this._matrix[4] += dx;
+ this._matrix[5] += dy;
+
+ this._startPoint.x = x;
+ this._startPoint.y = y;
+
+ this._path._applyTransform(this._matrix);
+ this._path.fire('drag');
+ L.DomEvent.stop(evt.originalEvent);
+ },
+
+ /**
+ * Dragging stopped, apply
+ * @param {L.MouseEvent} evt
+ */
+ _onDragEnd: function(evt) {
+ L.DomEvent.stop(evt);
+ // undo container transform
+ this._path._resetTransform();
+ // apply matrix
+ this._transformPoints(this._matrix);
+
+ this._path._map
+ .off('mousemove', this._onDrag, this)
+ .off('mouseup', this._onDragEnd, this);
+
+ // consistency
+ this._path.fire('dragend', {
+ distance: Math.sqrt(
+ L.LineUtil._sqDist(this._dragStartPoint, evt.containerPoint)
+ )
+ });
+
+ this._matrix = null;
+ this._startPoint = null;
+ this._dragStartPoint = null;
+ },
+
+ /**
+ * Applies transformation, does it in one sweep for performance,
+ * so don't be surprised about the code repetition.
+ *
+ * [ x ] [ a b tx ] [ x ] [ a * x + b * y + tx ]
+ * [ y ] = [ c d ty ] [ y ] = [ c * x + d * y + ty ]
+ *
+ * @param {Array.} matrix
+ */
+ _transformPoints: function(matrix) {
+ var path = this._path;
+ var i, len, latlng;
+
+ var px = L.point(matrix[4], matrix[5]);
+
+ var crs = path._map.options.crs;
+ var transformation = crs.transformation;
+ var scale = crs.scale(path._map.getZoom());
+ var projection = crs.projection;
+
+ var diff = transformation.untransform(px, scale)
+ .subtract(transformation.untransform(L.point(0, 0), scale));
+
+ // console.time('transform');
+
+ // all shifts are in-place
+ if (path._point) { // L.Circle
+ path._latlng = projection.unproject(
+ projection.project(path._latlng)._add(diff));
+ path._point._add(px);
+ } else if (path._originalPoints) { // everything else
+ for (i = 0, len = path._originalPoints.length; i < len; i++) {
+ latlng = path._latlngs[i];
+ path._latlngs[i] = projection
+ .unproject(projection.project(latlng)._add(diff));
+ path._originalPoints[i]._add(px);
+ }
+ }
+
+ // holes operations
+ if (path._holes) {
+ for (i = 0, len = path._holes.length; i < len; i++) {
+ for (var j = 0, len2 = path._holes[i].length; j < len2; j++) {
+ latlng = path._holes[i][j];
+ path._holes[i][j] = projection
+ .unproject(projection.project(latlng)._add(diff));
+ path._holePoints[i][j]._add(px);
+ }
+ }
+ }
+
+ // console.timeEnd('transform');
+
+ path._updatePath();
+ }
+
+});
+
+L.Path.prototype.__initEvents = L.Path.prototype._initEvents;
+L.Path.prototype._initEvents = function() {
+ this.__initEvents();
+
+ if (this.options.draggable) {
+ if (this.dragging) {
+ this.dragging.enable();
+ } else {
+ this.dragging = new L.Handler.PathDrag(this);
+ this.dragging.enable();
+ }
+ } else if (this.dragging) {
+ this.dragging.disable();
+ }
+};
+(function() {
+
+ // listen and propagate dragstart on sub-layers
+ L.FeatureGroup.EVENTS += ' dragstart';
+
+ function wrapMethod(klasses, methodName, method) {
+ for (var i = 0, len = klasses.length; i < len; i++) {
+ var klass = klasses[i];
+ klass.prototype['_' + methodName] = klass.prototype[methodName];
+ klass.prototype[methodName] = method;
+ }
+ }
+
+ /**
+ * @param {L.Polygon|L.Polyline} layer
+ * @return {L.MultiPolygon|L.MultiPolyline}
+ */
+ function addLayer(layer) {
+ if (this.hasLayer(layer)) {
+ return this;
+ }
+ layer
+ .on('drag', this._onDrag, this)
+ .on('dragend', this._onDragEnd, this);
+ return this._addLayer.call(this, layer);
+ }
+
+ /**
+ * @param {L.Polygon|L.Polyline} layer
+ * @return {L.MultiPolygon|L.MultiPolyline}
+ */
+ function removeLayer(layer) {
+ if (!this.hasLayer(layer)) {
+ return this;
+ }
+ layer
+ .off('drag', this._onDrag, this)
+ .off('dragend', this._onDragEnd, this);
+ return this._removeLayer.call(this, layer);
+ }
+
+ // duck-type methods to listen to the drag events
+ wrapMethod([L.MultiPolygon, L.MultiPolyline], 'addLayer', addLayer);
+ wrapMethod([L.MultiPolygon, L.MultiPolyline], 'removeLayer', removeLayer);
+
+ var dragMethods = {
+ _onDrag: function(evt) {
+ var layer = evt.target;
+ this.eachLayer(function(otherLayer) {
+ if (otherLayer !== layer) {
+ otherLayer._applyTransform(layer.dragging._matrix);
+ }
+ });
+
+ this._propagateEvent(evt);
+ },
+
+ _onDragEnd: function(evt) {
+ var layer = evt.target;
+
+ this.eachLayer(function(otherLayer) {
+ if (otherLayer !== layer) {
+ otherLayer._resetTransform();
+ otherLayer.dragging._transformPoints(layer.dragging._matrix);
+ }
+ });
+
+ this._propagateEvent(evt);
+ }
+ };
+
+ L.MultiPolygon.include(dragMethods);
+ L.MultiPolyline.include(dragMethods);
+
+})();
+// TODO: dismiss that on Leaflet 0.8.x release
+
+L.Polygon.include( /** @lends L.Polygon.prototype */ {
+
+ /**
+ * @return {L.LatLng}
+ */
+ getCenter: function() {
+ var i, j, len, p1, p2, f, area, x, y,
+ points = this._parts[0];
+
+ // polygon centroid algorithm; only uses the first ring if there are multiple
+
+ area = x = y = 0;
+
+ for (i = 0, len = points.length, j = len - 1; i < len; j = i++) {
+ p1 = points[i];
+ p2 = points[j];
+
+ f = p1.y * p2.x - p2.y * p1.x;
+ x += (p1.x + p2.x) * f;
+ y += (p1.y + p2.y) * f;
+ area += f * 3;
+ }
+
+ return this._map.layerPointToLatLng([x / area, y / area]);
+ }
+
+});
+"use strict";
+
+/**
+ * Static flag for move markers
+ * @type {Boolean}
+ */
+L.EditToolbar.Edit.MOVE_MARKERS = false;
+
+L.EditToolbar.Edit.include( /** @lends L.EditToolbar.Edit.prototype */ {
+
+ /**
+ * @override
+ */
+ initialize: function(map, options) {
+ L.EditToolbar.Edit.MOVE_MARKERS = !!options.selectedPathOptions.moveMarkers;
+ this._initialize(map, options);
+ },
+
+ /**
+ * @param {L.Map} map
+ * @param {Object} options
+ */
+ _initialize: L.EditToolbar.Edit.prototype.initialize
+
+});
+/**
+ * Mainly central marker routines
+ */
+
+L.Edit.SimpleShape.include( /** @lends L.Edit.SimpleShape.prototype */ {
+
+ /**
+ * Put move marker into center
+ */
+ _updateMoveMarker: function() {
+ if (this._moveMarker) {
+ this._moveMarker.setLatLng(this._getShapeCenter());
+ }
+ },
+
+ /**
+ * Shape centroid
+ * @return {L.LatLng}
+ */
+ _getShapeCenter: function() {
+ return this._shape.getBounds().getCenter();
+ },
+
+ /**
+ * @override
+ */
+ _createMoveMarker: function() {
+ if (L.EditToolbar.Edit.MOVE_MARKERS) {
+ this._moveMarker = this._createMarker(this._getShapeCenter(),
+ this.options.moveIcon);
+ }
+ }
+
+});
+
+/**
+ * Override this if you don't want the central marker
+ * @type {Boolean}
+ */
+L.Edit.SimpleShape.mergeOptions({
+ moveMarker: false
+});
+/**
+ * Dragging routines for circle
+ */
+
+L.Edit.Circle.include( /** @lends L.Edit.Circle.prototype */ {
+
+ /**
+ * @override
+ */
+ addHooks: function() {
+ if (this._shape._map) {
+ this._map = this._shape._map;
+ if (!this._markerGroup) {
+ this._enableDragging();
+ this._initMarkers();
+ }
+ this._shape._map.addLayer(this._markerGroup);
+ }
+ },
+
+ /**
+ * @override
+ */
+ removeHooks: function() {
+ if (this._shape._map) {
+ for (var i = 0, l = this._resizeMarkers.length; i < l; i++) {
+ this._unbindMarker(this._resizeMarkers[i]);
+ }
+
+ this._disableDragging();
+ this._resizeMarkers = null;
+ this._map.removeLayer(this._markerGroup);
+ delete this._markerGroup;
+ }
+
+ this._map = null;
+ },
+
+ /**
+ * @override
+ */
+ _createMoveMarker: L.Edit.SimpleShape.prototype._createMoveMarker,
+
+ /**
+ * Change
+ * @param {L.LatLng} latlng
+ */
+ _resize: function(latlng) {
+ var center = this._shape.getLatLng();
+ var radius = center.distanceTo(latlng);
+
+ this._shape.setRadius(radius);
+
+ this._updateMoveMarker();
+ },
+
+ /**
+ * Adds drag start listeners
+ */
+ _enableDragging: function() {
+ if (!this._shape.dragging) {
+ this._shape.dragging = new L.Handler.PathDrag(this._shape);
+ }
+ this._shape.dragging.enable();
+ this._shape
+ .on('dragstart', this._onStartDragFeature, this)
+ .on('dragend', this._onStopDragFeature, this);
+ },
+
+ /**
+ * Removes drag start listeners
+ */
+ _disableDragging: function() {
+ this._shape.dragging.disable();
+ this._shape
+ .off('dragstart', this._onStartDragFeature, this)
+ .off('dragend', this._onStopDragFeature, this);
+ },
+
+ /**
+ * Start drag
+ * @param {L.MouseEvent} evt
+ */
+ _onStartDragFeature: function() {
+ this._shape._map.removeLayer(this._markerGroup);
+ this._shape.fire('editstart');
+ },
+
+ /**
+ * Dragging stopped, apply
+ * @param {L.MouseEvent} evt
+ */
+ _onStopDragFeature: function() {
+ var center = this._shape.getLatLng();
+
+ //this._moveMarker.setLatLng(center);
+ this._resizeMarkers[0].setLatLng(this._getResizeMarkerPoint(center));
+
+ // show resize marker
+ this._shape._map.addLayer(this._markerGroup);
+ this._updateMoveMarker();
+ this._fireEdit();
+ }
+});
+/**
+ * Dragging routines for poly handler
+ */
+
+L.Edit.Rectangle.include( /** @lends L.Edit.Rectangle.prototype */ {
+
+ /**
+ * @override
+ */
+ addHooks: function() {
+ if (this._shape._map) {
+ if (!this._markerGroup) {
+ this._enableDragging();
+ this._initMarkers();
+ }
+ this._shape._map.addLayer(this._markerGroup);
+ }
+ },
+
+ /**
+ * @override
+ */
+ removeHooks: function() {
+ if (this._shape._map) {
+ this._shape._map.removeLayer(this._markerGroup);
+ this._disableDragging();
+ delete this._markerGroup;
+ delete this._markers;
+ }
+ },
+
+ /**
+ * @override
+ */
+ _resize: function(latlng) {
+ // Update the shape based on the current position of
+ // this corner and the opposite point
+ this._shape.setBounds(L.latLngBounds(latlng, this._oppositeCorner));
+ this._updateMoveMarker();
+ },
+
+ /**
+ * @override
+ */
+ _onMarkerDragEnd: function(e) {
+ this._toggleCornerMarkers(1);
+ this._repositionCornerMarkers();
+
+ L.Edit.SimpleShape.prototype._onMarkerDragEnd.call(this, e);
+ },
+
+ /**
+ * Adds drag start listeners
+ */
+ _enableDragging: function() {
+ if (!this._shape.dragging) {
+ this._shape.dragging = new L.Handler.PathDrag(this._shape);
+ }
+ this._shape.dragging.enable();
+ this._shape
+ .on('dragstart', this._onStartDragFeature, this)
+ .on('dragend', this._onStopDragFeature, this);
+ },
+
+ /**
+ * Removes drag start listeners
+ */
+ _disableDragging: function() {
+ this._shape.dragging.disable();
+ this._shape
+ .off('dragstart', this._onStartDragFeature, this)
+ .off('dragend', this._onStopDragFeature, this);
+ },
+
+ /**
+ * Start drag
+ * @param {L.MouseEvent} evt
+ */
+ _onStartDragFeature: function() {
+ this._shape._map.removeLayer(this._markerGroup);
+ this._shape.fire('editstart');
+ },
+
+ /**
+ * Dragging stopped, apply
+ * @param {L.MouseEvent} evt
+ */
+ _onStopDragFeature: function() {
+ var polygon = this._shape;
+ for (var i = 0, len = polygon._latlngs.length; i < len; i++) {
+ // update marker
+ var marker = this._resizeMarkers[i];
+ marker.setLatLng(polygon._latlngs[i]);
+
+ // this one's needed to update the path
+ marker._origLatLng = polygon._latlngs[i];
+ if (marker._middleLeft) {
+ marker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));
+ }
+ if (marker._middleRight) {
+ marker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));
+ }
+ }
+ // this._moveMarker.setLatLng(polygon.getBounds().getCenter());
+
+ // show vertices
+ this._shape._map.addLayer(this._markerGroup);
+ this._updateMoveMarker();
+
+ this._repositionCornerMarkers();
+ this._fireEdit();
+ }
+});
+/**
+ * Dragging routines for poly handler
+ */
+
+L.Edit.PolyVerticesEdit.include( /** @lends L.Edit.PolyVerticesEdit.prototype */ {
+
+ // store methods to call them in overrides
+ __createMarker: L.Edit.PolyVerticesEdit.prototype._createMarker,
+ __removeMarker: L.Edit.PolyVerticesEdit.prototype._removeMarker,
+
+ /**
+ * @override
+ */
+ addHooks: function() {
+ if (this._poly._map) {
+ if (!this._markerGroup) {
+ this._enableDragging();
+ this._initMarkers();
+ // Create center marker
+ this._createMoveMarker();
+ }
+ this._poly._map.addLayer(this._markerGroup);
+ }
+ },
+
+ /**
+ * @override
+ */
+ _createMoveMarker: function() {
+ if (L.EditToolbar.Edit.MOVE_MARKERS && (this._poly instanceof L.Polygon)) {
+ this._moveMarker = new L.Marker(this._getShapeCenter(), {
+ icon: this.options.moveIcon
+ });
+ this._moveMarker.on('mousedown', this._delegateToShape, this);
+ this._markerGroup.addLayer(this._moveMarker);
+ }
+ },
+
+ /**
+ * Start dragging through the marker
+ * @param {L.MouseEvent} evt
+ */
+ _delegateToShape: function(evt) {
+ var poly = this._shape || this._poly;
+ var marker = evt.target;
+ poly.fire('mousedown', L.Util.extend(evt, {
+ containerPoint: L.DomUtil.getPosition(marker._icon)
+ .add(poly._map._getMapPanePos())
+ }));
+ },
+
+ /**
+ * Polygon centroid
+ * @return {L.LatLng}
+ */
+ _getShapeCenter: function() {
+ return this._poly.getCenter();
+ },
+
+ /**
+ * @override
+ */
+ removeHooks: function() {
+ if (this._poly._map) {
+ this._poly._map.removeLayer(this._markerGroup);
+ this._disableDragging();
+ delete this._markerGroup;
+ delete this._markers;
+ }
+ },
+
+ /**
+ * Adds drag start listeners
+ */
+ _enableDragging: function() {
+ if (!this._poly.dragging) {
+ this._poly.dragging = new L.Handler.PathDrag(this._poly);
+ }
+ this._poly.dragging.enable();
+ this._poly
+ .on('dragstart', this._onStartDragFeature, this)
+ .on('dragend', this._onStopDragFeature, this);
+ },
+
+ /**
+ * Removes drag start listeners
+ */
+ _disableDragging: function() {
+ this._poly.dragging.disable();
+ this._poly
+ .off('dragstart', this._onStartDragFeature, this)
+ .off('dragend', this._onStopDragFeature, this);
+ },
+
+ /**
+ * Start drag
+ * @param {L.MouseEvent} evt
+ */
+ _onStartDragFeature: function(evt) {
+ this._poly._map.removeLayer(this._markerGroup);
+ this._poly.fire('editstart');
+ },
+
+ /**
+ * Dragging stopped, apply
+ * @param {L.MouseEvent} evt
+ */
+ _onStopDragFeature: function(evt) {
+ // var polygon = this._poly;
+ for (var i = 0, len = this._latlngs.length; i < len; i++) {
+ // update marker
+ var marker = this._markers[i];
+ marker.setLatLng(this._latlngs[i]);
+
+ // this one's needed to update the path
+ marker._origLatLng = this._latlngs[i];
+ if (marker._middleLeft) {
+ marker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));
+ }
+ if (marker._middleRight) {
+ marker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));
+ }
+ }
+
+ // show vertices
+ this._poly._map.addLayer(this._markerGroup);
+ L.Edit.SimpleShape.prototype._updateMoveMarker.call(this);
+ this._fireEdit();
+ },
+
+ /**
+ * Copy from simple shape
+ */
+ _updateMoveMarker: L.Edit.SimpleShape.prototype._updateMoveMarker,
+
+ /**
+ * @override
+ */
+ _createMarker: function(latlng, index) {
+ var marker = this.__createMarker(latlng, index);
+ marker
+ .on('dragstart', this._hideMoveMarker, this)
+ .on('dragend', this._showUpdateMoveMarker, this);
+ return marker;
+ },
+
+ /**
+ * @override
+ */
+ _removeMarker: function(marker) {
+ this.__removeMarker(marker);
+ marker
+ .off('dragstart', this._hideMoveMarker, this)
+ .off('dragend', this._showUpdateMoveMarker, this);
+ },
+
+ /**
+ * Hide move marker while dragging a vertex
+ */
+ _hideMoveMarker: function() {
+ if (this._moveMarker) {
+ this._markerGroup.removeLayer(this._moveMarker);
+ }
+ },
+
+ /**
+ * Show and update move marker
+ */
+ _showUpdateMoveMarker: function() {
+ if (this._moveMarker) {
+ this._markerGroup.addLayer(this._moveMarker);
+ this._updateMoveMarker();
+ }
+ }
+
+});
+
+/**
+ * @type {L.DivIcon}
+ */
+L.Edit.PolyVerticesEdit.prototype.options.moveIcon = new L.DivIcon({
+ iconSize: new L.Point(8, 8),
+ className: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move'
+});
+
+/**
+ * Override this if you don't want the central marker
+ * @type {Boolean}
+ */
+L.Edit.PolyVerticesEdit.mergeOptions({
+ moveMarker: false
+});
diff --git a/node_modules/leaflet-draw/docs/examples-0.7.x/libs/images/layers-2x.png b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/images/layers-2x.png
new file mode 100644
index 00000000..a2cf7f9e
Binary files /dev/null and b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/images/layers-2x.png differ
diff --git a/node_modules/leaflet-draw/docs/examples-0.7.x/libs/images/layers.png b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/images/layers.png
new file mode 100644
index 00000000..bca0a0e4
Binary files /dev/null and b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/images/layers.png differ
diff --git a/node_modules/leaflet-draw/docs/examples-0.7.x/libs/images/marker-icon-2x.png b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/images/marker-icon-2x.png
new file mode 100644
index 00000000..0015b649
Binary files /dev/null and b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/images/marker-icon-2x.png differ
diff --git a/node_modules/leaflet-draw/docs/examples-0.7.x/libs/images/marker-icon.png b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/images/marker-icon.png
new file mode 100644
index 00000000..e2e9f757
Binary files /dev/null and b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/images/marker-icon.png differ
diff --git a/node_modules/leaflet-draw/docs/examples-0.7.x/libs/images/marker-icon@2x.png b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/images/marker-icon@2x.png
new file mode 100644
index 00000000..0015b649
Binary files /dev/null and b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/images/marker-icon@2x.png differ
diff --git a/node_modules/leaflet-draw/docs/examples-0.7.x/libs/images/marker-shadow.png b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/images/marker-shadow.png
new file mode 100644
index 00000000..d1e773c7
Binary files /dev/null and b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/images/marker-shadow.png differ
diff --git a/node_modules/leaflet-draw/docs/examples-0.7.x/libs/leaflet-src.js b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/leaflet-src.js
new file mode 100644
index 00000000..e40bfbfa
--- /dev/null
+++ b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/leaflet-src.js
@@ -0,0 +1,9169 @@
+/*
+ Leaflet, a JavaScript library for mobile-friendly interactive maps. http://leafletjs.com
+ (c) 2010-2013, Vladimir Agafonkin
+ (c) 2010-2011, CloudMade
+*/
+(function (window, document, undefined) {
+var oldL = window.L,
+ L = {};
+
+L.version = '0.7.2';
+
+// define Leaflet for Node module pattern loaders, including Browserify
+if (typeof module === 'object' && typeof module.exports === 'object') {
+ module.exports = L;
+
+// define Leaflet as an AMD module
+} else if (typeof define === 'function' && define.amd) {
+ define(L);
+}
+
+// define Leaflet as a global L variable, saving the original L to restore later if needed
+
+L.noConflict = function () {
+ window.L = oldL;
+ return this;
+};
+
+window.L = L;
+
+
+/*
+ * L.Util contains various utility functions used throughout Leaflet code.
+ */
+
+L.Util = {
+ extend: function (dest) { // (Object[, Object, ...]) ->
+ var sources = Array.prototype.slice.call(arguments, 1),
+ i, j, len, src;
+
+ for (j = 0, len = sources.length; j < len; j++) {
+ src = sources[j] || {};
+ for (i in src) {
+ if (src.hasOwnProperty(i)) {
+ dest[i] = src[i];
+ }
+ }
+ }
+ return dest;
+ },
+
+ bind: function (fn, obj) { // (Function, Object) -> Function
+ var args = arguments.length > 2 ? Array.prototype.slice.call(arguments, 2) : null;
+ return function () {
+ return fn.apply(obj, args || arguments);
+ };
+ },
+
+ stamp: (function () {
+ var lastId = 0,
+ key = '_leaflet_id';
+ return function (obj) {
+ obj[key] = obj[key] || ++lastId;
+ return obj[key];
+ };
+ }()),
+
+ invokeEach: function (obj, method, context) {
+ var i, args;
+
+ if (typeof obj === 'object') {
+ args = Array.prototype.slice.call(arguments, 3);
+
+ for (i in obj) {
+ method.apply(context, [i, obj[i]].concat(args));
+ }
+ return true;
+ }
+
+ return false;
+ },
+
+ limitExecByInterval: function (fn, time, context) {
+ var lock, execOnUnlock;
+
+ return function wrapperFn() {
+ var args = arguments;
+
+ if (lock) {
+ execOnUnlock = true;
+ return;
+ }
+
+ lock = true;
+
+ setTimeout(function () {
+ lock = false;
+
+ if (execOnUnlock) {
+ wrapperFn.apply(context, args);
+ execOnUnlock = false;
+ }
+ }, time);
+
+ fn.apply(context, args);
+ };
+ },
+
+ falseFn: function () {
+ return false;
+ },
+
+ formatNum: function (num, digits) {
+ var pow = Math.pow(10, digits || 5);
+ return Math.round(num * pow) / pow;
+ },
+
+ trim: function (str) {
+ return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
+ },
+
+ splitWords: function (str) {
+ return L.Util.trim(str).split(/\s+/);
+ },
+
+ setOptions: function (obj, options) {
+ obj.options = L.extend({}, obj.options, options);
+ return obj.options;
+ },
+
+ getParamString: function (obj, existingUrl, uppercase) {
+ var params = [];
+ for (var i in obj) {
+ params.push(encodeURIComponent(uppercase ? i.toUpperCase() : i) + '=' + encodeURIComponent(obj[i]));
+ }
+ return ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&');
+ },
+ template: function (str, data) {
+ return str.replace(/\{ *([\w_]+) *\}/g, function (str, key) {
+ var value = data[key];
+ if (value === undefined) {
+ throw new Error('No value provided for variable ' + str);
+ } else if (typeof value === 'function') {
+ value = value(data);
+ }
+ return value;
+ });
+ },
+
+ isArray: Array.isArray || function (obj) {
+ return (Object.prototype.toString.call(obj) === '[object Array]');
+ },
+
+ emptyImageUrl: 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='
+};
+
+(function () {
+
+ // inspired by http://paulirish.com/2011/requestanimationframe-for-smart-animating/
+
+ function getPrefixed(name) {
+ var i, fn,
+ prefixes = ['webkit', 'moz', 'o', 'ms'];
+
+ for (i = 0; i < prefixes.length && !fn; i++) {
+ fn = window[prefixes[i] + name];
+ }
+
+ return fn;
+ }
+
+ var lastTime = 0;
+
+ function timeoutDefer(fn) {
+ var time = +new Date(),
+ timeToCall = Math.max(0, 16 - (time - lastTime));
+
+ lastTime = time + timeToCall;
+ return window.setTimeout(fn, timeToCall);
+ }
+
+ var requestFn = window.requestAnimationFrame ||
+ getPrefixed('RequestAnimationFrame') || timeoutDefer;
+
+ var cancelFn = window.cancelAnimationFrame ||
+ getPrefixed('CancelAnimationFrame') ||
+ getPrefixed('CancelRequestAnimationFrame') ||
+ function (id) { window.clearTimeout(id); };
+
+
+ L.Util.requestAnimFrame = function (fn, context, immediate, element) {
+ fn = L.bind(fn, context);
+
+ if (immediate && requestFn === timeoutDefer) {
+ fn();
+ } else {
+ return requestFn.call(window, fn, element);
+ }
+ };
+
+ L.Util.cancelAnimFrame = function (id) {
+ if (id) {
+ cancelFn.call(window, id);
+ }
+ };
+
+}());
+
+// shortcuts for most used utility functions
+L.extend = L.Util.extend;
+L.bind = L.Util.bind;
+L.stamp = L.Util.stamp;
+L.setOptions = L.Util.setOptions;
+
+
+/*
+ * L.Class powers the OOP facilities of the library.
+ * Thanks to John Resig and Dean Edwards for inspiration!
+ */
+
+L.Class = function () {};
+
+L.Class.extend = function (props) {
+
+ // extended class with the new prototype
+ var NewClass = function () {
+
+ // call the constructor
+ if (this.initialize) {
+ this.initialize.apply(this, arguments);
+ }
+
+ // call all constructor hooks
+ if (this._initHooks) {
+ this.callInitHooks();
+ }
+ };
+
+ // instantiate class without calling constructor
+ var F = function () {};
+ F.prototype = this.prototype;
+
+ var proto = new F();
+ proto.constructor = NewClass;
+
+ NewClass.prototype = proto;
+
+ //inherit parent's statics
+ for (var i in this) {
+ if (this.hasOwnProperty(i) && i !== 'prototype') {
+ NewClass[i] = this[i];
+ }
+ }
+
+ // mix static properties into the class
+ if (props.statics) {
+ L.extend(NewClass, props.statics);
+ delete props.statics;
+ }
+
+ // mix includes into the prototype
+ if (props.includes) {
+ L.Util.extend.apply(null, [proto].concat(props.includes));
+ delete props.includes;
+ }
+
+ // merge options
+ if (props.options && proto.options) {
+ props.options = L.extend({}, proto.options, props.options);
+ }
+
+ // mix given properties into the prototype
+ L.extend(proto, props);
+
+ proto._initHooks = [];
+
+ var parent = this;
+ // jshint camelcase: false
+ NewClass.__super__ = parent.prototype;
+
+ // add method for calling all hooks
+ proto.callInitHooks = function () {
+
+ if (this._initHooksCalled) { return; }
+
+ if (parent.prototype.callInitHooks) {
+ parent.prototype.callInitHooks.call(this);
+ }
+
+ this._initHooksCalled = true;
+
+ for (var i = 0, len = proto._initHooks.length; i < len; i++) {
+ proto._initHooks[i].call(this);
+ }
+ };
+
+ return NewClass;
+};
+
+
+// method for adding properties to prototype
+L.Class.include = function (props) {
+ L.extend(this.prototype, props);
+};
+
+// merge new default options to the Class
+L.Class.mergeOptions = function (options) {
+ L.extend(this.prototype.options, options);
+};
+
+// add a constructor hook
+L.Class.addInitHook = function (fn) { // (Function) || (String, args...)
+ var args = Array.prototype.slice.call(arguments, 1);
+
+ var init = typeof fn === 'function' ? fn : function () {
+ this[fn].apply(this, args);
+ };
+
+ this.prototype._initHooks = this.prototype._initHooks || [];
+ this.prototype._initHooks.push(init);
+};
+
+
+/*
+ * L.Mixin.Events is used to add custom events functionality to Leaflet classes.
+ */
+
+var eventsKey = '_leaflet_events';
+
+L.Mixin = {};
+
+L.Mixin.Events = {
+
+ addEventListener: function (types, fn, context) { // (String, Function[, Object]) or (Object[, Object])
+
+ // types can be a map of types/handlers
+ if (L.Util.invokeEach(types, this.addEventListener, this, fn, context)) { return this; }
+
+ var events = this[eventsKey] = this[eventsKey] || {},
+ contextId = context && context !== this && L.stamp(context),
+ i, len, event, type, indexKey, indexLenKey, typeIndex;
+
+ // types can be a string of space-separated words
+ types = L.Util.splitWords(types);
+
+ for (i = 0, len = types.length; i < len; i++) {
+ event = {
+ action: fn,
+ context: context || this
+ };
+ type = types[i];
+
+ if (contextId) {
+ // store listeners of a particular context in a separate hash (if it has an id)
+ // gives a major performance boost when removing thousands of map layers
+
+ indexKey = type + '_idx';
+ indexLenKey = indexKey + '_len';
+
+ typeIndex = events[indexKey] = events[indexKey] || {};
+
+ if (!typeIndex[contextId]) {
+ typeIndex[contextId] = [];
+
+ // keep track of the number of keys in the index to quickly check if it's empty
+ events[indexLenKey] = (events[indexLenKey] || 0) + 1;
+ }
+
+ typeIndex[contextId].push(event);
+
+
+ } else {
+ events[type] = events[type] || [];
+ events[type].push(event);
+ }
+ }
+
+ return this;
+ },
+
+ hasEventListeners: function (type) { // (String) -> Boolean
+ var events = this[eventsKey];
+ return !!events && ((type in events && events[type].length > 0) ||
+ (type + '_idx' in events && events[type + '_idx_len'] > 0));
+ },
+
+ removeEventListener: function (types, fn, context) { // ([String, Function, Object]) or (Object[, Object])
+
+ if (!this[eventsKey]) {
+ return this;
+ }
+
+ if (!types) {
+ return this.clearAllEventListeners();
+ }
+
+ if (L.Util.invokeEach(types, this.removeEventListener, this, fn, context)) { return this; }
+
+ var events = this[eventsKey],
+ contextId = context && context !== this && L.stamp(context),
+ i, len, type, listeners, j, indexKey, indexLenKey, typeIndex, removed;
+
+ types = L.Util.splitWords(types);
+
+ for (i = 0, len = types.length; i < len; i++) {
+ type = types[i];
+ indexKey = type + '_idx';
+ indexLenKey = indexKey + '_len';
+
+ typeIndex = events[indexKey];
+
+ if (!fn) {
+ // clear all listeners for a type if function isn't specified
+ delete events[type];
+ delete events[indexKey];
+ delete events[indexLenKey];
+
+ } else {
+ listeners = contextId && typeIndex ? typeIndex[contextId] : events[type];
+
+ if (listeners) {
+ for (j = listeners.length - 1; j >= 0; j--) {
+ if ((listeners[j].action === fn) && (!context || (listeners[j].context === context))) {
+ removed = listeners.splice(j, 1);
+ // set the old action to a no-op, because it is possible
+ // that the listener is being iterated over as part of a dispatch
+ removed[0].action = L.Util.falseFn;
+ }
+ }
+
+ if (context && typeIndex && (listeners.length === 0)) {
+ delete typeIndex[contextId];
+ events[indexLenKey]--;
+ }
+ }
+ }
+ }
+
+ return this;
+ },
+
+ clearAllEventListeners: function () {
+ delete this[eventsKey];
+ return this;
+ },
+
+ fireEvent: function (type, data) { // (String[, Object])
+ if (!this.hasEventListeners(type)) {
+ return this;
+ }
+
+ var event = L.Util.extend({}, data, { type: type, target: this });
+
+ var events = this[eventsKey],
+ listeners, i, len, typeIndex, contextId;
+
+ if (events[type]) {
+ // make sure adding/removing listeners inside other listeners won't cause infinite loop
+ listeners = events[type].slice();
+
+ for (i = 0, len = listeners.length; i < len; i++) {
+ listeners[i].action.call(listeners[i].context, event);
+ }
+ }
+
+ // fire event for the context-indexed listeners as well
+ typeIndex = events[type + '_idx'];
+
+ for (contextId in typeIndex) {
+ listeners = typeIndex[contextId].slice();
+
+ if (listeners) {
+ for (i = 0, len = listeners.length; i < len; i++) {
+ listeners[i].action.call(listeners[i].context, event);
+ }
+ }
+ }
+
+ return this;
+ },
+
+ addOneTimeEventListener: function (types, fn, context) {
+
+ if (L.Util.invokeEach(types, this.addOneTimeEventListener, this, fn, context)) { return this; }
+
+ var handler = L.bind(function () {
+ this
+ .removeEventListener(types, fn, context)
+ .removeEventListener(types, handler, context);
+ }, this);
+
+ return this
+ .addEventListener(types, fn, context)
+ .addEventListener(types, handler, context);
+ }
+};
+
+L.Mixin.Events.on = L.Mixin.Events.addEventListener;
+L.Mixin.Events.off = L.Mixin.Events.removeEventListener;
+L.Mixin.Events.once = L.Mixin.Events.addOneTimeEventListener;
+L.Mixin.Events.fire = L.Mixin.Events.fireEvent;
+
+
+/*
+ * L.Browser handles different browser and feature detections for internal Leaflet use.
+ */
+
+(function () {
+
+ var ie = 'ActiveXObject' in window,
+ ielt9 = ie && !document.addEventListener,
+
+ // terrible browser detection to work around Safari / iOS / Android browser bugs
+ ua = navigator.userAgent.toLowerCase(),
+ webkit = ua.indexOf('webkit') !== -1,
+ chrome = ua.indexOf('chrome') !== -1,
+ phantomjs = ua.indexOf('phantom') !== -1,
+ android = ua.indexOf('android') !== -1,
+ android23 = ua.search('android [23]') !== -1,
+ gecko = ua.indexOf('gecko') !== -1,
+
+ mobile = typeof orientation !== undefined + '',
+ msPointer = window.navigator && window.navigator.msPointerEnabled &&
+ window.navigator.msMaxTouchPoints && !window.PointerEvent,
+ pointer = (window.PointerEvent && window.navigator.pointerEnabled && window.navigator.maxTouchPoints) ||
+ msPointer,
+ retina = ('devicePixelRatio' in window && window.devicePixelRatio > 1) ||
+ ('matchMedia' in window && window.matchMedia('(min-resolution:144dpi)') &&
+ window.matchMedia('(min-resolution:144dpi)').matches),
+
+ doc = document.documentElement,
+ ie3d = ie && ('transition' in doc.style),
+ webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()) && !android23,
+ gecko3d = 'MozPerspective' in doc.style,
+ opera3d = 'OTransition' in doc.style,
+ any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d || opera3d) && !phantomjs;
+
+
+ // PhantomJS has 'ontouchstart' in document.documentElement, but doesn't actually support touch.
+ // https://github.com/Leaflet/Leaflet/pull/1434#issuecomment-13843151
+
+ var touch = !window.L_NO_TOUCH && !phantomjs && (function () {
+
+ var startName = 'ontouchstart';
+
+ // IE10+ (We simulate these into touch* events in L.DomEvent and L.DomEvent.Pointer) or WebKit, etc.
+ if (pointer || (startName in doc)) {
+ return true;
+ }
+
+ // Firefox/Gecko
+ var div = document.createElement('div'),
+ supported = false;
+
+ if (!div.setAttribute) {
+ return false;
+ }
+ div.setAttribute(startName, 'return;');
+
+ if (typeof div[startName] === 'function') {
+ supported = true;
+ }
+
+ div.removeAttribute(startName);
+ div = null;
+
+ return supported;
+ }());
+
+
+ L.Browser = {
+ ie: ie,
+ ielt9: ielt9,
+ webkit: webkit,
+ gecko: gecko && !webkit && !window.opera && !ie,
+
+ android: android,
+ android23: android23,
+
+ chrome: chrome,
+
+ ie3d: ie3d,
+ webkit3d: webkit3d,
+ gecko3d: gecko3d,
+ opera3d: opera3d,
+ any3d: any3d,
+
+ mobile: mobile,
+ mobileWebkit: mobile && webkit,
+ mobileWebkit3d: mobile && webkit3d,
+ mobileOpera: mobile && window.opera,
+
+ touch: touch,
+ msPointer: msPointer,
+ pointer: pointer,
+
+ retina: retina
+ };
+
+}());
+
+
+/*
+ * L.Point represents a point with x and y coordinates.
+ */
+
+L.Point = function (/*Number*/ x, /*Number*/ y, /*Boolean*/ round) {
+ this.x = (round ? Math.round(x) : x);
+ this.y = (round ? Math.round(y) : y);
+};
+
+L.Point.prototype = {
+
+ clone: function () {
+ return new L.Point(this.x, this.y);
+ },
+
+ // non-destructive, returns a new point
+ add: function (point) {
+ return this.clone()._add(L.point(point));
+ },
+
+ // destructive, used directly for performance in situations where it's safe to modify existing point
+ _add: function (point) {
+ this.x += point.x;
+ this.y += point.y;
+ return this;
+ },
+
+ subtract: function (point) {
+ return this.clone()._subtract(L.point(point));
+ },
+
+ _subtract: function (point) {
+ this.x -= point.x;
+ this.y -= point.y;
+ return this;
+ },
+
+ divideBy: function (num) {
+ return this.clone()._divideBy(num);
+ },
+
+ _divideBy: function (num) {
+ this.x /= num;
+ this.y /= num;
+ return this;
+ },
+
+ multiplyBy: function (num) {
+ return this.clone()._multiplyBy(num);
+ },
+
+ _multiplyBy: function (num) {
+ this.x *= num;
+ this.y *= num;
+ return this;
+ },
+
+ round: function () {
+ return this.clone()._round();
+ },
+
+ _round: function () {
+ this.x = Math.round(this.x);
+ this.y = Math.round(this.y);
+ return this;
+ },
+
+ floor: function () {
+ return this.clone()._floor();
+ },
+
+ _floor: function () {
+ this.x = Math.floor(this.x);
+ this.y = Math.floor(this.y);
+ return this;
+ },
+
+ distanceTo: function (point) {
+ point = L.point(point);
+
+ var x = point.x - this.x,
+ y = point.y - this.y;
+
+ return Math.sqrt(x * x + y * y);
+ },
+
+ equals: function (point) {
+ point = L.point(point);
+
+ return point.x === this.x &&
+ point.y === this.y;
+ },
+
+ contains: function (point) {
+ point = L.point(point);
+
+ return Math.abs(point.x) <= Math.abs(this.x) &&
+ Math.abs(point.y) <= Math.abs(this.y);
+ },
+
+ toString: function () {
+ return 'Point(' +
+ L.Util.formatNum(this.x) + ', ' +
+ L.Util.formatNum(this.y) + ')';
+ }
+};
+
+L.point = function (x, y, round) {
+ if (x instanceof L.Point) {
+ return x;
+ }
+ if (L.Util.isArray(x)) {
+ return new L.Point(x[0], x[1]);
+ }
+ if (x === undefined || x === null) {
+ return x;
+ }
+ return new L.Point(x, y, round);
+};
+
+
+/*
+ * L.Bounds represents a rectangular area on the screen in pixel coordinates.
+ */
+
+L.Bounds = function (a, b) { //(Point, Point) or Point[]
+ if (!a) { return; }
+
+ var points = b ? [a, b] : a;
+
+ for (var i = 0, len = points.length; i < len; i++) {
+ this.extend(points[i]);
+ }
+};
+
+L.Bounds.prototype = {
+ // extend the bounds to contain the given point
+ extend: function (point) { // (Point)
+ point = L.point(point);
+
+ if (!this.min && !this.max) {
+ this.min = point.clone();
+ this.max = point.clone();
+ } else {
+ this.min.x = Math.min(point.x, this.min.x);
+ this.max.x = Math.max(point.x, this.max.x);
+ this.min.y = Math.min(point.y, this.min.y);
+ this.max.y = Math.max(point.y, this.max.y);
+ }
+ return this;
+ },
+
+ getCenter: function (round) { // (Boolean) -> Point
+ return new L.Point(
+ (this.min.x + this.max.x) / 2,
+ (this.min.y + this.max.y) / 2, round);
+ },
+
+ getBottomLeft: function () { // -> Point
+ return new L.Point(this.min.x, this.max.y);
+ },
+
+ getTopRight: function () { // -> Point
+ return new L.Point(this.max.x, this.min.y);
+ },
+
+ getSize: function () {
+ return this.max.subtract(this.min);
+ },
+
+ contains: function (obj) { // (Bounds) or (Point) -> Boolean
+ var min, max;
+
+ if (typeof obj[0] === 'number' || obj instanceof L.Point) {
+ obj = L.point(obj);
+ } else {
+ obj = L.bounds(obj);
+ }
+
+ if (obj instanceof L.Bounds) {
+ min = obj.min;
+ max = obj.max;
+ } else {
+ min = max = obj;
+ }
+
+ return (min.x >= this.min.x) &&
+ (max.x <= this.max.x) &&
+ (min.y >= this.min.y) &&
+ (max.y <= this.max.y);
+ },
+
+ intersects: function (bounds) { // (Bounds) -> Boolean
+ bounds = L.bounds(bounds);
+
+ var min = this.min,
+ max = this.max,
+ min2 = bounds.min,
+ max2 = bounds.max,
+ xIntersects = (max2.x >= min.x) && (min2.x <= max.x),
+ yIntersects = (max2.y >= min.y) && (min2.y <= max.y);
+
+ return xIntersects && yIntersects;
+ },
+
+ isValid: function () {
+ return !!(this.min && this.max);
+ }
+};
+
+L.bounds = function (a, b) { // (Bounds) or (Point, Point) or (Point[])
+ if (!a || a instanceof L.Bounds) {
+ return a;
+ }
+ return new L.Bounds(a, b);
+};
+
+
+/*
+ * L.Transformation is an utility class to perform simple point transformations through a 2d-matrix.
+ */
+
+L.Transformation = function (a, b, c, d) {
+ this._a = a;
+ this._b = b;
+ this._c = c;
+ this._d = d;
+};
+
+L.Transformation.prototype = {
+ transform: function (point, scale) { // (Point, Number) -> Point
+ return this._transform(point.clone(), scale);
+ },
+
+ // destructive transform (faster)
+ _transform: function (point, scale) {
+ scale = scale || 1;
+ point.x = scale * (this._a * point.x + this._b);
+ point.y = scale * (this._c * point.y + this._d);
+ return point;
+ },
+
+ untransform: function (point, scale) {
+ scale = scale || 1;
+ return new L.Point(
+ (point.x / scale - this._b) / this._a,
+ (point.y / scale - this._d) / this._c);
+ }
+};
+
+
+/*
+ * L.DomUtil contains various utility functions for working with DOM.
+ */
+
+L.DomUtil = {
+ get: function (id) {
+ return (typeof id === 'string' ? document.getElementById(id) : id);
+ },
+
+ getStyle: function (el, style) {
+
+ var value = el.style[style];
+
+ if (!value && el.currentStyle) {
+ value = el.currentStyle[style];
+ }
+
+ if ((!value || value === 'auto') && document.defaultView) {
+ var css = document.defaultView.getComputedStyle(el, null);
+ value = css ? css[style] : null;
+ }
+
+ return value === 'auto' ? null : value;
+ },
+
+ getViewportOffset: function (element) {
+
+ var top = 0,
+ left = 0,
+ el = element,
+ docBody = document.body,
+ docEl = document.documentElement,
+ pos;
+
+ do {
+ top += el.offsetTop || 0;
+ left += el.offsetLeft || 0;
+
+ //add borders
+ top += parseInt(L.DomUtil.getStyle(el, 'borderTopWidth'), 10) || 0;
+ left += parseInt(L.DomUtil.getStyle(el, 'borderLeftWidth'), 10) || 0;
+
+ pos = L.DomUtil.getStyle(el, 'position');
+
+ if (el.offsetParent === docBody && pos === 'absolute') { break; }
+
+ if (pos === 'fixed') {
+ top += docBody.scrollTop || docEl.scrollTop || 0;
+ left += docBody.scrollLeft || docEl.scrollLeft || 0;
+ break;
+ }
+
+ if (pos === 'relative' && !el.offsetLeft) {
+ var width = L.DomUtil.getStyle(el, 'width'),
+ maxWidth = L.DomUtil.getStyle(el, 'max-width'),
+ r = el.getBoundingClientRect();
+
+ if (width !== 'none' || maxWidth !== 'none') {
+ left += r.left + el.clientLeft;
+ }
+
+ //calculate full y offset since we're breaking out of the loop
+ top += r.top + (docBody.scrollTop || docEl.scrollTop || 0);
+
+ break;
+ }
+
+ el = el.offsetParent;
+
+ } while (el);
+
+ el = element;
+
+ do {
+ if (el === docBody) { break; }
+
+ top -= el.scrollTop || 0;
+ left -= el.scrollLeft || 0;
+
+ el = el.parentNode;
+ } while (el);
+
+ return new L.Point(left, top);
+ },
+
+ documentIsLtr: function () {
+ if (!L.DomUtil._docIsLtrCached) {
+ L.DomUtil._docIsLtrCached = true;
+ L.DomUtil._docIsLtr = L.DomUtil.getStyle(document.body, 'direction') === 'ltr';
+ }
+ return L.DomUtil._docIsLtr;
+ },
+
+ create: function (tagName, className, container) {
+
+ var el = document.createElement(tagName);
+ el.className = className;
+
+ if (container) {
+ container.appendChild(el);
+ }
+
+ return el;
+ },
+
+ hasClass: function (el, name) {
+ if (el.classList !== undefined) {
+ return el.classList.contains(name);
+ }
+ var className = L.DomUtil._getClass(el);
+ return className.length > 0 && new RegExp('(^|\\s)' + name + '(\\s|$)').test(className);
+ },
+
+ addClass: function (el, name) {
+ if (el.classList !== undefined) {
+ var classes = L.Util.splitWords(name);
+ for (var i = 0, len = classes.length; i < len; i++) {
+ el.classList.add(classes[i]);
+ }
+ } else if (!L.DomUtil.hasClass(el, name)) {
+ var className = L.DomUtil._getClass(el);
+ L.DomUtil._setClass(el, (className ? className + ' ' : '') + name);
+ }
+ },
+
+ removeClass: function (el, name) {
+ if (el.classList !== undefined) {
+ el.classList.remove(name);
+ } else {
+ L.DomUtil._setClass(el, L.Util.trim((' ' + L.DomUtil._getClass(el) + ' ').replace(' ' + name + ' ', ' ')));
+ }
+ },
+
+ _setClass: function (el, name) {
+ if (el.className.baseVal === undefined) {
+ el.className = name;
+ } else {
+ // in case of SVG element
+ el.className.baseVal = name;
+ }
+ },
+
+ _getClass: function (el) {
+ return el.className.baseVal === undefined ? el.className : el.className.baseVal;
+ },
+
+ setOpacity: function (el, value) {
+
+ if ('opacity' in el.style) {
+ el.style.opacity = value;
+
+ } else if ('filter' in el.style) {
+
+ var filter = false,
+ filterName = 'DXImageTransform.Microsoft.Alpha';
+
+ // filters collection throws an error if we try to retrieve a filter that doesn't exist
+ try {
+ filter = el.filters.item(filterName);
+ } catch (e) {
+ // don't set opacity to 1 if we haven't already set an opacity,
+ // it isn't needed and breaks transparent pngs.
+ if (value === 1) { return; }
+ }
+
+ value = Math.round(value * 100);
+
+ if (filter) {
+ filter.Enabled = (value !== 100);
+ filter.Opacity = value;
+ } else {
+ el.style.filter += ' progid:' + filterName + '(opacity=' + value + ')';
+ }
+ }
+ },
+
+ testProp: function (props) {
+
+ var style = document.documentElement.style;
+
+ for (var i = 0; i < props.length; i++) {
+ if (props[i] in style) {
+ return props[i];
+ }
+ }
+ return false;
+ },
+
+ getTranslateString: function (point) {
+ // on WebKit browsers (Chrome/Safari/iOS Safari/Android) using translate3d instead of translate
+ // makes animation smoother as it ensures HW accel is used. Firefox 13 doesn't care
+ // (same speed either way), Opera 12 doesn't support translate3d
+
+ var is3d = L.Browser.webkit3d,
+ open = 'translate' + (is3d ? '3d' : '') + '(',
+ close = (is3d ? ',0' : '') + ')';
+
+ return open + point.x + 'px,' + point.y + 'px' + close;
+ },
+
+ getScaleString: function (scale, origin) {
+
+ var preTranslateStr = L.DomUtil.getTranslateString(origin.add(origin.multiplyBy(-1 * scale))),
+ scaleStr = ' scale(' + scale + ') ';
+
+ return preTranslateStr + scaleStr;
+ },
+
+ setPosition: function (el, point, disable3D) { // (HTMLElement, Point[, Boolean])
+
+ // jshint camelcase: false
+ el._leaflet_pos = point;
+
+ if (!disable3D && L.Browser.any3d) {
+ el.style[L.DomUtil.TRANSFORM] = L.DomUtil.getTranslateString(point);
+ } else {
+ el.style.left = point.x + 'px';
+ el.style.top = point.y + 'px';
+ }
+ },
+
+ getPosition: function (el) {
+ // this method is only used for elements previously positioned using setPosition,
+ // so it's safe to cache the position for performance
+
+ // jshint camelcase: false
+ return el._leaflet_pos;
+ }
+};
+
+
+// prefix style property names
+
+L.DomUtil.TRANSFORM = L.DomUtil.testProp(
+ ['transform', 'WebkitTransform', 'OTransform', 'MozTransform', 'msTransform']);
+
+// webkitTransition comes first because some browser versions that drop vendor prefix don't do
+// the same for the transitionend event, in particular the Android 4.1 stock browser
+
+L.DomUtil.TRANSITION = L.DomUtil.testProp(
+ ['webkitTransition', 'transition', 'OTransition', 'MozTransition', 'msTransition']);
+
+L.DomUtil.TRANSITION_END =
+ L.DomUtil.TRANSITION === 'webkitTransition' || L.DomUtil.TRANSITION === 'OTransition' ?
+ L.DomUtil.TRANSITION + 'End' : 'transitionend';
+
+(function () {
+ if ('onselectstart' in document) {
+ L.extend(L.DomUtil, {
+ disableTextSelection: function () {
+ L.DomEvent.on(window, 'selectstart', L.DomEvent.preventDefault);
+ },
+
+ enableTextSelection: function () {
+ L.DomEvent.off(window, 'selectstart', L.DomEvent.preventDefault);
+ }
+ });
+ } else {
+ var userSelectProperty = L.DomUtil.testProp(
+ ['userSelect', 'WebkitUserSelect', 'OUserSelect', 'MozUserSelect', 'msUserSelect']);
+
+ L.extend(L.DomUtil, {
+ disableTextSelection: function () {
+ if (userSelectProperty) {
+ var style = document.documentElement.style;
+ this._userSelect = style[userSelectProperty];
+ style[userSelectProperty] = 'none';
+ }
+ },
+
+ enableTextSelection: function () {
+ if (userSelectProperty) {
+ document.documentElement.style[userSelectProperty] = this._userSelect;
+ delete this._userSelect;
+ }
+ }
+ });
+ }
+
+ L.extend(L.DomUtil, {
+ disableImageDrag: function () {
+ L.DomEvent.on(window, 'dragstart', L.DomEvent.preventDefault);
+ },
+
+ enableImageDrag: function () {
+ L.DomEvent.off(window, 'dragstart', L.DomEvent.preventDefault);
+ }
+ });
+})();
+
+
+/*
+ * L.LatLng represents a geographical point with latitude and longitude coordinates.
+ */
+
+L.LatLng = function (lat, lng, alt) { // (Number, Number, Number)
+ lat = parseFloat(lat);
+ lng = parseFloat(lng);
+
+ if (isNaN(lat) || isNaN(lng)) {
+ throw new Error('Invalid LatLng object: (' + lat + ', ' + lng + ')');
+ }
+
+ this.lat = lat;
+ this.lng = lng;
+
+ if (alt !== undefined) {
+ this.alt = parseFloat(alt);
+ }
+};
+
+L.extend(L.LatLng, {
+ DEG_TO_RAD: Math.PI / 180,
+ RAD_TO_DEG: 180 / Math.PI,
+ MAX_MARGIN: 1.0E-9 // max margin of error for the "equals" check
+});
+
+L.LatLng.prototype = {
+ equals: function (obj) { // (LatLng) -> Boolean
+ if (!obj) { return false; }
+
+ obj = L.latLng(obj);
+
+ var margin = Math.max(
+ Math.abs(this.lat - obj.lat),
+ Math.abs(this.lng - obj.lng));
+
+ return margin <= L.LatLng.MAX_MARGIN;
+ },
+
+ toString: function (precision) { // (Number) -> String
+ return 'LatLng(' +
+ L.Util.formatNum(this.lat, precision) + ', ' +
+ L.Util.formatNum(this.lng, precision) + ')';
+ },
+
+ // Haversine distance formula, see http://en.wikipedia.org/wiki/Haversine_formula
+ // TODO move to projection code, LatLng shouldn't know about Earth
+ distanceTo: function (other) { // (LatLng) -> Number
+ other = L.latLng(other);
+
+ var R = 6378137, // earth radius in meters
+ d2r = L.LatLng.DEG_TO_RAD,
+ dLat = (other.lat - this.lat) * d2r,
+ dLon = (other.lng - this.lng) * d2r,
+ lat1 = this.lat * d2r,
+ lat2 = other.lat * d2r,
+ sin1 = Math.sin(dLat / 2),
+ sin2 = Math.sin(dLon / 2);
+
+ var a = sin1 * sin1 + sin2 * sin2 * Math.cos(lat1) * Math.cos(lat2);
+
+ return R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
+ },
+
+ wrap: function (a, b) { // (Number, Number) -> LatLng
+ var lng = this.lng;
+
+ a = a || -180;
+ b = b || 180;
+
+ lng = (lng + b) % (b - a) + (lng < a || lng === b ? b : a);
+
+ return new L.LatLng(this.lat, lng);
+ }
+};
+
+L.latLng = function (a, b) { // (LatLng) or ([Number, Number]) or (Number, Number)
+ if (a instanceof L.LatLng) {
+ return a;
+ }
+ if (L.Util.isArray(a)) {
+ if (typeof a[0] === 'number' || typeof a[0] === 'string') {
+ return new L.LatLng(a[0], a[1], a[2]);
+ } else {
+ return null;
+ }
+ }
+ if (a === undefined || a === null) {
+ return a;
+ }
+ if (typeof a === 'object' && 'lat' in a) {
+ return new L.LatLng(a.lat, 'lng' in a ? a.lng : a.lon);
+ }
+ if (b === undefined) {
+ return null;
+ }
+ return new L.LatLng(a, b);
+};
+
+
+
+/*
+ * L.LatLngBounds represents a rectangular area on the map in geographical coordinates.
+ */
+
+L.LatLngBounds = function (southWest, northEast) { // (LatLng, LatLng) or (LatLng[])
+ if (!southWest) { return; }
+
+ var latlngs = northEast ? [southWest, northEast] : southWest;
+
+ for (var i = 0, len = latlngs.length; i < len; i++) {
+ this.extend(latlngs[i]);
+ }
+};
+
+L.LatLngBounds.prototype = {
+ // extend the bounds to contain the given point or bounds
+ extend: function (obj) { // (LatLng) or (LatLngBounds)
+ if (!obj) { return this; }
+
+ var latLng = L.latLng(obj);
+ if (latLng !== null) {
+ obj = latLng;
+ } else {
+ obj = L.latLngBounds(obj);
+ }
+
+ if (obj instanceof L.LatLng) {
+ if (!this._southWest && !this._northEast) {
+ this._southWest = new L.LatLng(obj.lat, obj.lng);
+ this._northEast = new L.LatLng(obj.lat, obj.lng);
+ } else {
+ this._southWest.lat = Math.min(obj.lat, this._southWest.lat);
+ this._southWest.lng = Math.min(obj.lng, this._southWest.lng);
+
+ this._northEast.lat = Math.max(obj.lat, this._northEast.lat);
+ this._northEast.lng = Math.max(obj.lng, this._northEast.lng);
+ }
+ } else if (obj instanceof L.LatLngBounds) {
+ this.extend(obj._southWest);
+ this.extend(obj._northEast);
+ }
+ return this;
+ },
+
+ // extend the bounds by a percentage
+ pad: function (bufferRatio) { // (Number) -> LatLngBounds
+ var sw = this._southWest,
+ ne = this._northEast,
+ heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio,
+ widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;
+
+ return new L.LatLngBounds(
+ new L.LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer),
+ new L.LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer));
+ },
+
+ getCenter: function () { // -> LatLng
+ return new L.LatLng(
+ (this._southWest.lat + this._northEast.lat) / 2,
+ (this._southWest.lng + this._northEast.lng) / 2);
+ },
+
+ getSouthWest: function () {
+ return this._southWest;
+ },
+
+ getNorthEast: function () {
+ return this._northEast;
+ },
+
+ getNorthWest: function () {
+ return new L.LatLng(this.getNorth(), this.getWest());
+ },
+
+ getSouthEast: function () {
+ return new L.LatLng(this.getSouth(), this.getEast());
+ },
+
+ getWest: function () {
+ return this._southWest.lng;
+ },
+
+ getSouth: function () {
+ return this._southWest.lat;
+ },
+
+ getEast: function () {
+ return this._northEast.lng;
+ },
+
+ getNorth: function () {
+ return this._northEast.lat;
+ },
+
+ contains: function (obj) { // (LatLngBounds) or (LatLng) -> Boolean
+ if (typeof obj[0] === 'number' || obj instanceof L.LatLng) {
+ obj = L.latLng(obj);
+ } else {
+ obj = L.latLngBounds(obj);
+ }
+
+ var sw = this._southWest,
+ ne = this._northEast,
+ sw2, ne2;
+
+ if (obj instanceof L.LatLngBounds) {
+ sw2 = obj.getSouthWest();
+ ne2 = obj.getNorthEast();
+ } else {
+ sw2 = ne2 = obj;
+ }
+
+ return (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat) &&
+ (sw2.lng >= sw.lng) && (ne2.lng <= ne.lng);
+ },
+
+ intersects: function (bounds) { // (LatLngBounds)
+ bounds = L.latLngBounds(bounds);
+
+ var sw = this._southWest,
+ ne = this._northEast,
+ sw2 = bounds.getSouthWest(),
+ ne2 = bounds.getNorthEast(),
+
+ latIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat),
+ lngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng);
+
+ return latIntersects && lngIntersects;
+ },
+
+ toBBoxString: function () {
+ return [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(',');
+ },
+
+ equals: function (bounds) { // (LatLngBounds)
+ if (!bounds) { return false; }
+
+ bounds = L.latLngBounds(bounds);
+
+ return this._southWest.equals(bounds.getSouthWest()) &&
+ this._northEast.equals(bounds.getNorthEast());
+ },
+
+ isValid: function () {
+ return !!(this._southWest && this._northEast);
+ }
+};
+
+//TODO International date line?
+
+L.latLngBounds = function (a, b) { // (LatLngBounds) or (LatLng, LatLng)
+ if (!a || a instanceof L.LatLngBounds) {
+ return a;
+ }
+ return new L.LatLngBounds(a, b);
+};
+
+
+/*
+ * L.Projection contains various geographical projections used by CRS classes.
+ */
+
+L.Projection = {};
+
+
+/*
+ * Spherical Mercator is the most popular map projection, used by EPSG:3857 CRS used by default.
+ */
+
+L.Projection.SphericalMercator = {
+ MAX_LATITUDE: 85.0511287798,
+
+ project: function (latlng) { // (LatLng) -> Point
+ var d = L.LatLng.DEG_TO_RAD,
+ max = this.MAX_LATITUDE,
+ lat = Math.max(Math.min(max, latlng.lat), -max),
+ x = latlng.lng * d,
+ y = lat * d;
+
+ y = Math.log(Math.tan((Math.PI / 4) + (y / 2)));
+
+ return new L.Point(x, y);
+ },
+
+ unproject: function (point) { // (Point, Boolean) -> LatLng
+ var d = L.LatLng.RAD_TO_DEG,
+ lng = point.x * d,
+ lat = (2 * Math.atan(Math.exp(point.y)) - (Math.PI / 2)) * d;
+
+ return new L.LatLng(lat, lng);
+ }
+};
+
+
+/*
+ * Simple equirectangular (Plate Carree) projection, used by CRS like EPSG:4326 and Simple.
+ */
+
+L.Projection.LonLat = {
+ project: function (latlng) {
+ return new L.Point(latlng.lng, latlng.lat);
+ },
+
+ unproject: function (point) {
+ return new L.LatLng(point.y, point.x);
+ }
+};
+
+
+/*
+ * L.CRS is a base object for all defined CRS (Coordinate Reference Systems) in Leaflet.
+ */
+
+L.CRS = {
+ latLngToPoint: function (latlng, zoom) { // (LatLng, Number) -> Point
+ var projectedPoint = this.projection.project(latlng),
+ scale = this.scale(zoom);
+
+ return this.transformation._transform(projectedPoint, scale);
+ },
+
+ pointToLatLng: function (point, zoom) { // (Point, Number[, Boolean]) -> LatLng
+ var scale = this.scale(zoom),
+ untransformedPoint = this.transformation.untransform(point, scale);
+
+ return this.projection.unproject(untransformedPoint);
+ },
+
+ project: function (latlng) {
+ return this.projection.project(latlng);
+ },
+
+ scale: function (zoom) {
+ return 256 * Math.pow(2, zoom);
+ },
+
+ getSize: function (zoom) {
+ var s = this.scale(zoom);
+ return L.point(s, s);
+ }
+};
+
+
+/*
+ * A simple CRS that can be used for flat non-Earth maps like panoramas or game maps.
+ */
+
+L.CRS.Simple = L.extend({}, L.CRS, {
+ projection: L.Projection.LonLat,
+ transformation: new L.Transformation(1, 0, -1, 0),
+
+ scale: function (zoom) {
+ return Math.pow(2, zoom);
+ }
+});
+
+
+/*
+ * L.CRS.EPSG3857 (Spherical Mercator) is the most common CRS for web mapping
+ * and is used by Leaflet by default.
+ */
+
+L.CRS.EPSG3857 = L.extend({}, L.CRS, {
+ code: 'EPSG:3857',
+
+ projection: L.Projection.SphericalMercator,
+ transformation: new L.Transformation(0.5 / Math.PI, 0.5, -0.5 / Math.PI, 0.5),
+
+ project: function (latlng) { // (LatLng) -> Point
+ var projectedPoint = this.projection.project(latlng),
+ earthRadius = 6378137;
+ return projectedPoint.multiplyBy(earthRadius);
+ }
+});
+
+L.CRS.EPSG900913 = L.extend({}, L.CRS.EPSG3857, {
+ code: 'EPSG:900913'
+});
+
+
+/*
+ * L.CRS.EPSG4326 is a CRS popular among advanced GIS specialists.
+ */
+
+L.CRS.EPSG4326 = L.extend({}, L.CRS, {
+ code: 'EPSG:4326',
+
+ projection: L.Projection.LonLat,
+ transformation: new L.Transformation(1 / 360, 0.5, -1 / 360, 0.5)
+});
+
+
+/*
+ * L.Map is the central class of the API - it is used to create a map.
+ */
+
+L.Map = L.Class.extend({
+
+ includes: L.Mixin.Events,
+
+ options: {
+ crs: L.CRS.EPSG3857,
+
+ /*
+ center: LatLng,
+ zoom: Number,
+ layers: Array,
+ */
+
+ fadeAnimation: L.DomUtil.TRANSITION && !L.Browser.android23,
+ trackResize: true,
+ markerZoomAnimation: L.DomUtil.TRANSITION && L.Browser.any3d
+ },
+
+ initialize: function (id, options) { // (HTMLElement or String, Object)
+ options = L.setOptions(this, options);
+
+
+ this._initContainer(id);
+ this._initLayout();
+
+ // hack for https://github.com/Leaflet/Leaflet/issues/1980
+ this._onResize = L.bind(this._onResize, this);
+
+ this._initEvents();
+
+ if (options.maxBounds) {
+ this.setMaxBounds(options.maxBounds);
+ }
+
+ if (options.center && options.zoom !== undefined) {
+ this.setView(L.latLng(options.center), options.zoom, {reset: true});
+ }
+
+ this._handlers = [];
+
+ this._layers = {};
+ this._zoomBoundLayers = {};
+ this._tileLayersNum = 0;
+
+ this.callInitHooks();
+
+ this._addLayers(options.layers);
+ },
+
+
+ // public methods that modify map state
+
+ // replaced by animation-powered implementation in Map.PanAnimation.js
+ setView: function (center, zoom) {
+ zoom = zoom === undefined ? this.getZoom() : zoom;
+ this._resetView(L.latLng(center), this._limitZoom(zoom));
+ return this;
+ },
+
+ setZoom: function (zoom, options) {
+ if (!this._loaded) {
+ this._zoom = this._limitZoom(zoom);
+ return this;
+ }
+ return this.setView(this.getCenter(), zoom, {zoom: options});
+ },
+
+ zoomIn: function (delta, options) {
+ return this.setZoom(this._zoom + (delta || 1), options);
+ },
+
+ zoomOut: function (delta, options) {
+ return this.setZoom(this._zoom - (delta || 1), options);
+ },
+
+ setZoomAround: function (latlng, zoom, options) {
+ var scale = this.getZoomScale(zoom),
+ viewHalf = this.getSize().divideBy(2),
+ containerPoint = latlng instanceof L.Point ? latlng : this.latLngToContainerPoint(latlng),
+
+ centerOffset = containerPoint.subtract(viewHalf).multiplyBy(1 - 1 / scale),
+ newCenter = this.containerPointToLatLng(viewHalf.add(centerOffset));
+
+ return this.setView(newCenter, zoom, {zoom: options});
+ },
+
+ fitBounds: function (bounds, options) {
+
+ options = options || {};
+ bounds = bounds.getBounds ? bounds.getBounds() : L.latLngBounds(bounds);
+
+ var paddingTL = L.point(options.paddingTopLeft || options.padding || [0, 0]),
+ paddingBR = L.point(options.paddingBottomRight || options.padding || [0, 0]),
+
+ zoom = this.getBoundsZoom(bounds, false, paddingTL.add(paddingBR)),
+ paddingOffset = paddingBR.subtract(paddingTL).divideBy(2),
+
+ swPoint = this.project(bounds.getSouthWest(), zoom),
+ nePoint = this.project(bounds.getNorthEast(), zoom),
+ center = this.unproject(swPoint.add(nePoint).divideBy(2).add(paddingOffset), zoom);
+
+ zoom = options && options.maxZoom ? Math.min(options.maxZoom, zoom) : zoom;
+
+ return this.setView(center, zoom, options);
+ },
+
+ fitWorld: function (options) {
+ return this.fitBounds([[-90, -180], [90, 180]], options);
+ },
+
+ panTo: function (center, options) { // (LatLng)
+ return this.setView(center, this._zoom, {pan: options});
+ },
+
+ panBy: function (offset) { // (Point)
+ // replaced with animated panBy in Map.PanAnimation.js
+ this.fire('movestart');
+
+ this._rawPanBy(L.point(offset));
+
+ this.fire('move');
+ return this.fire('moveend');
+ },
+
+ setMaxBounds: function (bounds) {
+ bounds = L.latLngBounds(bounds);
+
+ this.options.maxBounds = bounds;
+
+ if (!bounds) {
+ return this.off('moveend', this._panInsideMaxBounds, this);
+ }
+
+ if (this._loaded) {
+ this._panInsideMaxBounds();
+ }
+
+ return this.on('moveend', this._panInsideMaxBounds, this);
+ },
+
+ panInsideBounds: function (bounds, options) {
+ var center = this.getCenter(),
+ newCenter = this._limitCenter(center, this._zoom, bounds);
+
+ if (center.equals(newCenter)) { return this; }
+
+ return this.panTo(newCenter, options);
+ },
+
+ addLayer: function (layer) {
+ // TODO method is too big, refactor
+
+ var id = L.stamp(layer);
+
+ if (this._layers[id]) { return this; }
+
+ this._layers[id] = layer;
+
+ // TODO getMaxZoom, getMinZoom in ILayer (instead of options)
+ if (layer.options && (!isNaN(layer.options.maxZoom) || !isNaN(layer.options.minZoom))) {
+ this._zoomBoundLayers[id] = layer;
+ this._updateZoomLevels();
+ }
+
+ // TODO looks ugly, refactor!!!
+ if (this.options.zoomAnimation && L.TileLayer && (layer instanceof L.TileLayer)) {
+ this._tileLayersNum++;
+ this._tileLayersToLoad++;
+ layer.on('load', this._onTileLayerLoad, this);
+ }
+
+ if (this._loaded) {
+ this._layerAdd(layer);
+ }
+
+ return this;
+ },
+
+ removeLayer: function (layer) {
+ var id = L.stamp(layer);
+
+ if (!this._layers[id]) { return this; }
+
+ if (this._loaded) {
+ layer.onRemove(this);
+ }
+
+ delete this._layers[id];
+
+ if (this._loaded) {
+ this.fire('layerremove', {layer: layer});
+ }
+
+ if (this._zoomBoundLayers[id]) {
+ delete this._zoomBoundLayers[id];
+ this._updateZoomLevels();
+ }
+
+ // TODO looks ugly, refactor
+ if (this.options.zoomAnimation && L.TileLayer && (layer instanceof L.TileLayer)) {
+ this._tileLayersNum--;
+ this._tileLayersToLoad--;
+ layer.off('load', this._onTileLayerLoad, this);
+ }
+
+ return this;
+ },
+
+ hasLayer: function (layer) {
+ if (!layer) { return false; }
+
+ return (L.stamp(layer) in this._layers);
+ },
+
+ eachLayer: function (method, context) {
+ for (var i in this._layers) {
+ method.call(context, this._layers[i]);
+ }
+ return this;
+ },
+
+ invalidateSize: function (options) {
+ if (!this._loaded) { return this; }
+
+ options = L.extend({
+ animate: false,
+ pan: true
+ }, options === true ? {animate: true} : options);
+
+ var oldSize = this.getSize();
+ this._sizeChanged = true;
+ this._initialCenter = null;
+
+ var newSize = this.getSize(),
+ oldCenter = oldSize.divideBy(2).round(),
+ newCenter = newSize.divideBy(2).round(),
+ offset = oldCenter.subtract(newCenter);
+
+ if (!offset.x && !offset.y) { return this; }
+
+ if (options.animate && options.pan) {
+ this.panBy(offset);
+
+ } else {
+ if (options.pan) {
+ this._rawPanBy(offset);
+ }
+
+ this.fire('move');
+
+ if (options.debounceMoveend) {
+ clearTimeout(this._sizeTimer);
+ this._sizeTimer = setTimeout(L.bind(this.fire, this, 'moveend'), 200);
+ } else {
+ this.fire('moveend');
+ }
+ }
+
+ return this.fire('resize', {
+ oldSize: oldSize,
+ newSize: newSize
+ });
+ },
+
+ // TODO handler.addTo
+ addHandler: function (name, HandlerClass) {
+ if (!HandlerClass) { return this; }
+
+ var handler = this[name] = new HandlerClass(this);
+
+ this._handlers.push(handler);
+
+ if (this.options[name]) {
+ handler.enable();
+ }
+
+ return this;
+ },
+
+ remove: function () {
+ if (this._loaded) {
+ this.fire('unload');
+ }
+
+ this._initEvents('off');
+
+ try {
+ // throws error in IE6-8
+ delete this._container._leaflet;
+ } catch (e) {
+ this._container._leaflet = undefined;
+ }
+
+ this._clearPanes();
+ if (this._clearControlPos) {
+ this._clearControlPos();
+ }
+
+ this._clearHandlers();
+
+ return this;
+ },
+
+
+ // public methods for getting map state
+
+ getCenter: function () { // (Boolean) -> LatLng
+ this._checkIfLoaded();
+
+ if (this._initialCenter && !this._moved()) {
+ return this._initialCenter;
+ }
+ return this.layerPointToLatLng(this._getCenterLayerPoint());
+ },
+
+ getZoom: function () {
+ return this._zoom;
+ },
+
+ getBounds: function () {
+ var bounds = this.getPixelBounds(),
+ sw = this.unproject(bounds.getBottomLeft()),
+ ne = this.unproject(bounds.getTopRight());
+
+ return new L.LatLngBounds(sw, ne);
+ },
+
+ getMinZoom: function () {
+ return this.options.minZoom === undefined ?
+ (this._layersMinZoom === undefined ? 0 : this._layersMinZoom) :
+ this.options.minZoom;
+ },
+
+ getMaxZoom: function () {
+ return this.options.maxZoom === undefined ?
+ (this._layersMaxZoom === undefined ? Infinity : this._layersMaxZoom) :
+ this.options.maxZoom;
+ },
+
+ getBoundsZoom: function (bounds, inside, padding) { // (LatLngBounds[, Boolean, Point]) -> Number
+ bounds = L.latLngBounds(bounds);
+
+ var zoom = this.getMinZoom() - (inside ? 1 : 0),
+ maxZoom = this.getMaxZoom(),
+ size = this.getSize(),
+
+ nw = bounds.getNorthWest(),
+ se = bounds.getSouthEast(),
+
+ zoomNotFound = true,
+ boundsSize;
+
+ padding = L.point(padding || [0, 0]);
+
+ do {
+ zoom++;
+ boundsSize = this.project(se, zoom).subtract(this.project(nw, zoom)).add(padding);
+ zoomNotFound = !inside ? size.contains(boundsSize) : boundsSize.x < size.x || boundsSize.y < size.y;
+
+ } while (zoomNotFound && zoom <= maxZoom);
+
+ if (zoomNotFound && inside) {
+ return null;
+ }
+
+ return inside ? zoom : zoom - 1;
+ },
+
+ getSize: function () {
+ if (!this._size || this._sizeChanged) {
+ this._size = new L.Point(
+ this._container.clientWidth,
+ this._container.clientHeight);
+
+ this._sizeChanged = false;
+ }
+ return this._size.clone();
+ },
+
+ getPixelBounds: function () {
+ var topLeftPoint = this._getTopLeftPoint();
+ return new L.Bounds(topLeftPoint, topLeftPoint.add(this.getSize()));
+ },
+
+ getPixelOrigin: function () {
+ this._checkIfLoaded();
+ return this._initialTopLeftPoint;
+ },
+
+ getPanes: function () {
+ return this._panes;
+ },
+
+ getContainer: function () {
+ return this._container;
+ },
+
+
+ // TODO replace with universal implementation after refactoring projections
+
+ getZoomScale: function (toZoom) {
+ var crs = this.options.crs;
+ return crs.scale(toZoom) / crs.scale(this._zoom);
+ },
+
+ getScaleZoom: function (scale) {
+ return this._zoom + (Math.log(scale) / Math.LN2);
+ },
+
+
+ // conversion methods
+
+ project: function (latlng, zoom) { // (LatLng[, Number]) -> Point
+ zoom = zoom === undefined ? this._zoom : zoom;
+ return this.options.crs.latLngToPoint(L.latLng(latlng), zoom);
+ },
+
+ unproject: function (point, zoom) { // (Point[, Number]) -> LatLng
+ zoom = zoom === undefined ? this._zoom : zoom;
+ return this.options.crs.pointToLatLng(L.point(point), zoom);
+ },
+
+ layerPointToLatLng: function (point) { // (Point)
+ var projectedPoint = L.point(point).add(this.getPixelOrigin());
+ return this.unproject(projectedPoint);
+ },
+
+ latLngToLayerPoint: function (latlng) { // (LatLng)
+ var projectedPoint = this.project(L.latLng(latlng))._round();
+ return projectedPoint._subtract(this.getPixelOrigin());
+ },
+
+ containerPointToLayerPoint: function (point) { // (Point)
+ return L.point(point).subtract(this._getMapPanePos());
+ },
+
+ layerPointToContainerPoint: function (point) { // (Point)
+ return L.point(point).add(this._getMapPanePos());
+ },
+
+ containerPointToLatLng: function (point) {
+ var layerPoint = this.containerPointToLayerPoint(L.point(point));
+ return this.layerPointToLatLng(layerPoint);
+ },
+
+ latLngToContainerPoint: function (latlng) {
+ return this.layerPointToContainerPoint(this.latLngToLayerPoint(L.latLng(latlng)));
+ },
+
+ mouseEventToContainerPoint: function (e) { // (MouseEvent)
+ return L.DomEvent.getMousePosition(e, this._container);
+ },
+
+ mouseEventToLayerPoint: function (e) { // (MouseEvent)
+ return this.containerPointToLayerPoint(this.mouseEventToContainerPoint(e));
+ },
+
+ mouseEventToLatLng: function (e) { // (MouseEvent)
+ return this.layerPointToLatLng(this.mouseEventToLayerPoint(e));
+ },
+
+
+ // map initialization methods
+
+ _initContainer: function (id) {
+ var container = this._container = L.DomUtil.get(id);
+
+ if (!container) {
+ throw new Error('Map container not found.');
+ } else if (container._leaflet) {
+ throw new Error('Map container is already initialized.');
+ }
+
+ container._leaflet = true;
+ },
+
+ _initLayout: function () {
+ var container = this._container;
+
+ L.DomUtil.addClass(container, 'leaflet-container' +
+ (L.Browser.touch ? ' leaflet-touch' : '') +
+ (L.Browser.retina ? ' leaflet-retina' : '') +
+ (L.Browser.ielt9 ? ' leaflet-oldie' : '') +
+ (this.options.fadeAnimation ? ' leaflet-fade-anim' : ''));
+
+ var position = L.DomUtil.getStyle(container, 'position');
+
+ if (position !== 'absolute' && position !== 'relative' && position !== 'fixed') {
+ container.style.position = 'relative';
+ }
+
+ this._initPanes();
+
+ if (this._initControlPos) {
+ this._initControlPos();
+ }
+ },
+
+ _initPanes: function () {
+ var panes = this._panes = {};
+
+ this._mapPane = panes.mapPane = this._createPane('leaflet-map-pane', this._container);
+
+ this._tilePane = panes.tilePane = this._createPane('leaflet-tile-pane', this._mapPane);
+ panes.objectsPane = this._createPane('leaflet-objects-pane', this._mapPane);
+ panes.shadowPane = this._createPane('leaflet-shadow-pane');
+ panes.overlayPane = this._createPane('leaflet-overlay-pane');
+ panes.markerPane = this._createPane('leaflet-marker-pane');
+ panes.popupPane = this._createPane('leaflet-popup-pane');
+
+ var zoomHide = ' leaflet-zoom-hide';
+
+ if (!this.options.markerZoomAnimation) {
+ L.DomUtil.addClass(panes.markerPane, zoomHide);
+ L.DomUtil.addClass(panes.shadowPane, zoomHide);
+ L.DomUtil.addClass(panes.popupPane, zoomHide);
+ }
+ },
+
+ _createPane: function (className, container) {
+ return L.DomUtil.create('div', className, container || this._panes.objectsPane);
+ },
+
+ _clearPanes: function () {
+ this._container.removeChild(this._mapPane);
+ },
+
+ _addLayers: function (layers) {
+ layers = layers ? (L.Util.isArray(layers) ? layers : [layers]) : [];
+
+ for (var i = 0, len = layers.length; i < len; i++) {
+ this.addLayer(layers[i]);
+ }
+ },
+
+
+ // private methods that modify map state
+
+ _resetView: function (center, zoom, preserveMapOffset, afterZoomAnim) {
+
+ var zoomChanged = (this._zoom !== zoom);
+
+ if (!afterZoomAnim) {
+ this.fire('movestart');
+
+ if (zoomChanged) {
+ this.fire('zoomstart');
+ }
+ }
+
+ this._zoom = zoom;
+ this._initialCenter = center;
+
+ this._initialTopLeftPoint = this._getNewTopLeftPoint(center);
+
+ if (!preserveMapOffset) {
+ L.DomUtil.setPosition(this._mapPane, new L.Point(0, 0));
+ } else {
+ this._initialTopLeftPoint._add(this._getMapPanePos());
+ }
+
+ this._tileLayersToLoad = this._tileLayersNum;
+
+ var loading = !this._loaded;
+ this._loaded = true;
+
+ if (loading) {
+ this.fire('load');
+ this.eachLayer(this._layerAdd, this);
+ }
+
+ this.fire('viewreset', {hard: !preserveMapOffset});
+
+ this.fire('move');
+
+ if (zoomChanged || afterZoomAnim) {
+ this.fire('zoomend');
+ }
+
+ this.fire('moveend', {hard: !preserveMapOffset});
+ },
+
+ _rawPanBy: function (offset) {
+ L.DomUtil.setPosition(this._mapPane, this._getMapPanePos().subtract(offset));
+ },
+
+ _getZoomSpan: function () {
+ return this.getMaxZoom() - this.getMinZoom();
+ },
+
+ _updateZoomLevels: function () {
+ var i,
+ minZoom = Infinity,
+ maxZoom = -Infinity,
+ oldZoomSpan = this._getZoomSpan();
+
+ for (i in this._zoomBoundLayers) {
+ var layer = this._zoomBoundLayers[i];
+ if (!isNaN(layer.options.minZoom)) {
+ minZoom = Math.min(minZoom, layer.options.minZoom);
+ }
+ if (!isNaN(layer.options.maxZoom)) {
+ maxZoom = Math.max(maxZoom, layer.options.maxZoom);
+ }
+ }
+
+ if (i === undefined) { // we have no tilelayers
+ this._layersMaxZoom = this._layersMinZoom = undefined;
+ } else {
+ this._layersMaxZoom = maxZoom;
+ this._layersMinZoom = minZoom;
+ }
+
+ if (oldZoomSpan !== this._getZoomSpan()) {
+ this.fire('zoomlevelschange');
+ }
+ },
+
+ _panInsideMaxBounds: function () {
+ this.panInsideBounds(this.options.maxBounds);
+ },
+
+ _checkIfLoaded: function () {
+ if (!this._loaded) {
+ throw new Error('Set map center and zoom first.');
+ }
+ },
+
+ // map events
+
+ _initEvents: function (onOff) {
+ if (!L.DomEvent) { return; }
+
+ onOff = onOff || 'on';
+
+ L.DomEvent[onOff](this._container, 'click', this._onMouseClick, this);
+
+ var events = ['dblclick', 'mousedown', 'mouseup', 'mouseenter',
+ 'mouseleave', 'mousemove', 'contextmenu'],
+ i, len;
+
+ for (i = 0, len = events.length; i < len; i++) {
+ L.DomEvent[onOff](this._container, events[i], this._fireMouseEvent, this);
+ }
+
+ if (this.options.trackResize) {
+ L.DomEvent[onOff](window, 'resize', this._onResize, this);
+ }
+ },
+
+ _onResize: function () {
+ L.Util.cancelAnimFrame(this._resizeRequest);
+ this._resizeRequest = L.Util.requestAnimFrame(
+ function () { this.invalidateSize({debounceMoveend: true}); }, this, false, this._container);
+ },
+
+ _onMouseClick: function (e) {
+ if (!this._loaded || (!e._simulated &&
+ ((this.dragging && this.dragging.moved()) ||
+ (this.boxZoom && this.boxZoom.moved()))) ||
+ L.DomEvent._skipped(e)) { return; }
+
+ this.fire('preclick');
+ this._fireMouseEvent(e);
+ },
+
+ _fireMouseEvent: function (e) {
+ if (!this._loaded || L.DomEvent._skipped(e)) { return; }
+
+ var type = e.type;
+
+ type = (type === 'mouseenter' ? 'mouseover' : (type === 'mouseleave' ? 'mouseout' : type));
+
+ if (!this.hasEventListeners(type)) { return; }
+
+ if (type === 'contextmenu') {
+ L.DomEvent.preventDefault(e);
+ }
+
+ var containerPoint = this.mouseEventToContainerPoint(e),
+ layerPoint = this.containerPointToLayerPoint(containerPoint),
+ latlng = this.layerPointToLatLng(layerPoint);
+
+ this.fire(type, {
+ latlng: latlng,
+ layerPoint: layerPoint,
+ containerPoint: containerPoint,
+ originalEvent: e
+ });
+ },
+
+ _onTileLayerLoad: function () {
+ this._tileLayersToLoad--;
+ if (this._tileLayersNum && !this._tileLayersToLoad) {
+ this.fire('tilelayersload');
+ }
+ },
+
+ _clearHandlers: function () {
+ for (var i = 0, len = this._handlers.length; i < len; i++) {
+ this._handlers[i].disable();
+ }
+ },
+
+ whenReady: function (callback, context) {
+ if (this._loaded) {
+ callback.call(context || this, this);
+ } else {
+ this.on('load', callback, context);
+ }
+ return this;
+ },
+
+ _layerAdd: function (layer) {
+ layer.onAdd(this);
+ this.fire('layeradd', {layer: layer});
+ },
+
+
+ // private methods for getting map state
+
+ _getMapPanePos: function () {
+ return L.DomUtil.getPosition(this._mapPane);
+ },
+
+ _moved: function () {
+ var pos = this._getMapPanePos();
+ return pos && !pos.equals([0, 0]);
+ },
+
+ _getTopLeftPoint: function () {
+ return this.getPixelOrigin().subtract(this._getMapPanePos());
+ },
+
+ _getNewTopLeftPoint: function (center, zoom) {
+ var viewHalf = this.getSize()._divideBy(2);
+ // TODO round on display, not calculation to increase precision?
+ return this.project(center, zoom)._subtract(viewHalf)._round();
+ },
+
+ _latLngToNewLayerPoint: function (latlng, newZoom, newCenter) {
+ var topLeft = this._getNewTopLeftPoint(newCenter, newZoom).add(this._getMapPanePos());
+ return this.project(latlng, newZoom)._subtract(topLeft);
+ },
+
+ // layer point of the current center
+ _getCenterLayerPoint: function () {
+ return this.containerPointToLayerPoint(this.getSize()._divideBy(2));
+ },
+
+ // offset of the specified place to the current center in pixels
+ _getCenterOffset: function (latlng) {
+ return this.latLngToLayerPoint(latlng).subtract(this._getCenterLayerPoint());
+ },
+
+ // adjust center for view to get inside bounds
+ _limitCenter: function (center, zoom, bounds) {
+
+ if (!bounds) { return center; }
+
+ var centerPoint = this.project(center, zoom),
+ viewHalf = this.getSize().divideBy(2),
+ viewBounds = new L.Bounds(centerPoint.subtract(viewHalf), centerPoint.add(viewHalf)),
+ offset = this._getBoundsOffset(viewBounds, bounds, zoom);
+
+ return this.unproject(centerPoint.add(offset), zoom);
+ },
+
+ // adjust offset for view to get inside bounds
+ _limitOffset: function (offset, bounds) {
+ if (!bounds) { return offset; }
+
+ var viewBounds = this.getPixelBounds(),
+ newBounds = new L.Bounds(viewBounds.min.add(offset), viewBounds.max.add(offset));
+
+ return offset.add(this._getBoundsOffset(newBounds, bounds));
+ },
+
+ // returns offset needed for pxBounds to get inside maxBounds at a specified zoom
+ _getBoundsOffset: function (pxBounds, maxBounds, zoom) {
+ var nwOffset = this.project(maxBounds.getNorthWest(), zoom).subtract(pxBounds.min),
+ seOffset = this.project(maxBounds.getSouthEast(), zoom).subtract(pxBounds.max),
+
+ dx = this._rebound(nwOffset.x, -seOffset.x),
+ dy = this._rebound(nwOffset.y, -seOffset.y);
+
+ return new L.Point(dx, dy);
+ },
+
+ _rebound: function (left, right) {
+ return left + right > 0 ?
+ Math.round(left - right) / 2 :
+ Math.max(0, Math.ceil(left)) - Math.max(0, Math.floor(right));
+ },
+
+ _limitZoom: function (zoom) {
+ var min = this.getMinZoom(),
+ max = this.getMaxZoom();
+
+ return Math.max(min, Math.min(max, zoom));
+ }
+});
+
+L.map = function (id, options) {
+ return new L.Map(id, options);
+};
+
+
+/*
+ * Mercator projection that takes into account that the Earth is not a perfect sphere.
+ * Less popular than spherical mercator; used by projections like EPSG:3395.
+ */
+
+L.Projection.Mercator = {
+ MAX_LATITUDE: 85.0840591556,
+
+ R_MINOR: 6356752.314245179,
+ R_MAJOR: 6378137,
+
+ project: function (latlng) { // (LatLng) -> Point
+ var d = L.LatLng.DEG_TO_RAD,
+ max = this.MAX_LATITUDE,
+ lat = Math.max(Math.min(max, latlng.lat), -max),
+ r = this.R_MAJOR,
+ r2 = this.R_MINOR,
+ x = latlng.lng * d * r,
+ y = lat * d,
+ tmp = r2 / r,
+ eccent = Math.sqrt(1.0 - tmp * tmp),
+ con = eccent * Math.sin(y);
+
+ con = Math.pow((1 - con) / (1 + con), eccent * 0.5);
+
+ var ts = Math.tan(0.5 * ((Math.PI * 0.5) - y)) / con;
+ y = -r * Math.log(ts);
+
+ return new L.Point(x, y);
+ },
+
+ unproject: function (point) { // (Point, Boolean) -> LatLng
+ var d = L.LatLng.RAD_TO_DEG,
+ r = this.R_MAJOR,
+ r2 = this.R_MINOR,
+ lng = point.x * d / r,
+ tmp = r2 / r,
+ eccent = Math.sqrt(1 - (tmp * tmp)),
+ ts = Math.exp(- point.y / r),
+ phi = (Math.PI / 2) - 2 * Math.atan(ts),
+ numIter = 15,
+ tol = 1e-7,
+ i = numIter,
+ dphi = 0.1,
+ con;
+
+ while ((Math.abs(dphi) > tol) && (--i > 0)) {
+ con = eccent * Math.sin(phi);
+ dphi = (Math.PI / 2) - 2 * Math.atan(ts *
+ Math.pow((1.0 - con) / (1.0 + con), 0.5 * eccent)) - phi;
+ phi += dphi;
+ }
+
+ return new L.LatLng(phi * d, lng);
+ }
+};
+
+
+
+L.CRS.EPSG3395 = L.extend({}, L.CRS, {
+ code: 'EPSG:3395',
+
+ projection: L.Projection.Mercator,
+
+ transformation: (function () {
+ var m = L.Projection.Mercator,
+ r = m.R_MAJOR,
+ scale = 0.5 / (Math.PI * r);
+
+ return new L.Transformation(scale, 0.5, -scale, 0.5);
+ }())
+});
+
+
+/*
+ * L.TileLayer is used for standard xyz-numbered tile layers.
+ */
+
+L.TileLayer = L.Class.extend({
+ includes: L.Mixin.Events,
+
+ options: {
+ minZoom: 0,
+ maxZoom: 18,
+ tileSize: 256,
+ subdomains: 'abc',
+ errorTileUrl: '',
+ attribution: '',
+ zoomOffset: 0,
+ opacity: 1,
+ /*
+ maxNativeZoom: null,
+ zIndex: null,
+ tms: false,
+ continuousWorld: false,
+ noWrap: false,
+ zoomReverse: false,
+ detectRetina: false,
+ reuseTiles: false,
+ bounds: false,
+ */
+ unloadInvisibleTiles: L.Browser.mobile,
+ updateWhenIdle: L.Browser.mobile
+ },
+
+ initialize: function (url, options) {
+ options = L.setOptions(this, options);
+
+ // detecting retina displays, adjusting tileSize and zoom levels
+ if (options.detectRetina && L.Browser.retina && options.maxZoom > 0) {
+
+ options.tileSize = Math.floor(options.tileSize / 2);
+ options.zoomOffset++;
+
+ if (options.minZoom > 0) {
+ options.minZoom--;
+ }
+ this.options.maxZoom--;
+ }
+
+ if (options.bounds) {
+ options.bounds = L.latLngBounds(options.bounds);
+ }
+
+ this._url = url;
+
+ var subdomains = this.options.subdomains;
+
+ if (typeof subdomains === 'string') {
+ this.options.subdomains = subdomains.split('');
+ }
+ },
+
+ onAdd: function (map) {
+ this._map = map;
+ this._animated = map._zoomAnimated;
+
+ // create a container div for tiles
+ this._initContainer();
+
+ // set up events
+ map.on({
+ 'viewreset': this._reset,
+ 'moveend': this._update
+ }, this);
+
+ if (this._animated) {
+ map.on({
+ 'zoomanim': this._animateZoom,
+ 'zoomend': this._endZoomAnim
+ }, this);
+ }
+
+ if (!this.options.updateWhenIdle) {
+ this._limitedUpdate = L.Util.limitExecByInterval(this._update, 150, this);
+ map.on('move', this._limitedUpdate, this);
+ }
+
+ this._reset();
+ this._update();
+ },
+
+ addTo: function (map) {
+ map.addLayer(this);
+ return this;
+ },
+
+ onRemove: function (map) {
+ this._container.parentNode.removeChild(this._container);
+
+ map.off({
+ 'viewreset': this._reset,
+ 'moveend': this._update
+ }, this);
+
+ if (this._animated) {
+ map.off({
+ 'zoomanim': this._animateZoom,
+ 'zoomend': this._endZoomAnim
+ }, this);
+ }
+
+ if (!this.options.updateWhenIdle) {
+ map.off('move', this._limitedUpdate, this);
+ }
+
+ this._container = null;
+ this._map = null;
+ },
+
+ bringToFront: function () {
+ var pane = this._map._panes.tilePane;
+
+ if (this._container) {
+ pane.appendChild(this._container);
+ this._setAutoZIndex(pane, Math.max);
+ }
+
+ return this;
+ },
+
+ bringToBack: function () {
+ var pane = this._map._panes.tilePane;
+
+ if (this._container) {
+ pane.insertBefore(this._container, pane.firstChild);
+ this._setAutoZIndex(pane, Math.min);
+ }
+
+ return this;
+ },
+
+ getAttribution: function () {
+ return this.options.attribution;
+ },
+
+ getContainer: function () {
+ return this._container;
+ },
+
+ setOpacity: function (opacity) {
+ this.options.opacity = opacity;
+
+ if (this._map) {
+ this._updateOpacity();
+ }
+
+ return this;
+ },
+
+ setZIndex: function (zIndex) {
+ this.options.zIndex = zIndex;
+ this._updateZIndex();
+
+ return this;
+ },
+
+ setUrl: function (url, noRedraw) {
+ this._url = url;
+
+ if (!noRedraw) {
+ this.redraw();
+ }
+
+ return this;
+ },
+
+ redraw: function () {
+ if (this._map) {
+ this._reset({hard: true});
+ this._update();
+ }
+ return this;
+ },
+
+ _updateZIndex: function () {
+ if (this._container && this.options.zIndex !== undefined) {
+ this._container.style.zIndex = this.options.zIndex;
+ }
+ },
+
+ _setAutoZIndex: function (pane, compare) {
+
+ var layers = pane.children,
+ edgeZIndex = -compare(Infinity, -Infinity), // -Infinity for max, Infinity for min
+ zIndex, i, len;
+
+ for (i = 0, len = layers.length; i < len; i++) {
+
+ if (layers[i] !== this._container) {
+ zIndex = parseInt(layers[i].style.zIndex, 10);
+
+ if (!isNaN(zIndex)) {
+ edgeZIndex = compare(edgeZIndex, zIndex);
+ }
+ }
+ }
+
+ this.options.zIndex = this._container.style.zIndex =
+ (isFinite(edgeZIndex) ? edgeZIndex : 0) + compare(1, -1);
+ },
+
+ _updateOpacity: function () {
+ var i,
+ tiles = this._tiles;
+
+ if (L.Browser.ielt9) {
+ for (i in tiles) {
+ L.DomUtil.setOpacity(tiles[i], this.options.opacity);
+ }
+ } else {
+ L.DomUtil.setOpacity(this._container, this.options.opacity);
+ }
+ },
+
+ _initContainer: function () {
+ var tilePane = this._map._panes.tilePane;
+
+ if (!this._container) {
+ this._container = L.DomUtil.create('div', 'leaflet-layer');
+
+ this._updateZIndex();
+
+ if (this._animated) {
+ var className = 'leaflet-tile-container';
+
+ this._bgBuffer = L.DomUtil.create('div', className, this._container);
+ this._tileContainer = L.DomUtil.create('div', className, this._container);
+
+ } else {
+ this._tileContainer = this._container;
+ }
+
+ tilePane.appendChild(this._container);
+
+ if (this.options.opacity < 1) {
+ this._updateOpacity();
+ }
+ }
+ },
+
+ _reset: function (e) {
+ for (var key in this._tiles) {
+ this.fire('tileunload', {tile: this._tiles[key]});
+ }
+
+ this._tiles = {};
+ this._tilesToLoad = 0;
+
+ if (this.options.reuseTiles) {
+ this._unusedTiles = [];
+ }
+
+ this._tileContainer.innerHTML = '';
+
+ if (this._animated && e && e.hard) {
+ this._clearBgBuffer();
+ }
+
+ this._initContainer();
+ },
+
+ _getTileSize: function () {
+ var map = this._map,
+ zoom = map.getZoom() + this.options.zoomOffset,
+ zoomN = this.options.maxNativeZoom,
+ tileSize = this.options.tileSize;
+
+ if (zoomN && zoom > zoomN) {
+ tileSize = Math.round(map.getZoomScale(zoom) / map.getZoomScale(zoomN) * tileSize);
+ }
+
+ return tileSize;
+ },
+
+ _update: function () {
+
+ if (!this._map) { return; }
+
+ var map = this._map,
+ bounds = map.getPixelBounds(),
+ zoom = map.getZoom(),
+ tileSize = this._getTileSize();
+
+ if (zoom > this.options.maxZoom || zoom < this.options.minZoom) {
+ return;
+ }
+
+ var tileBounds = L.bounds(
+ bounds.min.divideBy(tileSize)._floor(),
+ bounds.max.divideBy(tileSize)._floor());
+
+ this._addTilesFromCenterOut(tileBounds);
+
+ if (this.options.unloadInvisibleTiles || this.options.reuseTiles) {
+ this._removeOtherTiles(tileBounds);
+ }
+ },
+
+ _addTilesFromCenterOut: function (bounds) {
+ var queue = [],
+ center = bounds.getCenter();
+
+ var j, i, point;
+
+ for (j = bounds.min.y; j <= bounds.max.y; j++) {
+ for (i = bounds.min.x; i <= bounds.max.x; i++) {
+ point = new L.Point(i, j);
+
+ if (this._tileShouldBeLoaded(point)) {
+ queue.push(point);
+ }
+ }
+ }
+
+ var tilesToLoad = queue.length;
+
+ if (tilesToLoad === 0) { return; }
+
+ // load tiles in order of their distance to center
+ queue.sort(function (a, b) {
+ return a.distanceTo(center) - b.distanceTo(center);
+ });
+
+ var fragment = document.createDocumentFragment();
+
+ // if its the first batch of tiles to load
+ if (!this._tilesToLoad) {
+ this.fire('loading');
+ }
+
+ this._tilesToLoad += tilesToLoad;
+
+ for (i = 0; i < tilesToLoad; i++) {
+ this._addTile(queue[i], fragment);
+ }
+
+ this._tileContainer.appendChild(fragment);
+ },
+
+ _tileShouldBeLoaded: function (tilePoint) {
+ if ((tilePoint.x + ':' + tilePoint.y) in this._tiles) {
+ return false; // already loaded
+ }
+
+ var options = this.options;
+
+ if (!options.continuousWorld) {
+ var limit = this._getWrapTileNum();
+
+ // don't load if exceeds world bounds
+ if ((options.noWrap && (tilePoint.x < 0 || tilePoint.x >= limit.x)) ||
+ tilePoint.y < 0 || tilePoint.y >= limit.y) { return false; }
+ }
+
+ if (options.bounds) {
+ var tileSize = options.tileSize,
+ nwPoint = tilePoint.multiplyBy(tileSize),
+ sePoint = nwPoint.add([tileSize, tileSize]),
+ nw = this._map.unproject(nwPoint),
+ se = this._map.unproject(sePoint);
+
+ // TODO temporary hack, will be removed after refactoring projections
+ // https://github.com/Leaflet/Leaflet/issues/1618
+ if (!options.continuousWorld && !options.noWrap) {
+ nw = nw.wrap();
+ se = se.wrap();
+ }
+
+ if (!options.bounds.intersects([nw, se])) { return false; }
+ }
+
+ return true;
+ },
+
+ _removeOtherTiles: function (bounds) {
+ var kArr, x, y, key;
+
+ for (key in this._tiles) {
+ kArr = key.split(':');
+ x = parseInt(kArr[0], 10);
+ y = parseInt(kArr[1], 10);
+
+ // remove tile if it's out of bounds
+ if (x < bounds.min.x || x > bounds.max.x || y < bounds.min.y || y > bounds.max.y) {
+ this._removeTile(key);
+ }
+ }
+ },
+
+ _removeTile: function (key) {
+ var tile = this._tiles[key];
+
+ this.fire('tileunload', {tile: tile, url: tile.src});
+
+ if (this.options.reuseTiles) {
+ L.DomUtil.removeClass(tile, 'leaflet-tile-loaded');
+ this._unusedTiles.push(tile);
+
+ } else if (tile.parentNode === this._tileContainer) {
+ this._tileContainer.removeChild(tile);
+ }
+
+ // for https://github.com/CloudMade/Leaflet/issues/137
+ if (!L.Browser.android) {
+ tile.onload = null;
+ tile.src = L.Util.emptyImageUrl;
+ }
+
+ delete this._tiles[key];
+ },
+
+ _addTile: function (tilePoint, container) {
+ var tilePos = this._getTilePos(tilePoint);
+
+ // get unused tile - or create a new tile
+ var tile = this._getTile();
+
+ /*
+ Chrome 20 layouts much faster with top/left (verify with timeline, frames)
+ Android 4 browser has display issues with top/left and requires transform instead
+ (other browsers don't currently care) - see debug/hacks/jitter.html for an example
+ */
+ L.DomUtil.setPosition(tile, tilePos, L.Browser.chrome);
+
+ this._tiles[tilePoint.x + ':' + tilePoint.y] = tile;
+
+ this._loadTile(tile, tilePoint);
+
+ if (tile.parentNode !== this._tileContainer) {
+ container.appendChild(tile);
+ }
+ },
+
+ _getZoomForUrl: function () {
+
+ var options = this.options,
+ zoom = this._map.getZoom();
+
+ if (options.zoomReverse) {
+ zoom = options.maxZoom - zoom;
+ }
+
+ zoom += options.zoomOffset;
+
+ return options.maxNativeZoom ? Math.min(zoom, options.maxNativeZoom) : zoom;
+ },
+
+ _getTilePos: function (tilePoint) {
+ var origin = this._map.getPixelOrigin(),
+ tileSize = this._getTileSize();
+
+ return tilePoint.multiplyBy(tileSize).subtract(origin);
+ },
+
+ // image-specific code (override to implement e.g. Canvas or SVG tile layer)
+
+ getTileUrl: function (tilePoint) {
+ return L.Util.template(this._url, L.extend({
+ s: this._getSubdomain(tilePoint),
+ z: tilePoint.z,
+ x: tilePoint.x,
+ y: tilePoint.y
+ }, this.options));
+ },
+
+ _getWrapTileNum: function () {
+ var crs = this._map.options.crs,
+ size = crs.getSize(this._map.getZoom());
+ return size.divideBy(this._getTileSize())._floor();
+ },
+
+ _adjustTilePoint: function (tilePoint) {
+
+ var limit = this._getWrapTileNum();
+
+ // wrap tile coordinates
+ if (!this.options.continuousWorld && !this.options.noWrap) {
+ tilePoint.x = ((tilePoint.x % limit.x) + limit.x) % limit.x;
+ }
+
+ if (this.options.tms) {
+ tilePoint.y = limit.y - tilePoint.y - 1;
+ }
+
+ tilePoint.z = this._getZoomForUrl();
+ },
+
+ _getSubdomain: function (tilePoint) {
+ var index = Math.abs(tilePoint.x + tilePoint.y) % this.options.subdomains.length;
+ return this.options.subdomains[index];
+ },
+
+ _getTile: function () {
+ if (this.options.reuseTiles && this._unusedTiles.length > 0) {
+ var tile = this._unusedTiles.pop();
+ this._resetTile(tile);
+ return tile;
+ }
+ return this._createTile();
+ },
+
+ // Override if data stored on a tile needs to be cleaned up before reuse
+ _resetTile: function (/*tile*/) {},
+
+ _createTile: function () {
+ var tile = L.DomUtil.create('img', 'leaflet-tile');
+ tile.style.width = tile.style.height = this._getTileSize() + 'px';
+ tile.galleryimg = 'no';
+
+ tile.onselectstart = tile.onmousemove = L.Util.falseFn;
+
+ if (L.Browser.ielt9 && this.options.opacity !== undefined) {
+ L.DomUtil.setOpacity(tile, this.options.opacity);
+ }
+ // without this hack, tiles disappear after zoom on Chrome for Android
+ // https://github.com/Leaflet/Leaflet/issues/2078
+ if (L.Browser.mobileWebkit3d) {
+ tile.style.WebkitBackfaceVisibility = 'hidden';
+ }
+ return tile;
+ },
+
+ _loadTile: function (tile, tilePoint) {
+ tile._layer = this;
+ tile.onload = this._tileOnLoad;
+ tile.onerror = this._tileOnError;
+
+ this._adjustTilePoint(tilePoint);
+ tile.src = this.getTileUrl(tilePoint);
+
+ this.fire('tileloadstart', {
+ tile: tile,
+ url: tile.src
+ });
+ },
+
+ _tileLoaded: function () {
+ this._tilesToLoad--;
+
+ if (this._animated) {
+ L.DomUtil.addClass(this._tileContainer, 'leaflet-zoom-animated');
+ }
+
+ if (!this._tilesToLoad) {
+ this.fire('load');
+
+ if (this._animated) {
+ // clear scaled tiles after all new tiles are loaded (for performance)
+ clearTimeout(this._clearBgBufferTimer);
+ this._clearBgBufferTimer = setTimeout(L.bind(this._clearBgBuffer, this), 500);
+ }
+ }
+ },
+
+ _tileOnLoad: function () {
+ var layer = this._layer;
+
+ //Only if we are loading an actual image
+ if (this.src !== L.Util.emptyImageUrl) {
+ L.DomUtil.addClass(this, 'leaflet-tile-loaded');
+
+ layer.fire('tileload', {
+ tile: this,
+ url: this.src
+ });
+ }
+
+ layer._tileLoaded();
+ },
+
+ _tileOnError: function () {
+ var layer = this._layer;
+
+ layer.fire('tileerror', {
+ tile: this,
+ url: this.src
+ });
+
+ var newUrl = layer.options.errorTileUrl;
+ if (newUrl) {
+ this.src = newUrl;
+ }
+
+ layer._tileLoaded();
+ }
+});
+
+L.tileLayer = function (url, options) {
+ return new L.TileLayer(url, options);
+};
+
+
+/*
+ * L.TileLayer.WMS is used for putting WMS tile layers on the map.
+ */
+
+L.TileLayer.WMS = L.TileLayer.extend({
+
+ defaultWmsParams: {
+ service: 'WMS',
+ request: 'GetMap',
+ version: '1.1.1',
+ layers: '',
+ styles: '',
+ format: 'image/jpeg',
+ transparent: false
+ },
+
+ initialize: function (url, options) { // (String, Object)
+
+ this._url = url;
+
+ var wmsParams = L.extend({}, this.defaultWmsParams),
+ tileSize = options.tileSize || this.options.tileSize;
+
+ if (options.detectRetina && L.Browser.retina) {
+ wmsParams.width = wmsParams.height = tileSize * 2;
+ } else {
+ wmsParams.width = wmsParams.height = tileSize;
+ }
+
+ for (var i in options) {
+ // all keys that are not TileLayer options go to WMS params
+ if (!this.options.hasOwnProperty(i) && i !== 'crs') {
+ wmsParams[i] = options[i];
+ }
+ }
+
+ this.wmsParams = wmsParams;
+
+ L.setOptions(this, options);
+ },
+
+ onAdd: function (map) {
+
+ this._crs = this.options.crs || map.options.crs;
+
+ this._wmsVersion = parseFloat(this.wmsParams.version);
+
+ var projectionKey = this._wmsVersion >= 1.3 ? 'crs' : 'srs';
+ this.wmsParams[projectionKey] = this._crs.code;
+
+ L.TileLayer.prototype.onAdd.call(this, map);
+ },
+
+ getTileUrl: function (tilePoint) { // (Point, Number) -> String
+
+ var map = this._map,
+ tileSize = this.options.tileSize,
+
+ nwPoint = tilePoint.multiplyBy(tileSize),
+ sePoint = nwPoint.add([tileSize, tileSize]),
+
+ nw = this._crs.project(map.unproject(nwPoint, tilePoint.z)),
+ se = this._crs.project(map.unproject(sePoint, tilePoint.z)),
+ bbox = this._wmsVersion >= 1.3 && this._crs === L.CRS.EPSG4326 ?
+ [se.y, nw.x, nw.y, se.x].join(',') :
+ [nw.x, se.y, se.x, nw.y].join(','),
+
+ url = L.Util.template(this._url, {s: this._getSubdomain(tilePoint)});
+
+ return url + L.Util.getParamString(this.wmsParams, url, true) + '&BBOX=' + bbox;
+ },
+
+ setParams: function (params, noRedraw) {
+
+ L.extend(this.wmsParams, params);
+
+ if (!noRedraw) {
+ this.redraw();
+ }
+
+ return this;
+ }
+});
+
+L.tileLayer.wms = function (url, options) {
+ return new L.TileLayer.WMS(url, options);
+};
+
+
+/*
+ * L.TileLayer.Canvas is a class that you can use as a base for creating
+ * dynamically drawn Canvas-based tile layers.
+ */
+
+L.TileLayer.Canvas = L.TileLayer.extend({
+ options: {
+ async: false
+ },
+
+ initialize: function (options) {
+ L.setOptions(this, options);
+ },
+
+ redraw: function () {
+ if (this._map) {
+ this._reset({hard: true});
+ this._update();
+ }
+
+ for (var i in this._tiles) {
+ this._redrawTile(this._tiles[i]);
+ }
+ return this;
+ },
+
+ _redrawTile: function (tile) {
+ this.drawTile(tile, tile._tilePoint, this._map._zoom);
+ },
+
+ _createTile: function () {
+ var tile = L.DomUtil.create('canvas', 'leaflet-tile');
+ tile.width = tile.height = this.options.tileSize;
+ tile.onselectstart = tile.onmousemove = L.Util.falseFn;
+ return tile;
+ },
+
+ _loadTile: function (tile, tilePoint) {
+ tile._layer = this;
+ tile._tilePoint = tilePoint;
+
+ this._redrawTile(tile);
+
+ if (!this.options.async) {
+ this.tileDrawn(tile);
+ }
+ },
+
+ drawTile: function (/*tile, tilePoint*/) {
+ // override with rendering code
+ },
+
+ tileDrawn: function (tile) {
+ this._tileOnLoad.call(tile);
+ }
+});
+
+
+L.tileLayer.canvas = function (options) {
+ return new L.TileLayer.Canvas(options);
+};
+
+
+/*
+ * L.ImageOverlay is used to overlay images over the map (to specific geographical bounds).
+ */
+
+L.ImageOverlay = L.Class.extend({
+ includes: L.Mixin.Events,
+
+ options: {
+ opacity: 1
+ },
+
+ initialize: function (url, bounds, options) { // (String, LatLngBounds, Object)
+ this._url = url;
+ this._bounds = L.latLngBounds(bounds);
+
+ L.setOptions(this, options);
+ },
+
+ onAdd: function (map) {
+ this._map = map;
+
+ if (!this._image) {
+ this._initImage();
+ }
+
+ map._panes.overlayPane.appendChild(this._image);
+
+ map.on('viewreset', this._reset, this);
+
+ if (map.options.zoomAnimation && L.Browser.any3d) {
+ map.on('zoomanim', this._animateZoom, this);
+ }
+
+ this._reset();
+ },
+
+ onRemove: function (map) {
+ map.getPanes().overlayPane.removeChild(this._image);
+
+ map.off('viewreset', this._reset, this);
+
+ if (map.options.zoomAnimation) {
+ map.off('zoomanim', this._animateZoom, this);
+ }
+ },
+
+ addTo: function (map) {
+ map.addLayer(this);
+ return this;
+ },
+
+ setOpacity: function (opacity) {
+ this.options.opacity = opacity;
+ this._updateOpacity();
+ return this;
+ },
+
+ // TODO remove bringToFront/bringToBack duplication from TileLayer/Path
+ bringToFront: function () {
+ if (this._image) {
+ this._map._panes.overlayPane.appendChild(this._image);
+ }
+ return this;
+ },
+
+ bringToBack: function () {
+ var pane = this._map._panes.overlayPane;
+ if (this._image) {
+ pane.insertBefore(this._image, pane.firstChild);
+ }
+ return this;
+ },
+
+ setUrl: function (url) {
+ this._url = url;
+ this._image.src = this._url;
+ },
+
+ getAttribution: function () {
+ return this.options.attribution;
+ },
+
+ _initImage: function () {
+ this._image = L.DomUtil.create('img', 'leaflet-image-layer');
+
+ if (this._map.options.zoomAnimation && L.Browser.any3d) {
+ L.DomUtil.addClass(this._image, 'leaflet-zoom-animated');
+ } else {
+ L.DomUtil.addClass(this._image, 'leaflet-zoom-hide');
+ }
+
+ this._updateOpacity();
+
+ //TODO createImage util method to remove duplication
+ L.extend(this._image, {
+ galleryimg: 'no',
+ onselectstart: L.Util.falseFn,
+ onmousemove: L.Util.falseFn,
+ onload: L.bind(this._onImageLoad, this),
+ src: this._url
+ });
+ },
+
+ _animateZoom: function (e) {
+ var map = this._map,
+ image = this._image,
+ scale = map.getZoomScale(e.zoom),
+ nw = this._bounds.getNorthWest(),
+ se = this._bounds.getSouthEast(),
+
+ topLeft = map._latLngToNewLayerPoint(nw, e.zoom, e.center),
+ size = map._latLngToNewLayerPoint(se, e.zoom, e.center)._subtract(topLeft),
+ origin = topLeft._add(size._multiplyBy((1 / 2) * (1 - 1 / scale)));
+
+ image.style[L.DomUtil.TRANSFORM] =
+ L.DomUtil.getTranslateString(origin) + ' scale(' + scale + ') ';
+ },
+
+ _reset: function () {
+ var image = this._image,
+ topLeft = this._map.latLngToLayerPoint(this._bounds.getNorthWest()),
+ size = this._map.latLngToLayerPoint(this._bounds.getSouthEast())._subtract(topLeft);
+
+ L.DomUtil.setPosition(image, topLeft);
+
+ image.style.width = size.x + 'px';
+ image.style.height = size.y + 'px';
+ },
+
+ _onImageLoad: function () {
+ this.fire('load');
+ },
+
+ _updateOpacity: function () {
+ L.DomUtil.setOpacity(this._image, this.options.opacity);
+ }
+});
+
+L.imageOverlay = function (url, bounds, options) {
+ return new L.ImageOverlay(url, bounds, options);
+};
+
+
+/*
+ * L.Icon is an image-based icon class that you can use with L.Marker for custom markers.
+ */
+
+L.Icon = L.Class.extend({
+ options: {
+ /*
+ iconUrl: (String) (required)
+ iconRetinaUrl: (String) (optional, used for retina devices if detected)
+ iconSize: (Point) (can be set through CSS)
+ iconAnchor: (Point) (centered by default, can be set in CSS with negative margins)
+ popupAnchor: (Point) (if not specified, popup opens in the anchor point)
+ shadowUrl: (String) (no shadow by default)
+ shadowRetinaUrl: (String) (optional, used for retina devices if detected)
+ shadowSize: (Point)
+ shadowAnchor: (Point)
+ */
+ className: ''
+ },
+
+ initialize: function (options) {
+ L.setOptions(this, options);
+ },
+
+ createIcon: function (oldIcon) {
+ return this._createIcon('icon', oldIcon);
+ },
+
+ createShadow: function (oldIcon) {
+ return this._createIcon('shadow', oldIcon);
+ },
+
+ _createIcon: function (name, oldIcon) {
+ var src = this._getIconUrl(name);
+
+ if (!src) {
+ if (name === 'icon') {
+ throw new Error('iconUrl not set in Icon options (see the docs).');
+ }
+ return null;
+ }
+
+ var img;
+ if (!oldIcon || oldIcon.tagName !== 'IMG') {
+ img = this._createImg(src);
+ } else {
+ img = this._createImg(src, oldIcon);
+ }
+ this._setIconStyles(img, name);
+
+ return img;
+ },
+
+ _setIconStyles: function (img, name) {
+ var options = this.options,
+ size = L.point(options[name + 'Size']),
+ anchor;
+
+ if (name === 'shadow') {
+ anchor = L.point(options.shadowAnchor || options.iconAnchor);
+ } else {
+ anchor = L.point(options.iconAnchor);
+ }
+
+ if (!anchor && size) {
+ anchor = size.divideBy(2, true);
+ }
+
+ img.className = 'leaflet-marker-' + name + ' ' + options.className;
+
+ if (anchor) {
+ img.style.marginLeft = (-anchor.x) + 'px';
+ img.style.marginTop = (-anchor.y) + 'px';
+ }
+
+ if (size) {
+ img.style.width = size.x + 'px';
+ img.style.height = size.y + 'px';
+ }
+ },
+
+ _createImg: function (src, el) {
+ el = el || document.createElement('img');
+ el.src = src;
+ return el;
+ },
+
+ _getIconUrl: function (name) {
+ if (L.Browser.retina && this.options[name + 'RetinaUrl']) {
+ return this.options[name + 'RetinaUrl'];
+ }
+ return this.options[name + 'Url'];
+ }
+});
+
+L.icon = function (options) {
+ return new L.Icon(options);
+};
+
+
+/*
+ * L.Icon.Default is the blue marker icon used by default in Leaflet.
+ */
+
+L.Icon.Default = L.Icon.extend({
+
+ options: {
+ iconSize: [25, 41],
+ iconAnchor: [12, 41],
+ popupAnchor: [1, -34],
+
+ shadowSize: [41, 41]
+ },
+
+ _getIconUrl: function (name) {
+ var key = name + 'Url';
+
+ if (this.options[key]) {
+ return this.options[key];
+ }
+
+ if (L.Browser.retina && name === 'icon') {
+ name += '-2x';
+ }
+
+ var path = L.Icon.Default.imagePath;
+
+ if (!path) {
+ throw new Error('Couldn\'t autodetect L.Icon.Default.imagePath, set it manually.');
+ }
+
+ return path + '/marker-' + name + '.png';
+ }
+});
+
+L.Icon.Default.imagePath = (function () {
+ var scripts = document.getElementsByTagName('script'),
+ leafletRe = /[\/^]leaflet[\-\._]?([\w\-\._]*)\.js\??/;
+
+ var i, len, src, matches, path;
+
+ for (i = 0, len = scripts.length; i < len; i++) {
+ src = scripts[i].src;
+ matches = src.match(leafletRe);
+
+ if (matches) {
+ path = src.split(leafletRe)[0];
+ return (path ? path + '/' : '') + 'images';
+ }
+ }
+}());
+
+
+/*
+ * L.Marker is used to display clickable/draggable icons on the map.
+ */
+
+L.Marker = L.Class.extend({
+
+ includes: L.Mixin.Events,
+
+ options: {
+ icon: new L.Icon.Default(),
+ title: '',
+ alt: '',
+ clickable: true,
+ draggable: false,
+ keyboard: true,
+ zIndexOffset: 0,
+ opacity: 1,
+ riseOnHover: false,
+ riseOffset: 250
+ },
+
+ initialize: function (latlng, options) {
+ L.setOptions(this, options);
+ this._latlng = L.latLng(latlng);
+ },
+
+ onAdd: function (map) {
+ this._map = map;
+
+ map.on('viewreset', this.update, this);
+
+ this._initIcon();
+ this.update();
+ this.fire('add');
+
+ if (map.options.zoomAnimation && map.options.markerZoomAnimation) {
+ map.on('zoomanim', this._animateZoom, this);
+ }
+ },
+
+ addTo: function (map) {
+ map.addLayer(this);
+ return this;
+ },
+
+ onRemove: function (map) {
+ if (this.dragging) {
+ this.dragging.disable();
+ }
+
+ this._removeIcon();
+ this._removeShadow();
+
+ this.fire('remove');
+
+ map.off({
+ 'viewreset': this.update,
+ 'zoomanim': this._animateZoom
+ }, this);
+
+ this._map = null;
+ },
+
+ getLatLng: function () {
+ return this._latlng;
+ },
+
+ setLatLng: function (latlng) {
+ this._latlng = L.latLng(latlng);
+
+ this.update();
+
+ return this.fire('move', { latlng: this._latlng });
+ },
+
+ setZIndexOffset: function (offset) {
+ this.options.zIndexOffset = offset;
+ this.update();
+
+ return this;
+ },
+
+ setIcon: function (icon) {
+
+ this.options.icon = icon;
+
+ if (this._map) {
+ this._initIcon();
+ this.update();
+ }
+
+ if (this._popup) {
+ this.bindPopup(this._popup);
+ }
+
+ return this;
+ },
+
+ update: function () {
+ if (this._icon) {
+ var pos = this._map.latLngToLayerPoint(this._latlng).round();
+ this._setPos(pos);
+ }
+
+ return this;
+ },
+
+ _initIcon: function () {
+ var options = this.options,
+ map = this._map,
+ animation = (map.options.zoomAnimation && map.options.markerZoomAnimation),
+ classToAdd = animation ? 'leaflet-zoom-animated' : 'leaflet-zoom-hide';
+
+ var icon = options.icon.createIcon(this._icon),
+ addIcon = false;
+
+ // if we're not reusing the icon, remove the old one and init new one
+ if (icon !== this._icon) {
+ if (this._icon) {
+ this._removeIcon();
+ }
+ addIcon = true;
+
+ if (options.title) {
+ icon.title = options.title;
+ }
+
+ if (options.alt) {
+ icon.alt = options.alt;
+ }
+ }
+
+ L.DomUtil.addClass(icon, classToAdd);
+
+ if (options.keyboard) {
+ icon.tabIndex = '0';
+ }
+
+ this._icon = icon;
+
+ this._initInteraction();
+
+ if (options.riseOnHover) {
+ L.DomEvent
+ .on(icon, 'mouseover', this._bringToFront, this)
+ .on(icon, 'mouseout', this._resetZIndex, this);
+ }
+
+ var newShadow = options.icon.createShadow(this._shadow),
+ addShadow = false;
+
+ if (newShadow !== this._shadow) {
+ this._removeShadow();
+ addShadow = true;
+ }
+
+ if (newShadow) {
+ L.DomUtil.addClass(newShadow, classToAdd);
+ }
+ this._shadow = newShadow;
+
+
+ if (options.opacity < 1) {
+ this._updateOpacity();
+ }
+
+
+ var panes = this._map._panes;
+
+ if (addIcon) {
+ panes.markerPane.appendChild(this._icon);
+ }
+
+ if (newShadow && addShadow) {
+ panes.shadowPane.appendChild(this._shadow);
+ }
+ },
+
+ _removeIcon: function () {
+ if (this.options.riseOnHover) {
+ L.DomEvent
+ .off(this._icon, 'mouseover', this._bringToFront)
+ .off(this._icon, 'mouseout', this._resetZIndex);
+ }
+
+ this._map._panes.markerPane.removeChild(this._icon);
+
+ this._icon = null;
+ },
+
+ _removeShadow: function () {
+ if (this._shadow) {
+ this._map._panes.shadowPane.removeChild(this._shadow);
+ }
+ this._shadow = null;
+ },
+
+ _setPos: function (pos) {
+ L.DomUtil.setPosition(this._icon, pos);
+
+ if (this._shadow) {
+ L.DomUtil.setPosition(this._shadow, pos);
+ }
+
+ this._zIndex = pos.y + this.options.zIndexOffset;
+
+ this._resetZIndex();
+ },
+
+ _updateZIndex: function (offset) {
+ this._icon.style.zIndex = this._zIndex + offset;
+ },
+
+ _animateZoom: function (opt) {
+ var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center).round();
+
+ this._setPos(pos);
+ },
+
+ _initInteraction: function () {
+
+ if (!this.options.clickable) { return; }
+
+ // TODO refactor into something shared with Map/Path/etc. to DRY it up
+
+ var icon = this._icon,
+ events = ['dblclick', 'mousedown', 'mouseover', 'mouseout', 'contextmenu'];
+
+ L.DomUtil.addClass(icon, 'leaflet-clickable');
+ L.DomEvent.on(icon, 'click', this._onMouseClick, this);
+ L.DomEvent.on(icon, 'keypress', this._onKeyPress, this);
+
+ for (var i = 0; i < events.length; i++) {
+ L.DomEvent.on(icon, events[i], this._fireMouseEvent, this);
+ }
+
+ if (L.Handler.MarkerDrag) {
+ this.dragging = new L.Handler.MarkerDrag(this);
+
+ if (this.options.draggable) {
+ this.dragging.enable();
+ }
+ }
+ },
+
+ _onMouseClick: function (e) {
+ var wasDragged = this.dragging && this.dragging.moved();
+
+ if (this.hasEventListeners(e.type) || wasDragged) {
+ L.DomEvent.stopPropagation(e);
+ }
+
+ if (wasDragged) { return; }
+
+ if ((!this.dragging || !this.dragging._enabled) && this._map.dragging && this._map.dragging.moved()) { return; }
+
+ this.fire(e.type, {
+ originalEvent: e,
+ latlng: this._latlng
+ });
+ },
+
+ _onKeyPress: function (e) {
+ if (e.keyCode === 13) {
+ this.fire('click', {
+ originalEvent: e,
+ latlng: this._latlng
+ });
+ }
+ },
+
+ _fireMouseEvent: function (e) {
+
+ this.fire(e.type, {
+ originalEvent: e,
+ latlng: this._latlng
+ });
+
+ // TODO proper custom event propagation
+ // this line will always be called if marker is in a FeatureGroup
+ if (e.type === 'contextmenu' && this.hasEventListeners(e.type)) {
+ L.DomEvent.preventDefault(e);
+ }
+ if (e.type !== 'mousedown') {
+ L.DomEvent.stopPropagation(e);
+ } else {
+ L.DomEvent.preventDefault(e);
+ }
+ },
+
+ setOpacity: function (opacity) {
+ this.options.opacity = opacity;
+ if (this._map) {
+ this._updateOpacity();
+ }
+
+ return this;
+ },
+
+ _updateOpacity: function () {
+ L.DomUtil.setOpacity(this._icon, this.options.opacity);
+ if (this._shadow) {
+ L.DomUtil.setOpacity(this._shadow, this.options.opacity);
+ }
+ },
+
+ _bringToFront: function () {
+ this._updateZIndex(this.options.riseOffset);
+ },
+
+ _resetZIndex: function () {
+ this._updateZIndex(0);
+ }
+});
+
+L.marker = function (latlng, options) {
+ return new L.Marker(latlng, options);
+};
+
+
+/*
+ * L.DivIcon is a lightweight HTML-based icon class (as opposed to the image-based L.Icon)
+ * to use with L.Marker.
+ */
+
+L.DivIcon = L.Icon.extend({
+ options: {
+ iconSize: [12, 12], // also can be set through CSS
+ /*
+ iconAnchor: (Point)
+ popupAnchor: (Point)
+ html: (String)
+ bgPos: (Point)
+ */
+ className: 'leaflet-div-icon',
+ html: false
+ },
+
+ createIcon: function (oldIcon) {
+ var div = (oldIcon && oldIcon.tagName === 'DIV') ? oldIcon : document.createElement('div'),
+ options = this.options;
+
+ if (options.html !== false) {
+ div.innerHTML = options.html;
+ } else {
+ div.innerHTML = '';
+ }
+
+ if (options.bgPos) {
+ div.style.backgroundPosition =
+ (-options.bgPos.x) + 'px ' + (-options.bgPos.y) + 'px';
+ }
+
+ this._setIconStyles(div, 'icon');
+ return div;
+ },
+
+ createShadow: function () {
+ return null;
+ }
+});
+
+L.divIcon = function (options) {
+ return new L.DivIcon(options);
+};
+
+
+/*
+ * L.Popup is used for displaying popups on the map.
+ */
+
+L.Map.mergeOptions({
+ closePopupOnClick: true
+});
+
+L.Popup = L.Class.extend({
+ includes: L.Mixin.Events,
+
+ options: {
+ minWidth: 50,
+ maxWidth: 300,
+ // maxHeight: null,
+ autoPan: true,
+ closeButton: true,
+ offset: [0, 7],
+ autoPanPadding: [5, 5],
+ // autoPanPaddingTopLeft: null,
+ // autoPanPaddingBottomRight: null,
+ keepInView: false,
+ className: '',
+ zoomAnimation: true
+ },
+
+ initialize: function (options, source) {
+ L.setOptions(this, options);
+
+ this._source = source;
+ this._animated = L.Browser.any3d && this.options.zoomAnimation;
+ this._isOpen = false;
+ },
+
+ onAdd: function (map) {
+ this._map = map;
+
+ if (!this._container) {
+ this._initLayout();
+ }
+
+ var animFade = map.options.fadeAnimation;
+
+ if (animFade) {
+ L.DomUtil.setOpacity(this._container, 0);
+ }
+ map._panes.popupPane.appendChild(this._container);
+
+ map.on(this._getEvents(), this);
+
+ this.update();
+
+ if (animFade) {
+ L.DomUtil.setOpacity(this._container, 1);
+ }
+
+ this.fire('open');
+
+ map.fire('popupopen', {popup: this});
+
+ if (this._source) {
+ this._source.fire('popupopen', {popup: this});
+ }
+ },
+
+ addTo: function (map) {
+ map.addLayer(this);
+ return this;
+ },
+
+ openOn: function (map) {
+ map.openPopup(this);
+ return this;
+ },
+
+ onRemove: function (map) {
+ map._panes.popupPane.removeChild(this._container);
+
+ L.Util.falseFn(this._container.offsetWidth); // force reflow
+
+ map.off(this._getEvents(), this);
+
+ if (map.options.fadeAnimation) {
+ L.DomUtil.setOpacity(this._container, 0);
+ }
+
+ this._map = null;
+
+ this.fire('close');
+
+ map.fire('popupclose', {popup: this});
+
+ if (this._source) {
+ this._source.fire('popupclose', {popup: this});
+ }
+ },
+
+ getLatLng: function () {
+ return this._latlng;
+ },
+
+ setLatLng: function (latlng) {
+ this._latlng = L.latLng(latlng);
+ if (this._map) {
+ this._updatePosition();
+ this._adjustPan();
+ }
+ return this;
+ },
+
+ getContent: function () {
+ return this._content;
+ },
+
+ setContent: function (content) {
+ this._content = content;
+ this.update();
+ return this;
+ },
+
+ update: function () {
+ if (!this._map) { return; }
+
+ this._container.style.visibility = 'hidden';
+
+ this._updateContent();
+ this._updateLayout();
+ this._updatePosition();
+
+ this._container.style.visibility = '';
+
+ this._adjustPan();
+ },
+
+ _getEvents: function () {
+ var events = {
+ viewreset: this._updatePosition
+ };
+
+ if (this._animated) {
+ events.zoomanim = this._zoomAnimation;
+ }
+ if ('closeOnClick' in this.options ? this.options.closeOnClick : this._map.options.closePopupOnClick) {
+ events.preclick = this._close;
+ }
+ if (this.options.keepInView) {
+ events.moveend = this._adjustPan;
+ }
+
+ return events;
+ },
+
+ _close: function () {
+ if (this._map) {
+ this._map.closePopup(this);
+ }
+ },
+
+ _initLayout: function () {
+ var prefix = 'leaflet-popup',
+ containerClass = prefix + ' ' + this.options.className + ' leaflet-zoom-' +
+ (this._animated ? 'animated' : 'hide'),
+ container = this._container = L.DomUtil.create('div', containerClass),
+ closeButton;
+
+ if (this.options.closeButton) {
+ closeButton = this._closeButton =
+ L.DomUtil.create('a', prefix + '-close-button', container);
+ closeButton.href = '#close';
+ closeButton.innerHTML = '×';
+ L.DomEvent.disableClickPropagation(closeButton);
+
+ L.DomEvent.on(closeButton, 'click', this._onCloseButtonClick, this);
+ }
+
+ var wrapper = this._wrapper =
+ L.DomUtil.create('div', prefix + '-content-wrapper', container);
+ L.DomEvent.disableClickPropagation(wrapper);
+
+ this._contentNode = L.DomUtil.create('div', prefix + '-content', wrapper);
+
+ L.DomEvent.disableScrollPropagation(this._contentNode);
+ L.DomEvent.on(wrapper, 'contextmenu', L.DomEvent.stopPropagation);
+
+ this._tipContainer = L.DomUtil.create('div', prefix + '-tip-container', container);
+ this._tip = L.DomUtil.create('div', prefix + '-tip', this._tipContainer);
+ },
+
+ _updateContent: function () {
+ if (!this._content) { return; }
+
+ if (typeof this._content === 'string') {
+ this._contentNode.innerHTML = this._content;
+ } else {
+ while (this._contentNode.hasChildNodes()) {
+ this._contentNode.removeChild(this._contentNode.firstChild);
+ }
+ this._contentNode.appendChild(this._content);
+ }
+ this.fire('contentupdate');
+ },
+
+ _updateLayout: function () {
+ var container = this._contentNode,
+ style = container.style;
+
+ style.width = '';
+ style.whiteSpace = 'nowrap';
+
+ var width = container.offsetWidth;
+ width = Math.min(width, this.options.maxWidth);
+ width = Math.max(width, this.options.minWidth);
+
+ style.width = (width + 1) + 'px';
+ style.whiteSpace = '';
+
+ style.height = '';
+
+ var height = container.offsetHeight,
+ maxHeight = this.options.maxHeight,
+ scrolledClass = 'leaflet-popup-scrolled';
+
+ if (maxHeight && height > maxHeight) {
+ style.height = maxHeight + 'px';
+ L.DomUtil.addClass(container, scrolledClass);
+ } else {
+ L.DomUtil.removeClass(container, scrolledClass);
+ }
+
+ this._containerWidth = this._container.offsetWidth;
+ },
+
+ _updatePosition: function () {
+ if (!this._map) { return; }
+
+ var pos = this._map.latLngToLayerPoint(this._latlng),
+ animated = this._animated,
+ offset = L.point(this.options.offset);
+
+ if (animated) {
+ L.DomUtil.setPosition(this._container, pos);
+ }
+
+ this._containerBottom = -offset.y - (animated ? 0 : pos.y);
+ this._containerLeft = -Math.round(this._containerWidth / 2) + offset.x + (animated ? 0 : pos.x);
+
+ // bottom position the popup in case the height of the popup changes (images loading etc)
+ this._container.style.bottom = this._containerBottom + 'px';
+ this._container.style.left = this._containerLeft + 'px';
+ },
+
+ _zoomAnimation: function (opt) {
+ var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center);
+
+ L.DomUtil.setPosition(this._container, pos);
+ },
+
+ _adjustPan: function () {
+ if (!this.options.autoPan) { return; }
+
+ var map = this._map,
+ containerHeight = this._container.offsetHeight,
+ containerWidth = this._containerWidth,
+
+ layerPos = new L.Point(this._containerLeft, -containerHeight - this._containerBottom);
+
+ if (this._animated) {
+ layerPos._add(L.DomUtil.getPosition(this._container));
+ }
+
+ var containerPos = map.layerPointToContainerPoint(layerPos),
+ padding = L.point(this.options.autoPanPadding),
+ paddingTL = L.point(this.options.autoPanPaddingTopLeft || padding),
+ paddingBR = L.point(this.options.autoPanPaddingBottomRight || padding),
+ size = map.getSize(),
+ dx = 0,
+ dy = 0;
+
+ if (containerPos.x + containerWidth + paddingBR.x > size.x) { // right
+ dx = containerPos.x + containerWidth - size.x + paddingBR.x;
+ }
+ if (containerPos.x - dx - paddingTL.x < 0) { // left
+ dx = containerPos.x - paddingTL.x;
+ }
+ if (containerPos.y + containerHeight + paddingBR.y > size.y) { // bottom
+ dy = containerPos.y + containerHeight - size.y + paddingBR.y;
+ }
+ if (containerPos.y - dy - paddingTL.y < 0) { // top
+ dy = containerPos.y - paddingTL.y;
+ }
+
+ if (dx || dy) {
+ map
+ .fire('autopanstart')
+ .panBy([dx, dy]);
+ }
+ },
+
+ _onCloseButtonClick: function (e) {
+ this._close();
+ L.DomEvent.stop(e);
+ }
+});
+
+L.popup = function (options, source) {
+ return new L.Popup(options, source);
+};
+
+
+L.Map.include({
+ openPopup: function (popup, latlng, options) { // (Popup) or (String || HTMLElement, LatLng[, Object])
+ this.closePopup();
+
+ if (!(popup instanceof L.Popup)) {
+ var content = popup;
+
+ popup = new L.Popup(options)
+ .setLatLng(latlng)
+ .setContent(content);
+ }
+ popup._isOpen = true;
+
+ this._popup = popup;
+ return this.addLayer(popup);
+ },
+
+ closePopup: function (popup) {
+ if (!popup || popup === this._popup) {
+ popup = this._popup;
+ this._popup = null;
+ }
+ if (popup) {
+ this.removeLayer(popup);
+ popup._isOpen = false;
+ }
+ return this;
+ }
+});
+
+
+/*
+ * Popup extension to L.Marker, adding popup-related methods.
+ */
+
+L.Marker.include({
+ openPopup: function () {
+ if (this._popup && this._map && !this._map.hasLayer(this._popup)) {
+ this._popup.setLatLng(this._latlng);
+ this._map.openPopup(this._popup);
+ }
+
+ return this;
+ },
+
+ closePopup: function () {
+ if (this._popup) {
+ this._popup._close();
+ }
+ return this;
+ },
+
+ togglePopup: function () {
+ if (this._popup) {
+ if (this._popup._isOpen) {
+ this.closePopup();
+ } else {
+ this.openPopup();
+ }
+ }
+ return this;
+ },
+
+ bindPopup: function (content, options) {
+ var anchor = L.point(this.options.icon.options.popupAnchor || [0, 0]);
+
+ anchor = anchor.add(L.Popup.prototype.options.offset);
+
+ if (options && options.offset) {
+ anchor = anchor.add(options.offset);
+ }
+
+ options = L.extend({offset: anchor}, options);
+
+ if (!this._popupHandlersAdded) {
+ this
+ .on('click', this.togglePopup, this)
+ .on('remove', this.closePopup, this)
+ .on('move', this._movePopup, this);
+ this._popupHandlersAdded = true;
+ }
+
+ if (content instanceof L.Popup) {
+ L.setOptions(content, options);
+ this._popup = content;
+ } else {
+ this._popup = new L.Popup(options, this)
+ .setContent(content);
+ }
+
+ return this;
+ },
+
+ setPopupContent: function (content) {
+ if (this._popup) {
+ this._popup.setContent(content);
+ }
+ return this;
+ },
+
+ unbindPopup: function () {
+ if (this._popup) {
+ this._popup = null;
+ this
+ .off('click', this.togglePopup, this)
+ .off('remove', this.closePopup, this)
+ .off('move', this._movePopup, this);
+ this._popupHandlersAdded = false;
+ }
+ return this;
+ },
+
+ getPopup: function () {
+ return this._popup;
+ },
+
+ _movePopup: function (e) {
+ this._popup.setLatLng(e.latlng);
+ }
+});
+
+
+/*
+ * L.LayerGroup is a class to combine several layers into one so that
+ * you can manipulate the group (e.g. add/remove it) as one layer.
+ */
+
+L.LayerGroup = L.Class.extend({
+ initialize: function (layers) {
+ this._layers = {};
+
+ var i, len;
+
+ if (layers) {
+ for (i = 0, len = layers.length; i < len; i++) {
+ this.addLayer(layers[i]);
+ }
+ }
+ },
+
+ addLayer: function (layer) {
+ var id = this.getLayerId(layer);
+
+ this._layers[id] = layer;
+
+ if (this._map) {
+ this._map.addLayer(layer);
+ }
+
+ return this;
+ },
+
+ removeLayer: function (layer) {
+ var id = layer in this._layers ? layer : this.getLayerId(layer);
+
+ if (this._map && this._layers[id]) {
+ this._map.removeLayer(this._layers[id]);
+ }
+
+ delete this._layers[id];
+
+ return this;
+ },
+
+ hasLayer: function (layer) {
+ if (!layer) { return false; }
+
+ return (layer in this._layers || this.getLayerId(layer) in this._layers);
+ },
+
+ clearLayers: function () {
+ this.eachLayer(this.removeLayer, this);
+ return this;
+ },
+
+ invoke: function (methodName) {
+ var args = Array.prototype.slice.call(arguments, 1),
+ i, layer;
+
+ for (i in this._layers) {
+ layer = this._layers[i];
+
+ if (layer[methodName]) {
+ layer[methodName].apply(layer, args);
+ }
+ }
+
+ return this;
+ },
+
+ onAdd: function (map) {
+ this._map = map;
+ this.eachLayer(map.addLayer, map);
+ },
+
+ onRemove: function (map) {
+ this.eachLayer(map.removeLayer, map);
+ this._map = null;
+ },
+
+ addTo: function (map) {
+ map.addLayer(this);
+ return this;
+ },
+
+ eachLayer: function (method, context) {
+ for (var i in this._layers) {
+ method.call(context, this._layers[i]);
+ }
+ return this;
+ },
+
+ getLayer: function (id) {
+ return this._layers[id];
+ },
+
+ getLayers: function () {
+ var layers = [];
+
+ for (var i in this._layers) {
+ layers.push(this._layers[i]);
+ }
+ return layers;
+ },
+
+ setZIndex: function (zIndex) {
+ return this.invoke('setZIndex', zIndex);
+ },
+
+ getLayerId: function (layer) {
+ return L.stamp(layer);
+ }
+});
+
+L.layerGroup = function (layers) {
+ return new L.LayerGroup(layers);
+};
+
+
+/*
+ * L.FeatureGroup extends L.LayerGroup by introducing mouse events and additional methods
+ * shared between a group of interactive layers (like vectors or markers).
+ */
+
+L.FeatureGroup = L.LayerGroup.extend({
+ includes: L.Mixin.Events,
+
+ statics: {
+ EVENTS: 'click dblclick mouseover mouseout mousemove contextmenu popupopen popupclose'
+ },
+
+ addLayer: function (layer) {
+ if (this.hasLayer(layer)) {
+ return this;
+ }
+
+ if ('on' in layer) {
+ layer.on(L.FeatureGroup.EVENTS, this._propagateEvent, this);
+ }
+
+ L.LayerGroup.prototype.addLayer.call(this, layer);
+
+ if (this._popupContent && layer.bindPopup) {
+ layer.bindPopup(this._popupContent, this._popupOptions);
+ }
+
+ return this.fire('layeradd', {layer: layer});
+ },
+
+ removeLayer: function (layer) {
+ if (!this.hasLayer(layer)) {
+ return this;
+ }
+ if (layer in this._layers) {
+ layer = this._layers[layer];
+ }
+
+ layer.off(L.FeatureGroup.EVENTS, this._propagateEvent, this);
+
+ L.LayerGroup.prototype.removeLayer.call(this, layer);
+
+ if (this._popupContent) {
+ this.invoke('unbindPopup');
+ }
+
+ return this.fire('layerremove', {layer: layer});
+ },
+
+ bindPopup: function (content, options) {
+ this._popupContent = content;
+ this._popupOptions = options;
+ return this.invoke('bindPopup', content, options);
+ },
+
+ openPopup: function (latlng) {
+ // open popup on the first layer
+ for (var id in this._layers) {
+ this._layers[id].openPopup(latlng);
+ break;
+ }
+ return this;
+ },
+
+ setStyle: function (style) {
+ return this.invoke('setStyle', style);
+ },
+
+ bringToFront: function () {
+ return this.invoke('bringToFront');
+ },
+
+ bringToBack: function () {
+ return this.invoke('bringToBack');
+ },
+
+ getBounds: function () {
+ var bounds = new L.LatLngBounds();
+
+ this.eachLayer(function (layer) {
+ bounds.extend(layer instanceof L.Marker ? layer.getLatLng() : layer.getBounds());
+ });
+
+ return bounds;
+ },
+
+ _propagateEvent: function (e) {
+ e = L.extend({
+ layer: e.target,
+ target: this
+ }, e);
+ this.fire(e.type, e);
+ }
+});
+
+L.featureGroup = function (layers) {
+ return new L.FeatureGroup(layers);
+};
+
+
+/*
+ * L.Path is a base class for rendering vector paths on a map. Inherited by Polyline, Circle, etc.
+ */
+
+L.Path = L.Class.extend({
+ includes: [L.Mixin.Events],
+
+ statics: {
+ // how much to extend the clip area around the map view
+ // (relative to its size, e.g. 0.5 is half the screen in each direction)
+ // set it so that SVG element doesn't exceed 1280px (vectors flicker on dragend if it is)
+ CLIP_PADDING: (function () {
+ var max = L.Browser.mobile ? 1280 : 2000,
+ target = (max / Math.max(window.outerWidth, window.outerHeight) - 1) / 2;
+ return Math.max(0, Math.min(0.5, target));
+ })()
+ },
+
+ options: {
+ stroke: true,
+ color: '#0033ff',
+ dashArray: null,
+ lineCap: null,
+ lineJoin: null,
+ weight: 5,
+ opacity: 0.5,
+
+ fill: false,
+ fillColor: null, //same as color by default
+ fillOpacity: 0.2,
+
+ clickable: true
+ },
+
+ initialize: function (options) {
+ L.setOptions(this, options);
+ },
+
+ onAdd: function (map) {
+ this._map = map;
+
+ if (!this._container) {
+ this._initElements();
+ this._initEvents();
+ }
+
+ this.projectLatlngs();
+ this._updatePath();
+
+ if (this._container) {
+ this._map._pathRoot.appendChild(this._container);
+ }
+
+ this.fire('add');
+
+ map.on({
+ 'viewreset': this.projectLatlngs,
+ 'moveend': this._updatePath
+ }, this);
+ },
+
+ addTo: function (map) {
+ map.addLayer(this);
+ return this;
+ },
+
+ onRemove: function (map) {
+ map._pathRoot.removeChild(this._container);
+
+ // Need to fire remove event before we set _map to null as the event hooks might need the object
+ this.fire('remove');
+ this._map = null;
+
+ if (L.Browser.vml) {
+ this._container = null;
+ this._stroke = null;
+ this._fill = null;
+ }
+
+ map.off({
+ 'viewreset': this.projectLatlngs,
+ 'moveend': this._updatePath
+ }, this);
+ },
+
+ projectLatlngs: function () {
+ // do all projection stuff here
+ },
+
+ setStyle: function (style) {
+ L.setOptions(this, style);
+
+ if (this._container) {
+ this._updateStyle();
+ }
+
+ return this;
+ },
+
+ redraw: function () {
+ if (this._map) {
+ this.projectLatlngs();
+ this._updatePath();
+ }
+ return this;
+ }
+});
+
+L.Map.include({
+ _updatePathViewport: function () {
+ var p = L.Path.CLIP_PADDING,
+ size = this.getSize(),
+ panePos = L.DomUtil.getPosition(this._mapPane),
+ min = panePos.multiplyBy(-1)._subtract(size.multiplyBy(p)._round()),
+ max = min.add(size.multiplyBy(1 + p * 2)._round());
+
+ this._pathViewport = new L.Bounds(min, max);
+ }
+});
+
+
+/*
+ * Extends L.Path with SVG-specific rendering code.
+ */
+
+L.Path.SVG_NS = 'http://www.w3.org/2000/svg';
+
+L.Browser.svg = !!(document.createElementNS && document.createElementNS(L.Path.SVG_NS, 'svg').createSVGRect);
+
+L.Path = L.Path.extend({
+ statics: {
+ SVG: L.Browser.svg
+ },
+
+ bringToFront: function () {
+ var root = this._map._pathRoot,
+ path = this._container;
+
+ if (path && root.lastChild !== path) {
+ root.appendChild(path);
+ }
+ return this;
+ },
+
+ bringToBack: function () {
+ var root = this._map._pathRoot,
+ path = this._container,
+ first = root.firstChild;
+
+ if (path && first !== path) {
+ root.insertBefore(path, first);
+ }
+ return this;
+ },
+
+ getPathString: function () {
+ // form path string here
+ },
+
+ _createElement: function (name) {
+ return document.createElementNS(L.Path.SVG_NS, name);
+ },
+
+ _initElements: function () {
+ this._map._initPathRoot();
+ this._initPath();
+ this._initStyle();
+ },
+
+ _initPath: function () {
+ this._container = this._createElement('g');
+
+ this._path = this._createElement('path');
+
+ if (this.options.className) {
+ L.DomUtil.addClass(this._path, this.options.className);
+ }
+
+ this._container.appendChild(this._path);
+ },
+
+ _initStyle: function () {
+ if (this.options.stroke) {
+ this._path.setAttribute('stroke-linejoin', 'round');
+ this._path.setAttribute('stroke-linecap', 'round');
+ }
+ if (this.options.fill) {
+ this._path.setAttribute('fill-rule', 'evenodd');
+ }
+ if (this.options.pointerEvents) {
+ this._path.setAttribute('pointer-events', this.options.pointerEvents);
+ }
+ if (!this.options.clickable && !this.options.pointerEvents) {
+ this._path.setAttribute('pointer-events', 'none');
+ }
+ this._updateStyle();
+ },
+
+ _updateStyle: function () {
+ if (this.options.stroke) {
+ this._path.setAttribute('stroke', this.options.color);
+ this._path.setAttribute('stroke-opacity', this.options.opacity);
+ this._path.setAttribute('stroke-width', this.options.weight);
+ if (this.options.dashArray) {
+ this._path.setAttribute('stroke-dasharray', this.options.dashArray);
+ } else {
+ this._path.removeAttribute('stroke-dasharray');
+ }
+ if (this.options.lineCap) {
+ this._path.setAttribute('stroke-linecap', this.options.lineCap);
+ }
+ if (this.options.lineJoin) {
+ this._path.setAttribute('stroke-linejoin', this.options.lineJoin);
+ }
+ } else {
+ this._path.setAttribute('stroke', 'none');
+ }
+ if (this.options.fill) {
+ this._path.setAttribute('fill', this.options.fillColor || this.options.color);
+ this._path.setAttribute('fill-opacity', this.options.fillOpacity);
+ } else {
+ this._path.setAttribute('fill', 'none');
+ }
+ },
+
+ _updatePath: function () {
+ var str = this.getPathString();
+ if (!str) {
+ // fix webkit empty string parsing bug
+ str = 'M0 0';
+ }
+ this._path.setAttribute('d', str);
+ },
+
+ // TODO remove duplication with L.Map
+ _initEvents: function () {
+ if (this.options.clickable) {
+ if (L.Browser.svg || !L.Browser.vml) {
+ L.DomUtil.addClass(this._path, 'leaflet-clickable');
+ }
+
+ L.DomEvent.on(this._container, 'click', this._onMouseClick, this);
+
+ var events = ['dblclick', 'mousedown', 'mouseover',
+ 'mouseout', 'mousemove', 'contextmenu'];
+ for (var i = 0; i < events.length; i++) {
+ L.DomEvent.on(this._container, events[i], this._fireMouseEvent, this);
+ }
+ }
+ },
+
+ _onMouseClick: function (e) {
+ if (this._map.dragging && this._map.dragging.moved()) { return; }
+
+ this._fireMouseEvent(e);
+ },
+
+ _fireMouseEvent: function (e) {
+ if (!this.hasEventListeners(e.type)) { return; }
+
+ var map = this._map,
+ containerPoint = map.mouseEventToContainerPoint(e),
+ layerPoint = map.containerPointToLayerPoint(containerPoint),
+ latlng = map.layerPointToLatLng(layerPoint);
+
+ this.fire(e.type, {
+ latlng: latlng,
+ layerPoint: layerPoint,
+ containerPoint: containerPoint,
+ originalEvent: e
+ });
+
+ if (e.type === 'contextmenu') {
+ L.DomEvent.preventDefault(e);
+ }
+ if (e.type !== 'mousemove') {
+ L.DomEvent.stopPropagation(e);
+ }
+ }
+});
+
+L.Map.include({
+ _initPathRoot: function () {
+ if (!this._pathRoot) {
+ this._pathRoot = L.Path.prototype._createElement('svg');
+ this._panes.overlayPane.appendChild(this._pathRoot);
+
+ if (this.options.zoomAnimation && L.Browser.any3d) {
+ L.DomUtil.addClass(this._pathRoot, 'leaflet-zoom-animated');
+
+ this.on({
+ 'zoomanim': this._animatePathZoom,
+ 'zoomend': this._endPathZoom
+ });
+ } else {
+ L.DomUtil.addClass(this._pathRoot, 'leaflet-zoom-hide');
+ }
+
+ this.on('moveend', this._updateSvgViewport);
+ this._updateSvgViewport();
+ }
+ },
+
+ _animatePathZoom: function (e) {
+ var scale = this.getZoomScale(e.zoom),
+ offset = this._getCenterOffset(e.center)._multiplyBy(-scale)._add(this._pathViewport.min);
+
+ this._pathRoot.style[L.DomUtil.TRANSFORM] =
+ L.DomUtil.getTranslateString(offset) + ' scale(' + scale + ') ';
+
+ this._pathZooming = true;
+ },
+
+ _endPathZoom: function () {
+ this._pathZooming = false;
+ },
+
+ _updateSvgViewport: function () {
+
+ if (this._pathZooming) {
+ // Do not update SVGs while a zoom animation is going on otherwise the animation will break.
+ // When the zoom animation ends we will be updated again anyway
+ // This fixes the case where you do a momentum move and zoom while the move is still ongoing.
+ return;
+ }
+
+ this._updatePathViewport();
+
+ var vp = this._pathViewport,
+ min = vp.min,
+ max = vp.max,
+ width = max.x - min.x,
+ height = max.y - min.y,
+ root = this._pathRoot,
+ pane = this._panes.overlayPane;
+
+ // Hack to make flicker on drag end on mobile webkit less irritating
+ if (L.Browser.mobileWebkit) {
+ pane.removeChild(root);
+ }
+
+ L.DomUtil.setPosition(root, min);
+ root.setAttribute('width', width);
+ root.setAttribute('height', height);
+ root.setAttribute('viewBox', [min.x, min.y, width, height].join(' '));
+
+ if (L.Browser.mobileWebkit) {
+ pane.appendChild(root);
+ }
+ }
+});
+
+
+/*
+ * Popup extension to L.Path (polylines, polygons, circles), adding popup-related methods.
+ */
+
+L.Path.include({
+
+ bindPopup: function (content, options) {
+
+ if (content instanceof L.Popup) {
+ this._popup = content;
+ } else {
+ if (!this._popup || options) {
+ this._popup = new L.Popup(options, this);
+ }
+ this._popup.setContent(content);
+ }
+
+ if (!this._popupHandlersAdded) {
+ this
+ .on('click', this._openPopup, this)
+ .on('remove', this.closePopup, this);
+
+ this._popupHandlersAdded = true;
+ }
+
+ return this;
+ },
+
+ unbindPopup: function () {
+ if (this._popup) {
+ this._popup = null;
+ this
+ .off('click', this._openPopup)
+ .off('remove', this.closePopup);
+
+ this._popupHandlersAdded = false;
+ }
+ return this;
+ },
+
+ openPopup: function (latlng) {
+
+ if (this._popup) {
+ // open the popup from one of the path's points if not specified
+ latlng = latlng || this._latlng ||
+ this._latlngs[Math.floor(this._latlngs.length / 2)];
+
+ this._openPopup({latlng: latlng});
+ }
+
+ return this;
+ },
+
+ closePopup: function () {
+ if (this._popup) {
+ this._popup._close();
+ }
+ return this;
+ },
+
+ _openPopup: function (e) {
+ this._popup.setLatLng(e.latlng);
+ this._map.openPopup(this._popup);
+ }
+});
+
+
+/*
+ * Vector rendering for IE6-8 through VML.
+ * Thanks to Dmitry Baranovsky and his Raphael library for inspiration!
+ */
+
+L.Browser.vml = !L.Browser.svg && (function () {
+ try {
+ var div = document.createElement('div');
+ div.innerHTML = ' ';
+
+ var shape = div.firstChild;
+ shape.style.behavior = 'url(#default#VML)';
+
+ return shape && (typeof shape.adj === 'object');
+
+ } catch (e) {
+ return false;
+ }
+}());
+
+L.Path = L.Browser.svg || !L.Browser.vml ? L.Path : L.Path.extend({
+ statics: {
+ VML: true,
+ CLIP_PADDING: 0.02
+ },
+
+ _createElement: (function () {
+ try {
+ document.namespaces.add('lvml', 'urn:schemas-microsoft-com:vml');
+ return function (name) {
+ return document.createElement('');
+ };
+ } catch (e) {
+ return function (name) {
+ return document.createElement(
+ '<' + name + ' xmlns="urn:schemas-microsoft.com:vml" class="lvml">');
+ };
+ }
+ }()),
+
+ _initPath: function () {
+ var container = this._container = this._createElement('shape');
+
+ L.DomUtil.addClass(container, 'leaflet-vml-shape' +
+ (this.options.className ? ' ' + this.options.className : ''));
+
+ if (this.options.clickable) {
+ L.DomUtil.addClass(container, 'leaflet-clickable');
+ }
+
+ container.coordsize = '1 1';
+
+ this._path = this._createElement('path');
+ container.appendChild(this._path);
+
+ this._map._pathRoot.appendChild(container);
+ },
+
+ _initStyle: function () {
+ this._updateStyle();
+ },
+
+ _updateStyle: function () {
+ var stroke = this._stroke,
+ fill = this._fill,
+ options = this.options,
+ container = this._container;
+
+ container.stroked = options.stroke;
+ container.filled = options.fill;
+
+ if (options.stroke) {
+ if (!stroke) {
+ stroke = this._stroke = this._createElement('stroke');
+ stroke.endcap = 'round';
+ container.appendChild(stroke);
+ }
+ stroke.weight = options.weight + 'px';
+ stroke.color = options.color;
+ stroke.opacity = options.opacity;
+
+ if (options.dashArray) {
+ stroke.dashStyle = L.Util.isArray(options.dashArray) ?
+ options.dashArray.join(' ') :
+ options.dashArray.replace(/( *, *)/g, ' ');
+ } else {
+ stroke.dashStyle = '';
+ }
+ if (options.lineCap) {
+ stroke.endcap = options.lineCap.replace('butt', 'flat');
+ }
+ if (options.lineJoin) {
+ stroke.joinstyle = options.lineJoin;
+ }
+
+ } else if (stroke) {
+ container.removeChild(stroke);
+ this._stroke = null;
+ }
+
+ if (options.fill) {
+ if (!fill) {
+ fill = this._fill = this._createElement('fill');
+ container.appendChild(fill);
+ }
+ fill.color = options.fillColor || options.color;
+ fill.opacity = options.fillOpacity;
+
+ } else if (fill) {
+ container.removeChild(fill);
+ this._fill = null;
+ }
+ },
+
+ _updatePath: function () {
+ var style = this._container.style;
+
+ style.display = 'none';
+ this._path.v = this.getPathString() + ' '; // the space fixes IE empty path string bug
+ style.display = '';
+ }
+});
+
+L.Map.include(L.Browser.svg || !L.Browser.vml ? {} : {
+ _initPathRoot: function () {
+ if (this._pathRoot) { return; }
+
+ var root = this._pathRoot = document.createElement('div');
+ root.className = 'leaflet-vml-container';
+ this._panes.overlayPane.appendChild(root);
+
+ this.on('moveend', this._updatePathViewport);
+ this._updatePathViewport();
+ }
+});
+
+
+/*
+ * Vector rendering for all browsers that support canvas.
+ */
+
+L.Browser.canvas = (function () {
+ return !!document.createElement('canvas').getContext;
+}());
+
+L.Path = (L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? L.Path : L.Path.extend({
+ statics: {
+ //CLIP_PADDING: 0.02, // not sure if there's a need to set it to a small value
+ CANVAS: true,
+ SVG: false
+ },
+
+ redraw: function () {
+ if (this._map) {
+ this.projectLatlngs();
+ this._requestUpdate();
+ }
+ return this;
+ },
+
+ setStyle: function (style) {
+ L.setOptions(this, style);
+
+ if (this._map) {
+ this._updateStyle();
+ this._requestUpdate();
+ }
+ return this;
+ },
+
+ onRemove: function (map) {
+ map
+ .off('viewreset', this.projectLatlngs, this)
+ .off('moveend', this._updatePath, this);
+
+ if (this.options.clickable) {
+ this._map.off('click', this._onClick, this);
+ this._map.off('mousemove', this._onMouseMove, this);
+ }
+
+ this._requestUpdate();
+
+ this._map = null;
+ },
+
+ _requestUpdate: function () {
+ if (this._map && !L.Path._updateRequest) {
+ L.Path._updateRequest = L.Util.requestAnimFrame(this._fireMapMoveEnd, this._map);
+ }
+ },
+
+ _fireMapMoveEnd: function () {
+ L.Path._updateRequest = null;
+ this.fire('moveend');
+ },
+
+ _initElements: function () {
+ this._map._initPathRoot();
+ this._ctx = this._map._canvasCtx;
+ },
+
+ _updateStyle: function () {
+ var options = this.options;
+
+ if (options.stroke) {
+ this._ctx.lineWidth = options.weight;
+ this._ctx.strokeStyle = options.color;
+ }
+ if (options.fill) {
+ this._ctx.fillStyle = options.fillColor || options.color;
+ }
+ },
+
+ _drawPath: function () {
+ var i, j, len, len2, point, drawMethod;
+
+ this._ctx.beginPath();
+
+ for (i = 0, len = this._parts.length; i < len; i++) {
+ for (j = 0, len2 = this._parts[i].length; j < len2; j++) {
+ point = this._parts[i][j];
+ drawMethod = (j === 0 ? 'move' : 'line') + 'To';
+
+ this._ctx[drawMethod](point.x, point.y);
+ }
+ // TODO refactor ugly hack
+ if (this instanceof L.Polygon) {
+ this._ctx.closePath();
+ }
+ }
+ },
+
+ _checkIfEmpty: function () {
+ return !this._parts.length;
+ },
+
+ _updatePath: function () {
+ if (this._checkIfEmpty()) { return; }
+
+ var ctx = this._ctx,
+ options = this.options;
+
+ this._drawPath();
+ ctx.save();
+ this._updateStyle();
+
+ if (options.fill) {
+ ctx.globalAlpha = options.fillOpacity;
+ ctx.fill();
+ }
+
+ if (options.stroke) {
+ ctx.globalAlpha = options.opacity;
+ ctx.stroke();
+ }
+
+ ctx.restore();
+
+ // TODO optimization: 1 fill/stroke for all features with equal style instead of 1 for each feature
+ },
+
+ _initEvents: function () {
+ if (this.options.clickable) {
+ // TODO dblclick
+ this._map.on('mousemove', this._onMouseMove, this);
+ this._map.on('click', this._onClick, this);
+ }
+ },
+
+ _onClick: function (e) {
+ if (this._containsPoint(e.layerPoint)) {
+ this.fire('click', e);
+ }
+ },
+
+ _onMouseMove: function (e) {
+ if (!this._map || this._map._animatingZoom) { return; }
+
+ // TODO don't do on each move
+ if (this._containsPoint(e.layerPoint)) {
+ this._ctx.canvas.style.cursor = 'pointer';
+ this._mouseInside = true;
+ this.fire('mouseover', e);
+
+ } else if (this._mouseInside) {
+ this._ctx.canvas.style.cursor = '';
+ this._mouseInside = false;
+ this.fire('mouseout', e);
+ }
+ }
+});
+
+L.Map.include((L.Path.SVG && !window.L_PREFER_CANVAS) || !L.Browser.canvas ? {} : {
+ _initPathRoot: function () {
+ var root = this._pathRoot,
+ ctx;
+
+ if (!root) {
+ root = this._pathRoot = document.createElement('canvas');
+ root.style.position = 'absolute';
+ ctx = this._canvasCtx = root.getContext('2d');
+
+ ctx.lineCap = 'round';
+ ctx.lineJoin = 'round';
+
+ this._panes.overlayPane.appendChild(root);
+
+ if (this.options.zoomAnimation) {
+ this._pathRoot.className = 'leaflet-zoom-animated';
+ this.on('zoomanim', this._animatePathZoom);
+ this.on('zoomend', this._endPathZoom);
+ }
+ this.on('moveend', this._updateCanvasViewport);
+ this._updateCanvasViewport();
+ }
+ },
+
+ _updateCanvasViewport: function () {
+ // don't redraw while zooming. See _updateSvgViewport for more details
+ if (this._pathZooming) { return; }
+ this._updatePathViewport();
+
+ var vp = this._pathViewport,
+ min = vp.min,
+ size = vp.max.subtract(min),
+ root = this._pathRoot;
+
+ //TODO check if this works properly on mobile webkit
+ L.DomUtil.setPosition(root, min);
+ root.width = size.x;
+ root.height = size.y;
+ root.getContext('2d').translate(-min.x, -min.y);
+ }
+});
+
+
+/*
+ * L.LineUtil contains different utility functions for line segments
+ * and polylines (clipping, simplification, distances, etc.)
+ */
+
+/*jshint bitwise:false */ // allow bitwise operations for this file
+
+L.LineUtil = {
+
+ // Simplify polyline with vertex reduction and Douglas-Peucker simplification.
+ // Improves rendering performance dramatically by lessening the number of points to draw.
+
+ simplify: function (/*Point[]*/ points, /*Number*/ tolerance) {
+ if (!tolerance || !points.length) {
+ return points.slice();
+ }
+
+ var sqTolerance = tolerance * tolerance;
+
+ // stage 1: vertex reduction
+ points = this._reducePoints(points, sqTolerance);
+
+ // stage 2: Douglas-Peucker simplification
+ points = this._simplifyDP(points, sqTolerance);
+
+ return points;
+ },
+
+ // distance from a point to a segment between two points
+ pointToSegmentDistance: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2) {
+ return Math.sqrt(this._sqClosestPointOnSegment(p, p1, p2, true));
+ },
+
+ closestPointOnSegment: function (/*Point*/ p, /*Point*/ p1, /*Point*/ p2) {
+ return this._sqClosestPointOnSegment(p, p1, p2);
+ },
+
+ // Douglas-Peucker simplification, see http://en.wikipedia.org/wiki/Douglas-Peucker_algorithm
+ _simplifyDP: function (points, sqTolerance) {
+
+ var len = points.length,
+ ArrayConstructor = typeof Uint8Array !== undefined + '' ? Uint8Array : Array,
+ markers = new ArrayConstructor(len);
+
+ markers[0] = markers[len - 1] = 1;
+
+ this._simplifyDPStep(points, markers, sqTolerance, 0, len - 1);
+
+ var i,
+ newPoints = [];
+
+ for (i = 0; i < len; i++) {
+ if (markers[i]) {
+ newPoints.push(points[i]);
+ }
+ }
+
+ return newPoints;
+ },
+
+ _simplifyDPStep: function (points, markers, sqTolerance, first, last) {
+
+ var maxSqDist = 0,
+ index, i, sqDist;
+
+ for (i = first + 1; i <= last - 1; i++) {
+ sqDist = this._sqClosestPointOnSegment(points[i], points[first], points[last], true);
+
+ if (sqDist > maxSqDist) {
+ index = i;
+ maxSqDist = sqDist;
+ }
+ }
+
+ if (maxSqDist > sqTolerance) {
+ markers[index] = 1;
+
+ this._simplifyDPStep(points, markers, sqTolerance, first, index);
+ this._simplifyDPStep(points, markers, sqTolerance, index, last);
+ }
+ },
+
+ // reduce points that are too close to each other to a single point
+ _reducePoints: function (points, sqTolerance) {
+ var reducedPoints = [points[0]];
+
+ for (var i = 1, prev = 0, len = points.length; i < len; i++) {
+ if (this._sqDist(points[i], points[prev]) > sqTolerance) {
+ reducedPoints.push(points[i]);
+ prev = i;
+ }
+ }
+ if (prev < len - 1) {
+ reducedPoints.push(points[len - 1]);
+ }
+ return reducedPoints;
+ },
+
+ // Cohen-Sutherland line clipping algorithm.
+ // Used to avoid rendering parts of a polyline that are not currently visible.
+
+ clipSegment: function (a, b, bounds, useLastCode) {
+ var codeA = useLastCode ? this._lastCode : this._getBitCode(a, bounds),
+ codeB = this._getBitCode(b, bounds),
+
+ codeOut, p, newCode;
+
+ // save 2nd code to avoid calculating it on the next segment
+ this._lastCode = codeB;
+
+ while (true) {
+ // if a,b is inside the clip window (trivial accept)
+ if (!(codeA | codeB)) {
+ return [a, b];
+ // if a,b is outside the clip window (trivial reject)
+ } else if (codeA & codeB) {
+ return false;
+ // other cases
+ } else {
+ codeOut = codeA || codeB;
+ p = this._getEdgeIntersection(a, b, codeOut, bounds);
+ newCode = this._getBitCode(p, bounds);
+
+ if (codeOut === codeA) {
+ a = p;
+ codeA = newCode;
+ } else {
+ b = p;
+ codeB = newCode;
+ }
+ }
+ }
+ },
+
+ _getEdgeIntersection: function (a, b, code, bounds) {
+ var dx = b.x - a.x,
+ dy = b.y - a.y,
+ min = bounds.min,
+ max = bounds.max;
+
+ if (code & 8) { // top
+ return new L.Point(a.x + dx * (max.y - a.y) / dy, max.y);
+ } else if (code & 4) { // bottom
+ return new L.Point(a.x + dx * (min.y - a.y) / dy, min.y);
+ } else if (code & 2) { // right
+ return new L.Point(max.x, a.y + dy * (max.x - a.x) / dx);
+ } else if (code & 1) { // left
+ return new L.Point(min.x, a.y + dy * (min.x - a.x) / dx);
+ }
+ },
+
+ _getBitCode: function (/*Point*/ p, bounds) {
+ var code = 0;
+
+ if (p.x < bounds.min.x) { // left
+ code |= 1;
+ } else if (p.x > bounds.max.x) { // right
+ code |= 2;
+ }
+ if (p.y < bounds.min.y) { // bottom
+ code |= 4;
+ } else if (p.y > bounds.max.y) { // top
+ code |= 8;
+ }
+
+ return code;
+ },
+
+ // square distance (to avoid unnecessary Math.sqrt calls)
+ _sqDist: function (p1, p2) {
+ var dx = p2.x - p1.x,
+ dy = p2.y - p1.y;
+ return dx * dx + dy * dy;
+ },
+
+ // return closest point on segment or distance to that point
+ _sqClosestPointOnSegment: function (p, p1, p2, sqDist) {
+ var x = p1.x,
+ y = p1.y,
+ dx = p2.x - x,
+ dy = p2.y - y,
+ dot = dx * dx + dy * dy,
+ t;
+
+ if (dot > 0) {
+ t = ((p.x - x) * dx + (p.y - y) * dy) / dot;
+
+ if (t > 1) {
+ x = p2.x;
+ y = p2.y;
+ } else if (t > 0) {
+ x += dx * t;
+ y += dy * t;
+ }
+ }
+
+ dx = p.x - x;
+ dy = p.y - y;
+
+ return sqDist ? dx * dx + dy * dy : new L.Point(x, y);
+ }
+};
+
+
+/*
+ * L.Polyline is used to display polylines on a map.
+ */
+
+L.Polyline = L.Path.extend({
+ initialize: function (latlngs, options) {
+ L.Path.prototype.initialize.call(this, options);
+
+ this._latlngs = this._convertLatLngs(latlngs);
+ },
+
+ options: {
+ // how much to simplify the polyline on each zoom level
+ // more = better performance and smoother look, less = more accurate
+ smoothFactor: 1.0,
+ noClip: false
+ },
+
+ projectLatlngs: function () {
+ this._originalPoints = [];
+
+ for (var i = 0, len = this._latlngs.length; i < len; i++) {
+ this._originalPoints[i] = this._map.latLngToLayerPoint(this._latlngs[i]);
+ }
+ },
+
+ getPathString: function () {
+ for (var i = 0, len = this._parts.length, str = ''; i < len; i++) {
+ str += this._getPathPartStr(this._parts[i]);
+ }
+ return str;
+ },
+
+ getLatLngs: function () {
+ return this._latlngs;
+ },
+
+ setLatLngs: function (latlngs) {
+ this._latlngs = this._convertLatLngs(latlngs);
+ return this.redraw();
+ },
+
+ addLatLng: function (latlng) {
+ this._latlngs.push(L.latLng(latlng));
+ return this.redraw();
+ },
+
+ spliceLatLngs: function () { // (Number index, Number howMany)
+ var removed = [].splice.apply(this._latlngs, arguments);
+ this._convertLatLngs(this._latlngs, true);
+ this.redraw();
+ return removed;
+ },
+
+ closestLayerPoint: function (p) {
+ var minDistance = Infinity, parts = this._parts, p1, p2, minPoint = null;
+
+ for (var j = 0, jLen = parts.length; j < jLen; j++) {
+ var points = parts[j];
+ for (var i = 1, len = points.length; i < len; i++) {
+ p1 = points[i - 1];
+ p2 = points[i];
+ var sqDist = L.LineUtil._sqClosestPointOnSegment(p, p1, p2, true);
+ if (sqDist < minDistance) {
+ minDistance = sqDist;
+ minPoint = L.LineUtil._sqClosestPointOnSegment(p, p1, p2);
+ }
+ }
+ }
+ if (minPoint) {
+ minPoint.distance = Math.sqrt(minDistance);
+ }
+ return minPoint;
+ },
+
+ getBounds: function () {
+ return new L.LatLngBounds(this.getLatLngs());
+ },
+
+ _convertLatLngs: function (latlngs, overwrite) {
+ var i, len, target = overwrite ? latlngs : [];
+
+ for (i = 0, len = latlngs.length; i < len; i++) {
+ if (L.Util.isArray(latlngs[i]) && typeof latlngs[i][0] !== 'number') {
+ return;
+ }
+ target[i] = L.latLng(latlngs[i]);
+ }
+ return target;
+ },
+
+ _initEvents: function () {
+ L.Path.prototype._initEvents.call(this);
+ },
+
+ _getPathPartStr: function (points) {
+ var round = L.Path.VML;
+
+ for (var j = 0, len2 = points.length, str = '', p; j < len2; j++) {
+ p = points[j];
+ if (round) {
+ p._round();
+ }
+ str += (j ? 'L' : 'M') + p.x + ' ' + p.y;
+ }
+ return str;
+ },
+
+ _clipPoints: function () {
+ var points = this._originalPoints,
+ len = points.length,
+ i, k, segment;
+
+ if (this.options.noClip) {
+ this._parts = [points];
+ return;
+ }
+
+ this._parts = [];
+
+ var parts = this._parts,
+ vp = this._map._pathViewport,
+ lu = L.LineUtil;
+
+ for (i = 0, k = 0; i < len - 1; i++) {
+ segment = lu.clipSegment(points[i], points[i + 1], vp, i);
+ if (!segment) {
+ continue;
+ }
+
+ parts[k] = parts[k] || [];
+ parts[k].push(segment[0]);
+
+ // if segment goes out of screen, or it's the last one, it's the end of the line part
+ if ((segment[1] !== points[i + 1]) || (i === len - 2)) {
+ parts[k].push(segment[1]);
+ k++;
+ }
+ }
+ },
+
+ // simplify each clipped part of the polyline
+ _simplifyPoints: function () {
+ var parts = this._parts,
+ lu = L.LineUtil;
+
+ for (var i = 0, len = parts.length; i < len; i++) {
+ parts[i] = lu.simplify(parts[i], this.options.smoothFactor);
+ }
+ },
+
+ _updatePath: function () {
+ if (!this._map) { return; }
+
+ this._clipPoints();
+ this._simplifyPoints();
+
+ L.Path.prototype._updatePath.call(this);
+ }
+});
+
+L.polyline = function (latlngs, options) {
+ return new L.Polyline(latlngs, options);
+};
+
+
+/*
+ * L.PolyUtil contains utility functions for polygons (clipping, etc.).
+ */
+
+/*jshint bitwise:false */ // allow bitwise operations here
+
+L.PolyUtil = {};
+
+/*
+ * Sutherland-Hodgeman polygon clipping algorithm.
+ * Used to avoid rendering parts of a polygon that are not currently visible.
+ */
+L.PolyUtil.clipPolygon = function (points, bounds) {
+ var clippedPoints,
+ edges = [1, 4, 2, 8],
+ i, j, k,
+ a, b,
+ len, edge, p,
+ lu = L.LineUtil;
+
+ for (i = 0, len = points.length; i < len; i++) {
+ points[i]._code = lu._getBitCode(points[i], bounds);
+ }
+
+ // for each edge (left, bottom, right, top)
+ for (k = 0; k < 4; k++) {
+ edge = edges[k];
+ clippedPoints = [];
+
+ for (i = 0, len = points.length, j = len - 1; i < len; j = i++) {
+ a = points[i];
+ b = points[j];
+
+ // if a is inside the clip window
+ if (!(a._code & edge)) {
+ // if b is outside the clip window (a->b goes out of screen)
+ if (b._code & edge) {
+ p = lu._getEdgeIntersection(b, a, edge, bounds);
+ p._code = lu._getBitCode(p, bounds);
+ clippedPoints.push(p);
+ }
+ clippedPoints.push(a);
+
+ // else if b is inside the clip window (a->b enters the screen)
+ } else if (!(b._code & edge)) {
+ p = lu._getEdgeIntersection(b, a, edge, bounds);
+ p._code = lu._getBitCode(p, bounds);
+ clippedPoints.push(p);
+ }
+ }
+ points = clippedPoints;
+ }
+
+ return points;
+};
+
+
+/*
+ * L.Polygon is used to display polygons on a map.
+ */
+
+L.Polygon = L.Polyline.extend({
+ options: {
+ fill: true
+ },
+
+ initialize: function (latlngs, options) {
+ L.Polyline.prototype.initialize.call(this, latlngs, options);
+ this._initWithHoles(latlngs);
+ },
+
+ _initWithHoles: function (latlngs) {
+ var i, len, hole;
+ if (latlngs && L.Util.isArray(latlngs[0]) && (typeof latlngs[0][0] !== 'number')) {
+ this._latlngs = this._convertLatLngs(latlngs[0]);
+ this._holes = latlngs.slice(1);
+
+ for (i = 0, len = this._holes.length; i < len; i++) {
+ hole = this._holes[i] = this._convertLatLngs(this._holes[i]);
+ if (hole[0].equals(hole[hole.length - 1])) {
+ hole.pop();
+ }
+ }
+ }
+
+ // filter out last point if its equal to the first one
+ latlngs = this._latlngs;
+
+ if (latlngs.length >= 2 && latlngs[0].equals(latlngs[latlngs.length - 1])) {
+ latlngs.pop();
+ }
+ },
+
+ projectLatlngs: function () {
+ L.Polyline.prototype.projectLatlngs.call(this);
+
+ // project polygon holes points
+ // TODO move this logic to Polyline to get rid of duplication
+ this._holePoints = [];
+
+ if (!this._holes) { return; }
+
+ var i, j, len, len2;
+
+ for (i = 0, len = this._holes.length; i < len; i++) {
+ this._holePoints[i] = [];
+
+ for (j = 0, len2 = this._holes[i].length; j < len2; j++) {
+ this._holePoints[i][j] = this._map.latLngToLayerPoint(this._holes[i][j]);
+ }
+ }
+ },
+
+ setLatLngs: function (latlngs) {
+ if (latlngs && L.Util.isArray(latlngs[0]) && (typeof latlngs[0][0] !== 'number')) {
+ this._initWithHoles(latlngs);
+ return this.redraw();
+ } else {
+ return L.Polyline.prototype.setLatLngs.call(this, latlngs);
+ }
+ },
+
+ _clipPoints: function () {
+ var points = this._originalPoints,
+ newParts = [];
+
+ this._parts = [points].concat(this._holePoints);
+
+ if (this.options.noClip) { return; }
+
+ for (var i = 0, len = this._parts.length; i < len; i++) {
+ var clipped = L.PolyUtil.clipPolygon(this._parts[i], this._map._pathViewport);
+ if (clipped.length) {
+ newParts.push(clipped);
+ }
+ }
+
+ this._parts = newParts;
+ },
+
+ _getPathPartStr: function (points) {
+ var str = L.Polyline.prototype._getPathPartStr.call(this, points);
+ return str + (L.Browser.svg ? 'z' : 'x');
+ }
+});
+
+L.polygon = function (latlngs, options) {
+ return new L.Polygon(latlngs, options);
+};
+
+
+/*
+ * Contains L.MultiPolyline and L.MultiPolygon layers.
+ */
+
+(function () {
+ function createMulti(Klass) {
+
+ return L.FeatureGroup.extend({
+
+ initialize: function (latlngs, options) {
+ this._layers = {};
+ this._options = options;
+ this.setLatLngs(latlngs);
+ },
+
+ setLatLngs: function (latlngs) {
+ var i = 0,
+ len = latlngs.length;
+
+ this.eachLayer(function (layer) {
+ if (i < len) {
+ layer.setLatLngs(latlngs[i++]);
+ } else {
+ this.removeLayer(layer);
+ }
+ }, this);
+
+ while (i < len) {
+ this.addLayer(new Klass(latlngs[i++], this._options));
+ }
+
+ return this;
+ },
+
+ getLatLngs: function () {
+ var latlngs = [];
+
+ this.eachLayer(function (layer) {
+ latlngs.push(layer.getLatLngs());
+ });
+
+ return latlngs;
+ }
+ });
+ }
+
+ L.MultiPolyline = createMulti(L.Polyline);
+ L.MultiPolygon = createMulti(L.Polygon);
+
+ L.multiPolyline = function (latlngs, options) {
+ return new L.MultiPolyline(latlngs, options);
+ };
+
+ L.multiPolygon = function (latlngs, options) {
+ return new L.MultiPolygon(latlngs, options);
+ };
+}());
+
+
+/*
+ * L.Rectangle extends Polygon and creates a rectangle when passed a LatLngBounds object.
+ */
+
+L.Rectangle = L.Polygon.extend({
+ initialize: function (latLngBounds, options) {
+ L.Polygon.prototype.initialize.call(this, this._boundsToLatLngs(latLngBounds), options);
+ },
+
+ setBounds: function (latLngBounds) {
+ this.setLatLngs(this._boundsToLatLngs(latLngBounds));
+ },
+
+ _boundsToLatLngs: function (latLngBounds) {
+ latLngBounds = L.latLngBounds(latLngBounds);
+ return [
+ latLngBounds.getSouthWest(),
+ latLngBounds.getNorthWest(),
+ latLngBounds.getNorthEast(),
+ latLngBounds.getSouthEast()
+ ];
+ }
+});
+
+L.rectangle = function (latLngBounds, options) {
+ return new L.Rectangle(latLngBounds, options);
+};
+
+
+/*
+ * L.Circle is a circle overlay (with a certain radius in meters).
+ */
+
+L.Circle = L.Path.extend({
+ initialize: function (latlng, radius, options) {
+ L.Path.prototype.initialize.call(this, options);
+
+ this._latlng = L.latLng(latlng);
+ this._mRadius = radius;
+ },
+
+ options: {
+ fill: true
+ },
+
+ setLatLng: function (latlng) {
+ this._latlng = L.latLng(latlng);
+ return this.redraw();
+ },
+
+ setRadius: function (radius) {
+ this._mRadius = radius;
+ return this.redraw();
+ },
+
+ projectLatlngs: function () {
+ var lngRadius = this._getLngRadius(),
+ latlng = this._latlng,
+ pointLeft = this._map.latLngToLayerPoint([latlng.lat, latlng.lng - lngRadius]);
+
+ this._point = this._map.latLngToLayerPoint(latlng);
+ this._radius = Math.max(this._point.x - pointLeft.x, 1);
+ },
+
+ getBounds: function () {
+ var lngRadius = this._getLngRadius(),
+ latRadius = (this._mRadius / 40075017) * 360,
+ latlng = this._latlng;
+
+ return new L.LatLngBounds(
+ [latlng.lat - latRadius, latlng.lng - lngRadius],
+ [latlng.lat + latRadius, latlng.lng + lngRadius]);
+ },
+
+ getLatLng: function () {
+ return this._latlng;
+ },
+
+ getPathString: function () {
+ var p = this._point,
+ r = this._radius;
+
+ if (this._checkIfEmpty()) {
+ return '';
+ }
+
+ if (L.Browser.svg) {
+ return 'M' + p.x + ',' + (p.y - r) +
+ 'A' + r + ',' + r + ',0,1,1,' +
+ (p.x - 0.1) + ',' + (p.y - r) + ' z';
+ } else {
+ p._round();
+ r = Math.round(r);
+ return 'AL ' + p.x + ',' + p.y + ' ' + r + ',' + r + ' 0,' + (65535 * 360);
+ }
+ },
+
+ getRadius: function () {
+ return this._mRadius;
+ },
+
+ // TODO Earth hardcoded, move into projection code!
+
+ _getLatRadius: function () {
+ return (this._mRadius / 40075017) * 360;
+ },
+
+ _getLngRadius: function () {
+ return this._getLatRadius() / Math.cos(L.LatLng.DEG_TO_RAD * this._latlng.lat);
+ },
+
+ _checkIfEmpty: function () {
+ if (!this._map) {
+ return false;
+ }
+ var vp = this._map._pathViewport,
+ r = this._radius,
+ p = this._point;
+
+ return p.x - r > vp.max.x || p.y - r > vp.max.y ||
+ p.x + r < vp.min.x || p.y + r < vp.min.y;
+ }
+});
+
+L.circle = function (latlng, radius, options) {
+ return new L.Circle(latlng, radius, options);
+};
+
+
+/*
+ * L.CircleMarker is a circle overlay with a permanent pixel radius.
+ */
+
+L.CircleMarker = L.Circle.extend({
+ options: {
+ radius: 10,
+ weight: 2
+ },
+
+ initialize: function (latlng, options) {
+ L.Circle.prototype.initialize.call(this, latlng, null, options);
+ this._radius = this.options.radius;
+ },
+
+ projectLatlngs: function () {
+ this._point = this._map.latLngToLayerPoint(this._latlng);
+ },
+
+ _updateStyle : function () {
+ L.Circle.prototype._updateStyle.call(this);
+ this.setRadius(this.options.radius);
+ },
+
+ setLatLng: function (latlng) {
+ L.Circle.prototype.setLatLng.call(this, latlng);
+ if (this._popup && this._popup._isOpen) {
+ this._popup.setLatLng(latlng);
+ }
+ return this;
+ },
+
+ setRadius: function (radius) {
+ this.options.radius = this._radius = radius;
+ return this.redraw();
+ },
+
+ getRadius: function () {
+ return this._radius;
+ }
+});
+
+L.circleMarker = function (latlng, options) {
+ return new L.CircleMarker(latlng, options);
+};
+
+
+/*
+ * Extends L.Polyline to be able to manually detect clicks on Canvas-rendered polylines.
+ */
+
+L.Polyline.include(!L.Path.CANVAS ? {} : {
+ _containsPoint: function (p, closed) {
+ var i, j, k, len, len2, dist, part,
+ w = this.options.weight / 2;
+
+ if (L.Browser.touch) {
+ w += 10; // polyline click tolerance on touch devices
+ }
+
+ for (i = 0, len = this._parts.length; i < len; i++) {
+ part = this._parts[i];
+ for (j = 0, len2 = part.length, k = len2 - 1; j < len2; k = j++) {
+ if (!closed && (j === 0)) {
+ continue;
+ }
+
+ dist = L.LineUtil.pointToSegmentDistance(p, part[k], part[j]);
+
+ if (dist <= w) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+});
+
+
+/*
+ * Extends L.Polygon to be able to manually detect clicks on Canvas-rendered polygons.
+ */
+
+L.Polygon.include(!L.Path.CANVAS ? {} : {
+ _containsPoint: function (p) {
+ var inside = false,
+ part, p1, p2,
+ i, j, k,
+ len, len2;
+
+ // TODO optimization: check if within bounds first
+
+ if (L.Polyline.prototype._containsPoint.call(this, p, true)) {
+ // click on polygon border
+ return true;
+ }
+
+ // ray casting algorithm for detecting if point is in polygon
+
+ for (i = 0, len = this._parts.length; i < len; i++) {
+ part = this._parts[i];
+
+ for (j = 0, len2 = part.length, k = len2 - 1; j < len2; k = j++) {
+ p1 = part[j];
+ p2 = part[k];
+
+ if (((p1.y > p.y) !== (p2.y > p.y)) &&
+ (p.x < (p2.x - p1.x) * (p.y - p1.y) / (p2.y - p1.y) + p1.x)) {
+ inside = !inside;
+ }
+ }
+ }
+
+ return inside;
+ }
+});
+
+
+/*
+ * Extends L.Circle with Canvas-specific code.
+ */
+
+L.Circle.include(!L.Path.CANVAS ? {} : {
+ _drawPath: function () {
+ var p = this._point;
+ this._ctx.beginPath();
+ this._ctx.arc(p.x, p.y, this._radius, 0, Math.PI * 2, false);
+ },
+
+ _containsPoint: function (p) {
+ var center = this._point,
+ w2 = this.options.stroke ? this.options.weight / 2 : 0;
+
+ return (p.distanceTo(center) <= this._radius + w2);
+ }
+});
+
+
+/*
+ * CircleMarker canvas specific drawing parts.
+ */
+
+L.CircleMarker.include(!L.Path.CANVAS ? {} : {
+ _updateStyle: function () {
+ L.Path.prototype._updateStyle.call(this);
+ }
+});
+
+
+/*
+ * L.GeoJSON turns any GeoJSON data into a Leaflet layer.
+ */
+
+L.GeoJSON = L.FeatureGroup.extend({
+
+ initialize: function (geojson, options) {
+ L.setOptions(this, options);
+
+ this._layers = {};
+
+ if (geojson) {
+ this.addData(geojson);
+ }
+ },
+
+ addData: function (geojson) {
+ var features = L.Util.isArray(geojson) ? geojson : geojson.features,
+ i, len, feature;
+
+ if (features) {
+ for (i = 0, len = features.length; i < len; i++) {
+ // Only add this if geometry or geometries are set and not null
+ feature = features[i];
+ if (feature.geometries || feature.geometry || feature.features || feature.coordinates) {
+ this.addData(features[i]);
+ }
+ }
+ return this;
+ }
+
+ var options = this.options;
+
+ if (options.filter && !options.filter(geojson)) { return; }
+
+ var layer = L.GeoJSON.geometryToLayer(geojson, options.pointToLayer, options.coordsToLatLng, options);
+ layer.feature = L.GeoJSON.asFeature(geojson);
+
+ layer.defaultOptions = layer.options;
+ this.resetStyle(layer);
+
+ if (options.onEachFeature) {
+ options.onEachFeature(geojson, layer);
+ }
+
+ return this.addLayer(layer);
+ },
+
+ resetStyle: function (layer) {
+ var style = this.options.style;
+ if (style) {
+ // reset any custom styles
+ L.Util.extend(layer.options, layer.defaultOptions);
+
+ this._setLayerStyle(layer, style);
+ }
+ },
+
+ setStyle: function (style) {
+ this.eachLayer(function (layer) {
+ this._setLayerStyle(layer, style);
+ }, this);
+ },
+
+ _setLayerStyle: function (layer, style) {
+ if (typeof style === 'function') {
+ style = style(layer.feature);
+ }
+ if (layer.setStyle) {
+ layer.setStyle(style);
+ }
+ }
+});
+
+L.extend(L.GeoJSON, {
+ geometryToLayer: function (geojson, pointToLayer, coordsToLatLng, vectorOptions) {
+ var geometry = geojson.type === 'Feature' ? geojson.geometry : geojson,
+ coords = geometry.coordinates,
+ layers = [],
+ latlng, latlngs, i, len;
+
+ coordsToLatLng = coordsToLatLng || this.coordsToLatLng;
+
+ switch (geometry.type) {
+ case 'Point':
+ latlng = coordsToLatLng(coords);
+ return pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng);
+
+ case 'MultiPoint':
+ for (i = 0, len = coords.length; i < len; i++) {
+ latlng = coordsToLatLng(coords[i]);
+ layers.push(pointToLayer ? pointToLayer(geojson, latlng) : new L.Marker(latlng));
+ }
+ return new L.FeatureGroup(layers);
+
+ case 'LineString':
+ latlngs = this.coordsToLatLngs(coords, 0, coordsToLatLng);
+ return new L.Polyline(latlngs, vectorOptions);
+
+ case 'Polygon':
+ if (coords.length === 2 && !coords[1].length) {
+ throw new Error('Invalid GeoJSON object.');
+ }
+ latlngs = this.coordsToLatLngs(coords, 1, coordsToLatLng);
+ return new L.Polygon(latlngs, vectorOptions);
+
+ case 'MultiLineString':
+ latlngs = this.coordsToLatLngs(coords, 1, coordsToLatLng);
+ return new L.MultiPolyline(latlngs, vectorOptions);
+
+ case 'MultiPolygon':
+ latlngs = this.coordsToLatLngs(coords, 2, coordsToLatLng);
+ return new L.MultiPolygon(latlngs, vectorOptions);
+
+ case 'GeometryCollection':
+ for (i = 0, len = geometry.geometries.length; i < len; i++) {
+
+ layers.push(this.geometryToLayer({
+ geometry: geometry.geometries[i],
+ type: 'Feature',
+ properties: geojson.properties
+ }, pointToLayer, coordsToLatLng, vectorOptions));
+ }
+ return new L.FeatureGroup(layers);
+
+ default:
+ throw new Error('Invalid GeoJSON object.');
+ }
+ },
+
+ coordsToLatLng: function (coords) { // (Array[, Boolean]) -> LatLng
+ return new L.LatLng(coords[1], coords[0], coords[2]);
+ },
+
+ coordsToLatLngs: function (coords, levelsDeep, coordsToLatLng) { // (Array[, Number, Function]) -> Array
+ var latlng, i, len,
+ latlngs = [];
+
+ for (i = 0, len = coords.length; i < len; i++) {
+ latlng = levelsDeep ?
+ this.coordsToLatLngs(coords[i], levelsDeep - 1, coordsToLatLng) :
+ (coordsToLatLng || this.coordsToLatLng)(coords[i]);
+
+ latlngs.push(latlng);
+ }
+
+ return latlngs;
+ },
+
+ latLngToCoords: function (latlng) {
+ var coords = [latlng.lng, latlng.lat];
+
+ if (latlng.alt !== undefined) {
+ coords.push(latlng.alt);
+ }
+ return coords;
+ },
+
+ latLngsToCoords: function (latLngs) {
+ var coords = [];
+
+ for (var i = 0, len = latLngs.length; i < len; i++) {
+ coords.push(L.GeoJSON.latLngToCoords(latLngs[i]));
+ }
+
+ return coords;
+ },
+
+ getFeature: function (layer, newGeometry) {
+ return layer.feature ? L.extend({}, layer.feature, {geometry: newGeometry}) : L.GeoJSON.asFeature(newGeometry);
+ },
+
+ asFeature: function (geoJSON) {
+ if (geoJSON.type === 'Feature') {
+ return geoJSON;
+ }
+
+ return {
+ type: 'Feature',
+ properties: {},
+ geometry: geoJSON
+ };
+ }
+});
+
+var PointToGeoJSON = {
+ toGeoJSON: function () {
+ return L.GeoJSON.getFeature(this, {
+ type: 'Point',
+ coordinates: L.GeoJSON.latLngToCoords(this.getLatLng())
+ });
+ }
+};
+
+L.Marker.include(PointToGeoJSON);
+L.Circle.include(PointToGeoJSON);
+L.CircleMarker.include(PointToGeoJSON);
+
+L.Polyline.include({
+ toGeoJSON: function () {
+ return L.GeoJSON.getFeature(this, {
+ type: 'LineString',
+ coordinates: L.GeoJSON.latLngsToCoords(this.getLatLngs())
+ });
+ }
+});
+
+L.Polygon.include({
+ toGeoJSON: function () {
+ var coords = [L.GeoJSON.latLngsToCoords(this.getLatLngs())],
+ i, len, hole;
+
+ coords[0].push(coords[0][0]);
+
+ if (this._holes) {
+ for (i = 0, len = this._holes.length; i < len; i++) {
+ hole = L.GeoJSON.latLngsToCoords(this._holes[i]);
+ hole.push(hole[0]);
+ coords.push(hole);
+ }
+ }
+
+ return L.GeoJSON.getFeature(this, {
+ type: 'Polygon',
+ coordinates: coords
+ });
+ }
+});
+
+(function () {
+ function multiToGeoJSON(type) {
+ return function () {
+ var coords = [];
+
+ this.eachLayer(function (layer) {
+ coords.push(layer.toGeoJSON().geometry.coordinates);
+ });
+
+ return L.GeoJSON.getFeature(this, {
+ type: type,
+ coordinates: coords
+ });
+ };
+ }
+
+ L.MultiPolyline.include({toGeoJSON: multiToGeoJSON('MultiLineString')});
+ L.MultiPolygon.include({toGeoJSON: multiToGeoJSON('MultiPolygon')});
+
+ L.LayerGroup.include({
+ toGeoJSON: function () {
+
+ var geometry = this.feature && this.feature.geometry,
+ jsons = [],
+ json;
+
+ if (geometry && geometry.type === 'MultiPoint') {
+ return multiToGeoJSON('MultiPoint').call(this);
+ }
+
+ var isGeometryCollection = geometry && geometry.type === 'GeometryCollection';
+
+ this.eachLayer(function (layer) {
+ if (layer.toGeoJSON) {
+ json = layer.toGeoJSON();
+ jsons.push(isGeometryCollection ? json.geometry : L.GeoJSON.asFeature(json));
+ }
+ });
+
+ if (isGeometryCollection) {
+ return L.GeoJSON.getFeature(this, {
+ geometries: jsons,
+ type: 'GeometryCollection'
+ });
+ }
+
+ return {
+ type: 'FeatureCollection',
+ features: jsons
+ };
+ }
+ });
+}());
+
+L.geoJson = function (geojson, options) {
+ return new L.GeoJSON(geojson, options);
+};
+
+
+/*
+ * L.DomEvent contains functions for working with DOM events.
+ */
+
+L.DomEvent = {
+ /* inspired by John Resig, Dean Edwards and YUI addEvent implementations */
+ addListener: function (obj, type, fn, context) { // (HTMLElement, String, Function[, Object])
+
+ var id = L.stamp(fn),
+ key = '_leaflet_' + type + id,
+ handler, originalHandler, newType;
+
+ if (obj[key]) { return this; }
+
+ handler = function (e) {
+ return fn.call(context || obj, e || L.DomEvent._getEvent());
+ };
+
+ if (L.Browser.pointer && type.indexOf('touch') === 0) {
+ return this.addPointerListener(obj, type, handler, id);
+ }
+ if (L.Browser.touch && (type === 'dblclick') && this.addDoubleTapListener) {
+ this.addDoubleTapListener(obj, handler, id);
+ }
+
+ if ('addEventListener' in obj) {
+
+ if (type === 'mousewheel') {
+ obj.addEventListener('DOMMouseScroll', handler, false);
+ obj.addEventListener(type, handler, false);
+
+ } else if ((type === 'mouseenter') || (type === 'mouseleave')) {
+
+ originalHandler = handler;
+ newType = (type === 'mouseenter' ? 'mouseover' : 'mouseout');
+
+ handler = function (e) {
+ if (!L.DomEvent._checkMouse(obj, e)) { return; }
+ return originalHandler(e);
+ };
+
+ obj.addEventListener(newType, handler, false);
+
+ } else if (type === 'click' && L.Browser.android) {
+ originalHandler = handler;
+ handler = function (e) {
+ return L.DomEvent._filterClick(e, originalHandler);
+ };
+
+ obj.addEventListener(type, handler, false);
+ } else {
+ obj.addEventListener(type, handler, false);
+ }
+
+ } else if ('attachEvent' in obj) {
+ obj.attachEvent('on' + type, handler);
+ }
+
+ obj[key] = handler;
+
+ return this;
+ },
+
+ removeListener: function (obj, type, fn) { // (HTMLElement, String, Function)
+
+ var id = L.stamp(fn),
+ key = '_leaflet_' + type + id,
+ handler = obj[key];
+
+ if (!handler) { return this; }
+
+ if (L.Browser.pointer && type.indexOf('touch') === 0) {
+ this.removePointerListener(obj, type, id);
+ } else if (L.Browser.touch && (type === 'dblclick') && this.removeDoubleTapListener) {
+ this.removeDoubleTapListener(obj, id);
+
+ } else if ('removeEventListener' in obj) {
+
+ if (type === 'mousewheel') {
+ obj.removeEventListener('DOMMouseScroll', handler, false);
+ obj.removeEventListener(type, handler, false);
+
+ } else if ((type === 'mouseenter') || (type === 'mouseleave')) {
+ obj.removeEventListener((type === 'mouseenter' ? 'mouseover' : 'mouseout'), handler, false);
+ } else {
+ obj.removeEventListener(type, handler, false);
+ }
+ } else if ('detachEvent' in obj) {
+ obj.detachEvent('on' + type, handler);
+ }
+
+ obj[key] = null;
+
+ return this;
+ },
+
+ stopPropagation: function (e) {
+
+ if (e.stopPropagation) {
+ e.stopPropagation();
+ } else {
+ e.cancelBubble = true;
+ }
+ L.DomEvent._skipped(e);
+
+ return this;
+ },
+
+ disableScrollPropagation: function (el) {
+ var stop = L.DomEvent.stopPropagation;
+
+ return L.DomEvent
+ .on(el, 'mousewheel', stop)
+ .on(el, 'MozMousePixelScroll', stop);
+ },
+
+ disableClickPropagation: function (el) {
+ var stop = L.DomEvent.stopPropagation;
+
+ for (var i = L.Draggable.START.length - 1; i >= 0; i--) {
+ L.DomEvent.on(el, L.Draggable.START[i], stop);
+ }
+
+ return L.DomEvent
+ .on(el, 'click', L.DomEvent._fakeStop)
+ .on(el, 'dblclick', stop);
+ },
+
+ preventDefault: function (e) {
+
+ if (e.preventDefault) {
+ e.preventDefault();
+ } else {
+ e.returnValue = false;
+ }
+ return this;
+ },
+
+ stop: function (e) {
+ return L.DomEvent
+ .preventDefault(e)
+ .stopPropagation(e);
+ },
+
+ getMousePosition: function (e, container) {
+ if (!container) {
+ return new L.Point(e.clientX, e.clientY);
+ }
+
+ var rect = container.getBoundingClientRect();
+
+ return new L.Point(
+ e.clientX - rect.left - container.clientLeft,
+ e.clientY - rect.top - container.clientTop);
+ },
+
+ getWheelDelta: function (e) {
+
+ var delta = 0;
+
+ if (e.wheelDelta) {
+ delta = e.wheelDelta / 120;
+ }
+ if (e.detail) {
+ delta = -e.detail / 3;
+ }
+ return delta;
+ },
+
+ _skipEvents: {},
+
+ _fakeStop: function (e) {
+ // fakes stopPropagation by setting a special event flag, checked/reset with L.DomEvent._skipped(e)
+ L.DomEvent._skipEvents[e.type] = true;
+ },
+
+ _skipped: function (e) {
+ var skipped = this._skipEvents[e.type];
+ // reset when checking, as it's only used in map container and propagates outside of the map
+ this._skipEvents[e.type] = false;
+ return skipped;
+ },
+
+ // check if element really left/entered the event target (for mouseenter/mouseleave)
+ _checkMouse: function (el, e) {
+
+ var related = e.relatedTarget;
+
+ if (!related) { return true; }
+
+ try {
+ while (related && (related !== el)) {
+ related = related.parentNode;
+ }
+ } catch (err) {
+ return false;
+ }
+ return (related !== el);
+ },
+
+ _getEvent: function () { // evil magic for IE
+ /*jshint noarg:false */
+ var e = window.event;
+ if (!e) {
+ var caller = arguments.callee.caller;
+ while (caller) {
+ e = caller['arguments'][0];
+ if (e && window.Event === e.constructor) {
+ break;
+ }
+ caller = caller.caller;
+ }
+ }
+ return e;
+ },
+
+ // this is a horrible workaround for a bug in Android where a single touch triggers two click events
+ _filterClick: function (e, handler) {
+ var timeStamp = (e.timeStamp || e.originalEvent.timeStamp),
+ elapsed = L.DomEvent._lastClick && (timeStamp - L.DomEvent._lastClick);
+
+ // are they closer together than 1000ms yet more than 100ms?
+ // Android typically triggers them ~300ms apart while multiple listeners
+ // on the same event should be triggered far faster;
+ // or check if click is simulated on the element, and if it is, reject any non-simulated events
+
+ if ((elapsed && elapsed > 100 && elapsed < 1000) || (e.target._simulatedClick && !e._simulated)) {
+ L.DomEvent.stop(e);
+ return;
+ }
+ L.DomEvent._lastClick = timeStamp;
+
+ return handler(e);
+ }
+};
+
+L.DomEvent.on = L.DomEvent.addListener;
+L.DomEvent.off = L.DomEvent.removeListener;
+
+
+/*
+ * L.Draggable allows you to add dragging capabilities to any element. Supports mobile devices too.
+ */
+
+L.Draggable = L.Class.extend({
+ includes: L.Mixin.Events,
+
+ statics: {
+ START: L.Browser.touch ? ['touchstart', 'mousedown'] : ['mousedown'],
+ END: {
+ mousedown: 'mouseup',
+ touchstart: 'touchend',
+ pointerdown: 'touchend',
+ MSPointerDown: 'touchend'
+ },
+ MOVE: {
+ mousedown: 'mousemove',
+ touchstart: 'touchmove',
+ pointerdown: 'touchmove',
+ MSPointerDown: 'touchmove'
+ }
+ },
+
+ initialize: function (element, dragStartTarget) {
+ this._element = element;
+ this._dragStartTarget = dragStartTarget || element;
+ },
+
+ enable: function () {
+ if (this._enabled) { return; }
+
+ for (var i = L.Draggable.START.length - 1; i >= 0; i--) {
+ L.DomEvent.on(this._dragStartTarget, L.Draggable.START[i], this._onDown, this);
+ }
+
+ this._enabled = true;
+ },
+
+ disable: function () {
+ if (!this._enabled) { return; }
+
+ for (var i = L.Draggable.START.length - 1; i >= 0; i--) {
+ L.DomEvent.off(this._dragStartTarget, L.Draggable.START[i], this._onDown, this);
+ }
+
+ this._enabled = false;
+ this._moved = false;
+ },
+
+ _onDown: function (e) {
+ this._moved = false;
+
+ if (e.shiftKey || ((e.which !== 1) && (e.button !== 1) && !e.touches)) { return; }
+
+ L.DomEvent.stopPropagation(e);
+
+ if (L.Draggable._disabled) { return; }
+
+ L.DomUtil.disableImageDrag();
+ L.DomUtil.disableTextSelection();
+
+ if (this._moving) { return; }
+
+ var first = e.touches ? e.touches[0] : e;
+
+ this._startPoint = new L.Point(first.clientX, first.clientY);
+ this._startPos = this._newPos = L.DomUtil.getPosition(this._element);
+
+ L.DomEvent
+ .on(document, L.Draggable.MOVE[e.type], this._onMove, this)
+ .on(document, L.Draggable.END[e.type], this._onUp, this);
+ },
+
+ _onMove: function (e) {
+ if (e.touches && e.touches.length > 1) {
+ this._moved = true;
+ return;
+ }
+
+ var first = (e.touches && e.touches.length === 1 ? e.touches[0] : e),
+ newPoint = new L.Point(first.clientX, first.clientY),
+ offset = newPoint.subtract(this._startPoint);
+
+ if (!offset.x && !offset.y) { return; }
+
+ L.DomEvent.preventDefault(e);
+
+ if (!this._moved) {
+ this.fire('dragstart');
+
+ this._moved = true;
+ this._startPos = L.DomUtil.getPosition(this._element).subtract(offset);
+
+ L.DomUtil.addClass(document.body, 'leaflet-dragging');
+ L.DomUtil.addClass((e.target || e.srcElement), 'leaflet-drag-target');
+ }
+
+ this._newPos = this._startPos.add(offset);
+ this._moving = true;
+
+ L.Util.cancelAnimFrame(this._animRequest);
+ this._animRequest = L.Util.requestAnimFrame(this._updatePosition, this, true, this._dragStartTarget);
+ },
+
+ _updatePosition: function () {
+ this.fire('predrag');
+ L.DomUtil.setPosition(this._element, this._newPos);
+ this.fire('drag');
+ },
+
+ _onUp: function (e) {
+ L.DomUtil.removeClass(document.body, 'leaflet-dragging');
+ L.DomUtil.removeClass((e.target || e.srcElement), 'leaflet-drag-target');
+
+ for (var i in L.Draggable.MOVE) {
+ L.DomEvent
+ .off(document, L.Draggable.MOVE[i], this._onMove)
+ .off(document, L.Draggable.END[i], this._onUp);
+ }
+
+ L.DomUtil.enableImageDrag();
+ L.DomUtil.enableTextSelection();
+
+ if (this._moved && this._moving) {
+ // ensure drag is not fired after dragend
+ L.Util.cancelAnimFrame(this._animRequest);
+
+ this.fire('dragend', {
+ distance: this._newPos.distanceTo(this._startPos)
+ });
+ }
+
+ this._moving = false;
+ }
+});
+
+
+/*
+ L.Handler is a base class for handler classes that are used internally to inject
+ interaction features like dragging to classes like Map and Marker.
+*/
+
+L.Handler = L.Class.extend({
+ initialize: function (map) {
+ this._map = map;
+ },
+
+ enable: function () {
+ if (this._enabled) { return; }
+
+ this._enabled = true;
+ this.addHooks();
+ },
+
+ disable: function () {
+ if (!this._enabled) { return; }
+
+ this._enabled = false;
+ this.removeHooks();
+ },
+
+ enabled: function () {
+ return !!this._enabled;
+ }
+});
+
+
+/*
+ * L.Handler.MapDrag is used to make the map draggable (with panning inertia), enabled by default.
+ */
+
+L.Map.mergeOptions({
+ dragging: true,
+
+ inertia: !L.Browser.android23,
+ inertiaDeceleration: 3400, // px/s^2
+ inertiaMaxSpeed: Infinity, // px/s
+ inertiaThreshold: L.Browser.touch ? 32 : 18, // ms
+ easeLinearity: 0.25,
+
+ // TODO refactor, move to CRS
+ worldCopyJump: false
+});
+
+L.Map.Drag = L.Handler.extend({
+ addHooks: function () {
+ if (!this._draggable) {
+ var map = this._map;
+
+ this._draggable = new L.Draggable(map._mapPane, map._container);
+
+ this._draggable.on({
+ 'dragstart': this._onDragStart,
+ 'drag': this._onDrag,
+ 'dragend': this._onDragEnd
+ }, this);
+
+ if (map.options.worldCopyJump) {
+ this._draggable.on('predrag', this._onPreDrag, this);
+ map.on('viewreset', this._onViewReset, this);
+
+ map.whenReady(this._onViewReset, this);
+ }
+ }
+ this._draggable.enable();
+ },
+
+ removeHooks: function () {
+ this._draggable.disable();
+ },
+
+ moved: function () {
+ return this._draggable && this._draggable._moved;
+ },
+
+ _onDragStart: function () {
+ var map = this._map;
+
+ if (map._panAnim) {
+ map._panAnim.stop();
+ }
+
+ map
+ .fire('movestart')
+ .fire('dragstart');
+
+ if (map.options.inertia) {
+ this._positions = [];
+ this._times = [];
+ }
+ },
+
+ _onDrag: function () {
+ if (this._map.options.inertia) {
+ var time = this._lastTime = +new Date(),
+ pos = this._lastPos = this._draggable._newPos;
+
+ this._positions.push(pos);
+ this._times.push(time);
+
+ if (time - this._times[0] > 200) {
+ this._positions.shift();
+ this._times.shift();
+ }
+ }
+
+ this._map
+ .fire('move')
+ .fire('drag');
+ },
+
+ _onViewReset: function () {
+ // TODO fix hardcoded Earth values
+ var pxCenter = this._map.getSize()._divideBy(2),
+ pxWorldCenter = this._map.latLngToLayerPoint([0, 0]);
+
+ this._initialWorldOffset = pxWorldCenter.subtract(pxCenter).x;
+ this._worldWidth = this._map.project([0, 180]).x;
+ },
+
+ _onPreDrag: function () {
+ // TODO refactor to be able to adjust map pane position after zoom
+ var worldWidth = this._worldWidth,
+ halfWidth = Math.round(worldWidth / 2),
+ dx = this._initialWorldOffset,
+ x = this._draggable._newPos.x,
+ newX1 = (x - halfWidth + dx) % worldWidth + halfWidth - dx,
+ newX2 = (x + halfWidth + dx) % worldWidth - halfWidth - dx,
+ newX = Math.abs(newX1 + dx) < Math.abs(newX2 + dx) ? newX1 : newX2;
+
+ this._draggable._newPos.x = newX;
+ },
+
+ _onDragEnd: function (e) {
+ var map = this._map,
+ options = map.options,
+ delay = +new Date() - this._lastTime,
+
+ noInertia = !options.inertia || delay > options.inertiaThreshold || !this._positions[0];
+
+ map.fire('dragend', e);
+
+ if (noInertia) {
+ map.fire('moveend');
+
+ } else {
+
+ var direction = this._lastPos.subtract(this._positions[0]),
+ duration = (this._lastTime + delay - this._times[0]) / 1000,
+ ease = options.easeLinearity,
+
+ speedVector = direction.multiplyBy(ease / duration),
+ speed = speedVector.distanceTo([0, 0]),
+
+ limitedSpeed = Math.min(options.inertiaMaxSpeed, speed),
+ limitedSpeedVector = speedVector.multiplyBy(limitedSpeed / speed),
+
+ decelerationDuration = limitedSpeed / (options.inertiaDeceleration * ease),
+ offset = limitedSpeedVector.multiplyBy(-decelerationDuration / 2).round();
+
+ if (!offset.x || !offset.y) {
+ map.fire('moveend');
+
+ } else {
+ offset = map._limitOffset(offset, map.options.maxBounds);
+
+ L.Util.requestAnimFrame(function () {
+ map.panBy(offset, {
+ duration: decelerationDuration,
+ easeLinearity: ease,
+ noMoveStart: true
+ });
+ });
+ }
+ }
+ }
+});
+
+L.Map.addInitHook('addHandler', 'dragging', L.Map.Drag);
+
+
+/*
+ * L.Handler.DoubleClickZoom is used to handle double-click zoom on the map, enabled by default.
+ */
+
+L.Map.mergeOptions({
+ doubleClickZoom: true
+});
+
+L.Map.DoubleClickZoom = L.Handler.extend({
+ addHooks: function () {
+ this._map.on('dblclick', this._onDoubleClick, this);
+ },
+
+ removeHooks: function () {
+ this._map.off('dblclick', this._onDoubleClick, this);
+ },
+
+ _onDoubleClick: function (e) {
+ var map = this._map,
+ zoom = map.getZoom() + (e.originalEvent.shiftKey ? -1 : 1);
+
+ if (map.options.doubleClickZoom === 'center') {
+ map.setZoom(zoom);
+ } else {
+ map.setZoomAround(e.containerPoint, zoom);
+ }
+ }
+});
+
+L.Map.addInitHook('addHandler', 'doubleClickZoom', L.Map.DoubleClickZoom);
+
+
+/*
+ * L.Handler.ScrollWheelZoom is used by L.Map to enable mouse scroll wheel zoom on the map.
+ */
+
+L.Map.mergeOptions({
+ scrollWheelZoom: true
+});
+
+L.Map.ScrollWheelZoom = L.Handler.extend({
+ addHooks: function () {
+ L.DomEvent.on(this._map._container, 'mousewheel', this._onWheelScroll, this);
+ L.DomEvent.on(this._map._container, 'MozMousePixelScroll', L.DomEvent.preventDefault);
+ this._delta = 0;
+ },
+
+ removeHooks: function () {
+ L.DomEvent.off(this._map._container, 'mousewheel', this._onWheelScroll);
+ L.DomEvent.off(this._map._container, 'MozMousePixelScroll', L.DomEvent.preventDefault);
+ },
+
+ _onWheelScroll: function (e) {
+ var delta = L.DomEvent.getWheelDelta(e);
+
+ this._delta += delta;
+ this._lastMousePos = this._map.mouseEventToContainerPoint(e);
+
+ if (!this._startTime) {
+ this._startTime = +new Date();
+ }
+
+ var left = Math.max(40 - (+new Date() - this._startTime), 0);
+
+ clearTimeout(this._timer);
+ this._timer = setTimeout(L.bind(this._performZoom, this), left);
+
+ L.DomEvent.preventDefault(e);
+ L.DomEvent.stopPropagation(e);
+ },
+
+ _performZoom: function () {
+ var map = this._map,
+ delta = this._delta,
+ zoom = map.getZoom();
+
+ delta = delta > 0 ? Math.ceil(delta) : Math.floor(delta);
+ delta = Math.max(Math.min(delta, 4), -4);
+ delta = map._limitZoom(zoom + delta) - zoom;
+
+ this._delta = 0;
+ this._startTime = null;
+
+ if (!delta) { return; }
+
+ if (map.options.scrollWheelZoom === 'center') {
+ map.setZoom(zoom + delta);
+ } else {
+ map.setZoomAround(this._lastMousePos, zoom + delta);
+ }
+ }
+});
+
+L.Map.addInitHook('addHandler', 'scrollWheelZoom', L.Map.ScrollWheelZoom);
+
+
+/*
+ * Extends the event handling code with double tap support for mobile browsers.
+ */
+
+L.extend(L.DomEvent, {
+
+ _touchstart: L.Browser.msPointer ? 'MSPointerDown' : L.Browser.pointer ? 'pointerdown' : 'touchstart',
+ _touchend: L.Browser.msPointer ? 'MSPointerUp' : L.Browser.pointer ? 'pointerup' : 'touchend',
+
+ // inspired by Zepto touch code by Thomas Fuchs
+ addDoubleTapListener: function (obj, handler, id) {
+ var last,
+ doubleTap = false,
+ delay = 250,
+ touch,
+ pre = '_leaflet_',
+ touchstart = this._touchstart,
+ touchend = this._touchend,
+ trackedTouches = [];
+
+ function onTouchStart(e) {
+ var count;
+
+ if (L.Browser.pointer) {
+ trackedTouches.push(e.pointerId);
+ count = trackedTouches.length;
+ } else {
+ count = e.touches.length;
+ }
+ if (count > 1) {
+ return;
+ }
+
+ var now = Date.now(),
+ delta = now - (last || now);
+
+ touch = e.touches ? e.touches[0] : e;
+ doubleTap = (delta > 0 && delta <= delay);
+ last = now;
+ }
+
+ function onTouchEnd(e) {
+ if (L.Browser.pointer) {
+ var idx = trackedTouches.indexOf(e.pointerId);
+ if (idx === -1) {
+ return;
+ }
+ trackedTouches.splice(idx, 1);
+ }
+
+ if (doubleTap) {
+ if (L.Browser.pointer) {
+ // work around .type being readonly with MSPointer* events
+ var newTouch = { },
+ prop;
+
+ // jshint forin:false
+ for (var i in touch) {
+ prop = touch[i];
+ if (typeof prop === 'function') {
+ newTouch[i] = prop.bind(touch);
+ } else {
+ newTouch[i] = prop;
+ }
+ }
+ touch = newTouch;
+ }
+ touch.type = 'dblclick';
+ handler(touch);
+ last = null;
+ }
+ }
+ obj[pre + touchstart + id] = onTouchStart;
+ obj[pre + touchend + id] = onTouchEnd;
+
+ // on pointer we need to listen on the document, otherwise a drag starting on the map and moving off screen
+ // will not come through to us, so we will lose track of how many touches are ongoing
+ var endElement = L.Browser.pointer ? document.documentElement : obj;
+
+ obj.addEventListener(touchstart, onTouchStart, false);
+ endElement.addEventListener(touchend, onTouchEnd, false);
+
+ if (L.Browser.pointer) {
+ endElement.addEventListener(L.DomEvent.POINTER_CANCEL, onTouchEnd, false);
+ }
+
+ return this;
+ },
+
+ removeDoubleTapListener: function (obj, id) {
+ var pre = '_leaflet_';
+
+ obj.removeEventListener(this._touchstart, obj[pre + this._touchstart + id], false);
+ (L.Browser.pointer ? document.documentElement : obj).removeEventListener(
+ this._touchend, obj[pre + this._touchend + id], false);
+
+ if (L.Browser.pointer) {
+ document.documentElement.removeEventListener(L.DomEvent.POINTER_CANCEL, obj[pre + this._touchend + id],
+ false);
+ }
+
+ return this;
+ }
+});
+
+
+/*
+ * Extends L.DomEvent to provide touch support for Internet Explorer and Windows-based devices.
+ */
+
+L.extend(L.DomEvent, {
+
+ //static
+ POINTER_DOWN: L.Browser.msPointer ? 'MSPointerDown' : 'pointerdown',
+ POINTER_MOVE: L.Browser.msPointer ? 'MSPointerMove' : 'pointermove',
+ POINTER_UP: L.Browser.msPointer ? 'MSPointerUp' : 'pointerup',
+ POINTER_CANCEL: L.Browser.msPointer ? 'MSPointerCancel' : 'pointercancel',
+
+ _pointers: [],
+ _pointerDocumentListener: false,
+
+ // Provides a touch events wrapper for (ms)pointer events.
+ // Based on changes by veproza https://github.com/CloudMade/Leaflet/pull/1019
+ //ref http://www.w3.org/TR/pointerevents/ https://www.w3.org/Bugs/Public/show_bug.cgi?id=22890
+
+ addPointerListener: function (obj, type, handler, id) {
+
+ switch (type) {
+ case 'touchstart':
+ return this.addPointerListenerStart(obj, type, handler, id);
+ case 'touchend':
+ return this.addPointerListenerEnd(obj, type, handler, id);
+ case 'touchmove':
+ return this.addPointerListenerMove(obj, type, handler, id);
+ default:
+ throw 'Unknown touch event type';
+ }
+ },
+
+ addPointerListenerStart: function (obj, type, handler, id) {
+ var pre = '_leaflet_',
+ pointers = this._pointers;
+
+ var cb = function (e) {
+
+ L.DomEvent.preventDefault(e);
+
+ var alreadyInArray = false;
+ for (var i = 0; i < pointers.length; i++) {
+ if (pointers[i].pointerId === e.pointerId) {
+ alreadyInArray = true;
+ break;
+ }
+ }
+ if (!alreadyInArray) {
+ pointers.push(e);
+ }
+
+ e.touches = pointers.slice();
+ e.changedTouches = [e];
+
+ handler(e);
+ };
+
+ obj[pre + 'touchstart' + id] = cb;
+ obj.addEventListener(this.POINTER_DOWN, cb, false);
+
+ // need to also listen for end events to keep the _pointers list accurate
+ // this needs to be on the body and never go away
+ if (!this._pointerDocumentListener) {
+ var internalCb = function (e) {
+ for (var i = 0; i < pointers.length; i++) {
+ if (pointers[i].pointerId === e.pointerId) {
+ pointers.splice(i, 1);
+ break;
+ }
+ }
+ };
+ //We listen on the documentElement as any drags that end by moving the touch off the screen get fired there
+ document.documentElement.addEventListener(this.POINTER_UP, internalCb, false);
+ document.documentElement.addEventListener(this.POINTER_CANCEL, internalCb, false);
+
+ this._pointerDocumentListener = true;
+ }
+
+ return this;
+ },
+
+ addPointerListenerMove: function (obj, type, handler, id) {
+ var pre = '_leaflet_',
+ touches = this._pointers;
+
+ function cb(e) {
+
+ // don't fire touch moves when mouse isn't down
+ if ((e.pointerType === e.MSPOINTER_TYPE_MOUSE || e.pointerType === 'mouse') && e.buttons === 0) { return; }
+
+ for (var i = 0; i < touches.length; i++) {
+ if (touches[i].pointerId === e.pointerId) {
+ touches[i] = e;
+ break;
+ }
+ }
+
+ e.touches = touches.slice();
+ e.changedTouches = [e];
+
+ handler(e);
+ }
+
+ obj[pre + 'touchmove' + id] = cb;
+ obj.addEventListener(this.POINTER_MOVE, cb, false);
+
+ return this;
+ },
+
+ addPointerListenerEnd: function (obj, type, handler, id) {
+ var pre = '_leaflet_',
+ touches = this._pointers;
+
+ var cb = function (e) {
+ for (var i = 0; i < touches.length; i++) {
+ if (touches[i].pointerId === e.pointerId) {
+ touches.splice(i, 1);
+ break;
+ }
+ }
+
+ e.touches = touches.slice();
+ e.changedTouches = [e];
+
+ handler(e);
+ };
+
+ obj[pre + 'touchend' + id] = cb;
+ obj.addEventListener(this.POINTER_UP, cb, false);
+ obj.addEventListener(this.POINTER_CANCEL, cb, false);
+
+ return this;
+ },
+
+ removePointerListener: function (obj, type, id) {
+ var pre = '_leaflet_',
+ cb = obj[pre + type + id];
+
+ switch (type) {
+ case 'touchstart':
+ obj.removeEventListener(this.POINTER_DOWN, cb, false);
+ break;
+ case 'touchmove':
+ obj.removeEventListener(this.POINTER_MOVE, cb, false);
+ break;
+ case 'touchend':
+ obj.removeEventListener(this.POINTER_UP, cb, false);
+ obj.removeEventListener(this.POINTER_CANCEL, cb, false);
+ break;
+ }
+
+ return this;
+ }
+});
+
+
+/*
+ * L.Handler.TouchZoom is used by L.Map to add pinch zoom on supported mobile browsers.
+ */
+
+L.Map.mergeOptions({
+ touchZoom: L.Browser.touch && !L.Browser.android23,
+ bounceAtZoomLimits: true
+});
+
+L.Map.TouchZoom = L.Handler.extend({
+ addHooks: function () {
+ L.DomEvent.on(this._map._container, 'touchstart', this._onTouchStart, this);
+ },
+
+ removeHooks: function () {
+ L.DomEvent.off(this._map._container, 'touchstart', this._onTouchStart, this);
+ },
+
+ _onTouchStart: function (e) {
+ var map = this._map;
+
+ if (!e.touches || e.touches.length !== 2 || map._animatingZoom || this._zooming) { return; }
+
+ var p1 = map.mouseEventToLayerPoint(e.touches[0]),
+ p2 = map.mouseEventToLayerPoint(e.touches[1]),
+ viewCenter = map._getCenterLayerPoint();
+
+ this._startCenter = p1.add(p2)._divideBy(2);
+ this._startDist = p1.distanceTo(p2);
+
+ this._moved = false;
+ this._zooming = true;
+
+ this._centerOffset = viewCenter.subtract(this._startCenter);
+
+ if (map._panAnim) {
+ map._panAnim.stop();
+ }
+
+ L.DomEvent
+ .on(document, 'touchmove', this._onTouchMove, this)
+ .on(document, 'touchend', this._onTouchEnd, this);
+
+ L.DomEvent.preventDefault(e);
+ },
+
+ _onTouchMove: function (e) {
+ var map = this._map;
+
+ if (!e.touches || e.touches.length !== 2 || !this._zooming) { return; }
+
+ var p1 = map.mouseEventToLayerPoint(e.touches[0]),
+ p2 = map.mouseEventToLayerPoint(e.touches[1]);
+
+ this._scale = p1.distanceTo(p2) / this._startDist;
+ this._delta = p1._add(p2)._divideBy(2)._subtract(this._startCenter);
+
+ if (this._scale === 1) { return; }
+
+ if (!map.options.bounceAtZoomLimits) {
+ if ((map.getZoom() === map.getMinZoom() && this._scale < 1) ||
+ (map.getZoom() === map.getMaxZoom() && this._scale > 1)) { return; }
+ }
+
+ if (!this._moved) {
+ L.DomUtil.addClass(map._mapPane, 'leaflet-touching');
+
+ map
+ .fire('movestart')
+ .fire('zoomstart');
+
+ this._moved = true;
+ }
+
+ L.Util.cancelAnimFrame(this._animRequest);
+ this._animRequest = L.Util.requestAnimFrame(
+ this._updateOnMove, this, true, this._map._container);
+
+ L.DomEvent.preventDefault(e);
+ },
+
+ _updateOnMove: function () {
+ var map = this._map,
+ origin = this._getScaleOrigin(),
+ center = map.layerPointToLatLng(origin),
+ zoom = map.getScaleZoom(this._scale);
+
+ map._animateZoom(center, zoom, this._startCenter, this._scale, this._delta);
+ },
+
+ _onTouchEnd: function () {
+ if (!this._moved || !this._zooming) {
+ this._zooming = false;
+ return;
+ }
+
+ var map = this._map;
+
+ this._zooming = false;
+ L.DomUtil.removeClass(map._mapPane, 'leaflet-touching');
+ L.Util.cancelAnimFrame(this._animRequest);
+
+ L.DomEvent
+ .off(document, 'touchmove', this._onTouchMove)
+ .off(document, 'touchend', this._onTouchEnd);
+
+ var origin = this._getScaleOrigin(),
+ center = map.layerPointToLatLng(origin),
+
+ oldZoom = map.getZoom(),
+ floatZoomDelta = map.getScaleZoom(this._scale) - oldZoom,
+ roundZoomDelta = (floatZoomDelta > 0 ?
+ Math.ceil(floatZoomDelta) : Math.floor(floatZoomDelta)),
+
+ zoom = map._limitZoom(oldZoom + roundZoomDelta),
+ scale = map.getZoomScale(zoom) / this._scale;
+
+ map._animateZoom(center, zoom, origin, scale);
+ },
+
+ _getScaleOrigin: function () {
+ var centerOffset = this._centerOffset.subtract(this._delta).divideBy(this._scale);
+ return this._startCenter.add(centerOffset);
+ }
+});
+
+L.Map.addInitHook('addHandler', 'touchZoom', L.Map.TouchZoom);
+
+
+/*
+ * L.Map.Tap is used to enable mobile hacks like quick taps and long hold.
+ */
+
+L.Map.mergeOptions({
+ tap: true,
+ tapTolerance: 15
+});
+
+L.Map.Tap = L.Handler.extend({
+ addHooks: function () {
+ L.DomEvent.on(this._map._container, 'touchstart', this._onDown, this);
+ },
+
+ removeHooks: function () {
+ L.DomEvent.off(this._map._container, 'touchstart', this._onDown, this);
+ },
+
+ _onDown: function (e) {
+ if (!e.touches) { return; }
+
+ L.DomEvent.preventDefault(e);
+
+ this._fireClick = true;
+
+ // don't simulate click or track longpress if more than 1 touch
+ if (e.touches.length > 1) {
+ this._fireClick = false;
+ clearTimeout(this._holdTimeout);
+ return;
+ }
+
+ var first = e.touches[0],
+ el = first.target;
+
+ this._startPos = this._newPos = new L.Point(first.clientX, first.clientY);
+
+ // if touching a link, highlight it
+ if (el.tagName && el.tagName.toLowerCase() === 'a') {
+ L.DomUtil.addClass(el, 'leaflet-active');
+ }
+
+ // simulate long hold but setting a timeout
+ this._holdTimeout = setTimeout(L.bind(function () {
+ if (this._isTapValid()) {
+ this._fireClick = false;
+ this._onUp();
+ this._simulateEvent('contextmenu', first);
+ }
+ }, this), 1000);
+
+ L.DomEvent
+ .on(document, 'touchmove', this._onMove, this)
+ .on(document, 'touchend', this._onUp, this);
+ },
+
+ _onUp: function (e) {
+ clearTimeout(this._holdTimeout);
+
+ L.DomEvent
+ .off(document, 'touchmove', this._onMove, this)
+ .off(document, 'touchend', this._onUp, this);
+
+ if (this._fireClick && e && e.changedTouches) {
+
+ var first = e.changedTouches[0],
+ el = first.target;
+
+ if (el && el.tagName && el.tagName.toLowerCase() === 'a') {
+ L.DomUtil.removeClass(el, 'leaflet-active');
+ }
+
+ // simulate click if the touch didn't move too much
+ if (this._isTapValid()) {
+ this._simulateEvent('click', first);
+ }
+ }
+ },
+
+ _isTapValid: function () {
+ return this._newPos.distanceTo(this._startPos) <= this._map.options.tapTolerance;
+ },
+
+ _onMove: function (e) {
+ var first = e.touches[0];
+ this._newPos = new L.Point(first.clientX, first.clientY);
+ },
+
+ _simulateEvent: function (type, e) {
+ var simulatedEvent = document.createEvent('MouseEvents');
+
+ simulatedEvent._simulated = true;
+ e.target._simulatedClick = true;
+
+ simulatedEvent.initMouseEvent(
+ type, true, true, window, 1,
+ e.screenX, e.screenY,
+ e.clientX, e.clientY,
+ false, false, false, false, 0, null);
+
+ e.target.dispatchEvent(simulatedEvent);
+ }
+});
+
+if (L.Browser.touch && !L.Browser.pointer) {
+ L.Map.addInitHook('addHandler', 'tap', L.Map.Tap);
+}
+
+
+/*
+ * L.Handler.ShiftDragZoom is used to add shift-drag zoom interaction to the map
+ * (zoom to a selected bounding box), enabled by default.
+ */
+
+L.Map.mergeOptions({
+ boxZoom: true
+});
+
+L.Map.BoxZoom = L.Handler.extend({
+ initialize: function (map) {
+ this._map = map;
+ this._container = map._container;
+ this._pane = map._panes.overlayPane;
+ this._moved = false;
+ },
+
+ addHooks: function () {
+ L.DomEvent.on(this._container, 'mousedown', this._onMouseDown, this);
+ },
+
+ removeHooks: function () {
+ L.DomEvent.off(this._container, 'mousedown', this._onMouseDown);
+ this._moved = false;
+ },
+
+ moved: function () {
+ return this._moved;
+ },
+
+ _onMouseDown: function (e) {
+ this._moved = false;
+
+ if (!e.shiftKey || ((e.which !== 1) && (e.button !== 1))) { return false; }
+
+ L.DomUtil.disableTextSelection();
+ L.DomUtil.disableImageDrag();
+
+ this._startLayerPoint = this._map.mouseEventToLayerPoint(e);
+
+ L.DomEvent
+ .on(document, 'mousemove', this._onMouseMove, this)
+ .on(document, 'mouseup', this._onMouseUp, this)
+ .on(document, 'keydown', this._onKeyDown, this);
+ },
+
+ _onMouseMove: function (e) {
+ if (!this._moved) {
+ this._box = L.DomUtil.create('div', 'leaflet-zoom-box', this._pane);
+ L.DomUtil.setPosition(this._box, this._startLayerPoint);
+
+ //TODO refactor: move cursor to styles
+ this._container.style.cursor = 'crosshair';
+ this._map.fire('boxzoomstart');
+ }
+
+ var startPoint = this._startLayerPoint,
+ box = this._box,
+
+ layerPoint = this._map.mouseEventToLayerPoint(e),
+ offset = layerPoint.subtract(startPoint),
+
+ newPos = new L.Point(
+ Math.min(layerPoint.x, startPoint.x),
+ Math.min(layerPoint.y, startPoint.y));
+
+ L.DomUtil.setPosition(box, newPos);
+
+ this._moved = true;
+
+ // TODO refactor: remove hardcoded 4 pixels
+ box.style.width = (Math.max(0, Math.abs(offset.x) - 4)) + 'px';
+ box.style.height = (Math.max(0, Math.abs(offset.y) - 4)) + 'px';
+ },
+
+ _finish: function () {
+ if (this._moved) {
+ this._pane.removeChild(this._box);
+ this._container.style.cursor = '';
+ }
+
+ L.DomUtil.enableTextSelection();
+ L.DomUtil.enableImageDrag();
+
+ L.DomEvent
+ .off(document, 'mousemove', this._onMouseMove)
+ .off(document, 'mouseup', this._onMouseUp)
+ .off(document, 'keydown', this._onKeyDown);
+ },
+
+ _onMouseUp: function (e) {
+
+ this._finish();
+
+ var map = this._map,
+ layerPoint = map.mouseEventToLayerPoint(e);
+
+ if (this._startLayerPoint.equals(layerPoint)) { return; }
+
+ var bounds = new L.LatLngBounds(
+ map.layerPointToLatLng(this._startLayerPoint),
+ map.layerPointToLatLng(layerPoint));
+
+ map.fitBounds(bounds);
+
+ map.fire('boxzoomend', {
+ boxZoomBounds: bounds
+ });
+ },
+
+ _onKeyDown: function (e) {
+ if (e.keyCode === 27) {
+ this._finish();
+ }
+ }
+});
+
+L.Map.addInitHook('addHandler', 'boxZoom', L.Map.BoxZoom);
+
+
+/*
+ * L.Map.Keyboard is handling keyboard interaction with the map, enabled by default.
+ */
+
+L.Map.mergeOptions({
+ keyboard: true,
+ keyboardPanOffset: 80,
+ keyboardZoomOffset: 1
+});
+
+L.Map.Keyboard = L.Handler.extend({
+
+ keyCodes: {
+ left: [37],
+ right: [39],
+ down: [40],
+ up: [38],
+ zoomIn: [187, 107, 61, 171],
+ zoomOut: [189, 109, 173]
+ },
+
+ initialize: function (map) {
+ this._map = map;
+
+ this._setPanOffset(map.options.keyboardPanOffset);
+ this._setZoomOffset(map.options.keyboardZoomOffset);
+ },
+
+ addHooks: function () {
+ var container = this._map._container;
+
+ // make the container focusable by tabbing
+ if (container.tabIndex === -1) {
+ container.tabIndex = '0';
+ }
+
+ L.DomEvent
+ .on(container, 'focus', this._onFocus, this)
+ .on(container, 'blur', this._onBlur, this)
+ .on(container, 'mousedown', this._onMouseDown, this);
+
+ this._map
+ .on('focus', this._addHooks, this)
+ .on('blur', this._removeHooks, this);
+ },
+
+ removeHooks: function () {
+ this._removeHooks();
+
+ var container = this._map._container;
+
+ L.DomEvent
+ .off(container, 'focus', this._onFocus, this)
+ .off(container, 'blur', this._onBlur, this)
+ .off(container, 'mousedown', this._onMouseDown, this);
+
+ this._map
+ .off('focus', this._addHooks, this)
+ .off('blur', this._removeHooks, this);
+ },
+
+ _onMouseDown: function () {
+ if (this._focused) { return; }
+
+ var body = document.body,
+ docEl = document.documentElement,
+ top = body.scrollTop || docEl.scrollTop,
+ left = body.scrollLeft || docEl.scrollLeft;
+
+ this._map._container.focus();
+
+ window.scrollTo(left, top);
+ },
+
+ _onFocus: function () {
+ this._focused = true;
+ this._map.fire('focus');
+ },
+
+ _onBlur: function () {
+ this._focused = false;
+ this._map.fire('blur');
+ },
+
+ _setPanOffset: function (pan) {
+ var keys = this._panKeys = {},
+ codes = this.keyCodes,
+ i, len;
+
+ for (i = 0, len = codes.left.length; i < len; i++) {
+ keys[codes.left[i]] = [-1 * pan, 0];
+ }
+ for (i = 0, len = codes.right.length; i < len; i++) {
+ keys[codes.right[i]] = [pan, 0];
+ }
+ for (i = 0, len = codes.down.length; i < len; i++) {
+ keys[codes.down[i]] = [0, pan];
+ }
+ for (i = 0, len = codes.up.length; i < len; i++) {
+ keys[codes.up[i]] = [0, -1 * pan];
+ }
+ },
+
+ _setZoomOffset: function (zoom) {
+ var keys = this._zoomKeys = {},
+ codes = this.keyCodes,
+ i, len;
+
+ for (i = 0, len = codes.zoomIn.length; i < len; i++) {
+ keys[codes.zoomIn[i]] = zoom;
+ }
+ for (i = 0, len = codes.zoomOut.length; i < len; i++) {
+ keys[codes.zoomOut[i]] = -zoom;
+ }
+ },
+
+ _addHooks: function () {
+ L.DomEvent.on(document, 'keydown', this._onKeyDown, this);
+ },
+
+ _removeHooks: function () {
+ L.DomEvent.off(document, 'keydown', this._onKeyDown, this);
+ },
+
+ _onKeyDown: function (e) {
+ var key = e.keyCode,
+ map = this._map;
+
+ if (key in this._panKeys) {
+
+ if (map._panAnim && map._panAnim._inProgress) { return; }
+
+ map.panBy(this._panKeys[key]);
+
+ if (map.options.maxBounds) {
+ map.panInsideBounds(map.options.maxBounds);
+ }
+
+ } else if (key in this._zoomKeys) {
+ map.setZoom(map.getZoom() + this._zoomKeys[key]);
+
+ } else {
+ return;
+ }
+
+ L.DomEvent.stop(e);
+ }
+});
+
+L.Map.addInitHook('addHandler', 'keyboard', L.Map.Keyboard);
+
+
+/*
+ * L.Handler.MarkerDrag is used internally by L.Marker to make the markers draggable.
+ */
+
+L.Handler.MarkerDrag = L.Handler.extend({
+ initialize: function (marker) {
+ this._marker = marker;
+ },
+
+ addHooks: function () {
+ var icon = this._marker._icon;
+ if (!this._draggable) {
+ this._draggable = new L.Draggable(icon, icon);
+ }
+
+ this._draggable
+ .on('dragstart', this._onDragStart, this)
+ .on('drag', this._onDrag, this)
+ .on('dragend', this._onDragEnd, this);
+ this._draggable.enable();
+ L.DomUtil.addClass(this._marker._icon, 'leaflet-marker-draggable');
+ },
+
+ removeHooks: function () {
+ this._draggable
+ .off('dragstart', this._onDragStart, this)
+ .off('drag', this._onDrag, this)
+ .off('dragend', this._onDragEnd, this);
+
+ this._draggable.disable();
+ L.DomUtil.removeClass(this._marker._icon, 'leaflet-marker-draggable');
+ },
+
+ moved: function () {
+ return this._draggable && this._draggable._moved;
+ },
+
+ _onDragStart: function () {
+ this._marker
+ .closePopup()
+ .fire('movestart')
+ .fire('dragstart');
+ },
+
+ _onDrag: function () {
+ var marker = this._marker,
+ shadow = marker._shadow,
+ iconPos = L.DomUtil.getPosition(marker._icon),
+ latlng = marker._map.layerPointToLatLng(iconPos);
+
+ // update shadow position
+ if (shadow) {
+ L.DomUtil.setPosition(shadow, iconPos);
+ }
+
+ marker._latlng = latlng;
+
+ marker
+ .fire('move', {latlng: latlng})
+ .fire('drag');
+ },
+
+ _onDragEnd: function (e) {
+ this._marker
+ .fire('moveend')
+ .fire('dragend', e);
+ }
+});
+
+
+/*
+ * L.Control is a base class for implementing map controls. Handles positioning.
+ * All other controls extend from this class.
+ */
+
+L.Control = L.Class.extend({
+ options: {
+ position: 'topright'
+ },
+
+ initialize: function (options) {
+ L.setOptions(this, options);
+ },
+
+ getPosition: function () {
+ return this.options.position;
+ },
+
+ setPosition: function (position) {
+ var map = this._map;
+
+ if (map) {
+ map.removeControl(this);
+ }
+
+ this.options.position = position;
+
+ if (map) {
+ map.addControl(this);
+ }
+
+ return this;
+ },
+
+ getContainer: function () {
+ return this._container;
+ },
+
+ addTo: function (map) {
+ this._map = map;
+
+ var container = this._container = this.onAdd(map),
+ pos = this.getPosition(),
+ corner = map._controlCorners[pos];
+
+ L.DomUtil.addClass(container, 'leaflet-control');
+
+ if (pos.indexOf('bottom') !== -1) {
+ corner.insertBefore(container, corner.firstChild);
+ } else {
+ corner.appendChild(container);
+ }
+
+ return this;
+ },
+
+ removeFrom: function (map) {
+ var pos = this.getPosition(),
+ corner = map._controlCorners[pos];
+
+ corner.removeChild(this._container);
+ this._map = null;
+
+ if (this.onRemove) {
+ this.onRemove(map);
+ }
+
+ return this;
+ },
+
+ _refocusOnMap: function () {
+ if (this._map) {
+ this._map.getContainer().focus();
+ }
+ }
+});
+
+L.control = function (options) {
+ return new L.Control(options);
+};
+
+
+// adds control-related methods to L.Map
+
+L.Map.include({
+ addControl: function (control) {
+ control.addTo(this);
+ return this;
+ },
+
+ removeControl: function (control) {
+ control.removeFrom(this);
+ return this;
+ },
+
+ _initControlPos: function () {
+ var corners = this._controlCorners = {},
+ l = 'leaflet-',
+ container = this._controlContainer =
+ L.DomUtil.create('div', l + 'control-container', this._container);
+
+ function createCorner(vSide, hSide) {
+ var className = l + vSide + ' ' + l + hSide;
+
+ corners[vSide + hSide] = L.DomUtil.create('div', className, container);
+ }
+
+ createCorner('top', 'left');
+ createCorner('top', 'right');
+ createCorner('bottom', 'left');
+ createCorner('bottom', 'right');
+ },
+
+ _clearControlPos: function () {
+ this._container.removeChild(this._controlContainer);
+ }
+});
+
+
+/*
+ * L.Control.Zoom is used for the default zoom buttons on the map.
+ */
+
+L.Control.Zoom = L.Control.extend({
+ options: {
+ position: 'topleft',
+ zoomInText: '+',
+ zoomInTitle: 'Zoom in',
+ zoomOutText: '-',
+ zoomOutTitle: 'Zoom out'
+ },
+
+ onAdd: function (map) {
+ var zoomName = 'leaflet-control-zoom',
+ container = L.DomUtil.create('div', zoomName + ' leaflet-bar');
+
+ this._map = map;
+
+ this._zoomInButton = this._createButton(
+ this.options.zoomInText, this.options.zoomInTitle,
+ zoomName + '-in', container, this._zoomIn, this);
+ this._zoomOutButton = this._createButton(
+ this.options.zoomOutText, this.options.zoomOutTitle,
+ zoomName + '-out', container, this._zoomOut, this);
+
+ this._updateDisabled();
+ map.on('zoomend zoomlevelschange', this._updateDisabled, this);
+
+ return container;
+ },
+
+ onRemove: function (map) {
+ map.off('zoomend zoomlevelschange', this._updateDisabled, this);
+ },
+
+ _zoomIn: function (e) {
+ this._map.zoomIn(e.shiftKey ? 3 : 1);
+ },
+
+ _zoomOut: function (e) {
+ this._map.zoomOut(e.shiftKey ? 3 : 1);
+ },
+
+ _createButton: function (html, title, className, container, fn, context) {
+ var link = L.DomUtil.create('a', className, container);
+ link.innerHTML = html;
+ link.href = '#';
+ link.title = title;
+
+ var stop = L.DomEvent.stopPropagation;
+
+ L.DomEvent
+ .on(link, 'click', stop)
+ .on(link, 'mousedown', stop)
+ .on(link, 'dblclick', stop)
+ .on(link, 'click', L.DomEvent.preventDefault)
+ .on(link, 'click', fn, context)
+ .on(link, 'click', this._refocusOnMap, context);
+
+ return link;
+ },
+
+ _updateDisabled: function () {
+ var map = this._map,
+ className = 'leaflet-disabled';
+
+ L.DomUtil.removeClass(this._zoomInButton, className);
+ L.DomUtil.removeClass(this._zoomOutButton, className);
+
+ if (map._zoom === map.getMinZoom()) {
+ L.DomUtil.addClass(this._zoomOutButton, className);
+ }
+ if (map._zoom === map.getMaxZoom()) {
+ L.DomUtil.addClass(this._zoomInButton, className);
+ }
+ }
+});
+
+L.Map.mergeOptions({
+ zoomControl: true
+});
+
+L.Map.addInitHook(function () {
+ if (this.options.zoomControl) {
+ this.zoomControl = new L.Control.Zoom();
+ this.addControl(this.zoomControl);
+ }
+});
+
+L.control.zoom = function (options) {
+ return new L.Control.Zoom(options);
+};
+
+
+
+/*
+ * L.Control.Attribution is used for displaying attribution on the map (added by default).
+ */
+
+L.Control.Attribution = L.Control.extend({
+ options: {
+ position: 'bottomright',
+ prefix: 'Leaflet '
+ },
+
+ initialize: function (options) {
+ L.setOptions(this, options);
+
+ this._attributions = {};
+ },
+
+ onAdd: function (map) {
+ this._container = L.DomUtil.create('div', 'leaflet-control-attribution');
+ L.DomEvent.disableClickPropagation(this._container);
+
+ for (var i in map._layers) {
+ if (map._layers[i].getAttribution) {
+ this.addAttribution(map._layers[i].getAttribution());
+ }
+ }
+
+ map
+ .on('layeradd', this._onLayerAdd, this)
+ .on('layerremove', this._onLayerRemove, this);
+
+ this._update();
+
+ return this._container;
+ },
+
+ onRemove: function (map) {
+ map
+ .off('layeradd', this._onLayerAdd)
+ .off('layerremove', this._onLayerRemove);
+
+ },
+
+ setPrefix: function (prefix) {
+ this.options.prefix = prefix;
+ this._update();
+ return this;
+ },
+
+ addAttribution: function (text) {
+ if (!text) { return; }
+
+ if (!this._attributions[text]) {
+ this._attributions[text] = 0;
+ }
+ this._attributions[text]++;
+
+ this._update();
+
+ return this;
+ },
+
+ removeAttribution: function (text) {
+ if (!text) { return; }
+
+ if (this._attributions[text]) {
+ this._attributions[text]--;
+ this._update();
+ }
+
+ return this;
+ },
+
+ _update: function () {
+ if (!this._map) { return; }
+
+ var attribs = [];
+
+ for (var i in this._attributions) {
+ if (this._attributions[i]) {
+ attribs.push(i);
+ }
+ }
+
+ var prefixAndAttribs = [];
+
+ if (this.options.prefix) {
+ prefixAndAttribs.push(this.options.prefix);
+ }
+ if (attribs.length) {
+ prefixAndAttribs.push(attribs.join(', '));
+ }
+
+ this._container.innerHTML = prefixAndAttribs.join(' | ');
+ },
+
+ _onLayerAdd: function (e) {
+ if (e.layer.getAttribution) {
+ this.addAttribution(e.layer.getAttribution());
+ }
+ },
+
+ _onLayerRemove: function (e) {
+ if (e.layer.getAttribution) {
+ this.removeAttribution(e.layer.getAttribution());
+ }
+ }
+});
+
+L.Map.mergeOptions({
+ attributionControl: true
+});
+
+L.Map.addInitHook(function () {
+ if (this.options.attributionControl) {
+ this.attributionControl = (new L.Control.Attribution()).addTo(this);
+ }
+});
+
+L.control.attribution = function (options) {
+ return new L.Control.Attribution(options);
+};
+
+
+/*
+ * L.Control.Scale is used for displaying metric/imperial scale on the map.
+ */
+
+L.Control.Scale = L.Control.extend({
+ options: {
+ position: 'bottomleft',
+ maxWidth: 100,
+ metric: true,
+ imperial: true,
+ updateWhenIdle: false
+ },
+
+ onAdd: function (map) {
+ this._map = map;
+
+ var className = 'leaflet-control-scale',
+ container = L.DomUtil.create('div', className),
+ options = this.options;
+
+ this._addScales(options, className, container);
+
+ map.on(options.updateWhenIdle ? 'moveend' : 'move', this._update, this);
+ map.whenReady(this._update, this);
+
+ return container;
+ },
+
+ onRemove: function (map) {
+ map.off(this.options.updateWhenIdle ? 'moveend' : 'move', this._update, this);
+ },
+
+ _addScales: function (options, className, container) {
+ if (options.metric) {
+ this._mScale = L.DomUtil.create('div', className + '-line', container);
+ }
+ if (options.imperial) {
+ this._iScale = L.DomUtil.create('div', className + '-line', container);
+ }
+ },
+
+ _update: function () {
+ var bounds = this._map.getBounds(),
+ centerLat = bounds.getCenter().lat,
+ halfWorldMeters = 6378137 * Math.PI * Math.cos(centerLat * Math.PI / 180),
+ dist = halfWorldMeters * (bounds.getNorthEast().lng - bounds.getSouthWest().lng) / 180,
+
+ size = this._map.getSize(),
+ options = this.options,
+ maxMeters = 0;
+
+ if (size.x > 0) {
+ maxMeters = dist * (options.maxWidth / size.x);
+ }
+
+ this._updateScales(options, maxMeters);
+ },
+
+ _updateScales: function (options, maxMeters) {
+ if (options.metric && maxMeters) {
+ this._updateMetric(maxMeters);
+ }
+
+ if (options.imperial && maxMeters) {
+ this._updateImperial(maxMeters);
+ }
+ },
+
+ _updateMetric: function (maxMeters) {
+ var meters = this._getRoundNum(maxMeters);
+
+ this._mScale.style.width = this._getScaleWidth(meters / maxMeters) + 'px';
+ this._mScale.innerHTML = meters < 1000 ? meters + ' m' : (meters / 1000) + ' km';
+ },
+
+ _updateImperial: function (maxMeters) {
+ var maxFeet = maxMeters * 3.2808399,
+ scale = this._iScale,
+ maxMiles, miles, feet;
+
+ if (maxFeet > 5280) {
+ maxMiles = maxFeet / 5280;
+ miles = this._getRoundNum(maxMiles);
+
+ scale.style.width = this._getScaleWidth(miles / maxMiles) + 'px';
+ scale.innerHTML = miles + ' mi';
+
+ } else {
+ feet = this._getRoundNum(maxFeet);
+
+ scale.style.width = this._getScaleWidth(feet / maxFeet) + 'px';
+ scale.innerHTML = feet + ' ft';
+ }
+ },
+
+ _getScaleWidth: function (ratio) {
+ return Math.round(this.options.maxWidth * ratio) - 10;
+ },
+
+ _getRoundNum: function (num) {
+ var pow10 = Math.pow(10, (Math.floor(num) + '').length - 1),
+ d = num / pow10;
+
+ d = d >= 10 ? 10 : d >= 5 ? 5 : d >= 3 ? 3 : d >= 2 ? 2 : 1;
+
+ return pow10 * d;
+ }
+});
+
+L.control.scale = function (options) {
+ return new L.Control.Scale(options);
+};
+
+
+/*
+ * L.Control.Layers is a control to allow users to switch between different layers on the map.
+ */
+
+L.Control.Layers = L.Control.extend({
+ options: {
+ collapsed: true,
+ position: 'topright',
+ autoZIndex: true
+ },
+
+ initialize: function (baseLayers, overlays, options) {
+ L.setOptions(this, options);
+
+ this._layers = {};
+ this._lastZIndex = 0;
+ this._handlingClick = false;
+
+ for (var i in baseLayers) {
+ this._addLayer(baseLayers[i], i);
+ }
+
+ for (i in overlays) {
+ this._addLayer(overlays[i], i, true);
+ }
+ },
+
+ onAdd: function (map) {
+ this._initLayout();
+ this._update();
+
+ map
+ .on('layeradd', this._onLayerChange, this)
+ .on('layerremove', this._onLayerChange, this);
+
+ return this._container;
+ },
+
+ onRemove: function (map) {
+ map
+ .off('layeradd', this._onLayerChange)
+ .off('layerremove', this._onLayerChange);
+ },
+
+ addBaseLayer: function (layer, name) {
+ this._addLayer(layer, name);
+ this._update();
+ return this;
+ },
+
+ addOverlay: function (layer, name) {
+ this._addLayer(layer, name, true);
+ this._update();
+ return this;
+ },
+
+ removeLayer: function (layer) {
+ var id = L.stamp(layer);
+ delete this._layers[id];
+ this._update();
+ return this;
+ },
+
+ _initLayout: function () {
+ var className = 'leaflet-control-layers',
+ container = this._container = L.DomUtil.create('div', className);
+
+ //Makes this work on IE10 Touch devices by stopping it from firing a mouseout event when the touch is released
+ container.setAttribute('aria-haspopup', true);
+
+ if (!L.Browser.touch) {
+ L.DomEvent
+ .disableClickPropagation(container)
+ .disableScrollPropagation(container);
+ } else {
+ L.DomEvent.on(container, 'click', L.DomEvent.stopPropagation);
+ }
+
+ var form = this._form = L.DomUtil.create('form', className + '-list');
+
+ if (this.options.collapsed) {
+ if (!L.Browser.android) {
+ L.DomEvent
+ .on(container, 'mouseover', this._expand, this)
+ .on(container, 'mouseout', this._collapse, this);
+ }
+ var link = this._layersLink = L.DomUtil.create('a', className + '-toggle', container);
+ link.href = '#';
+ link.title = 'Layers';
+
+ if (L.Browser.touch) {
+ L.DomEvent
+ .on(link, 'click', L.DomEvent.stop)
+ .on(link, 'click', this._expand, this);
+ }
+ else {
+ L.DomEvent.on(link, 'focus', this._expand, this);
+ }
+ //Work around for Firefox android issue https://github.com/Leaflet/Leaflet/issues/2033
+ L.DomEvent.on(form, 'click', function () {
+ setTimeout(L.bind(this._onInputClick, this), 0);
+ }, this);
+
+ this._map.on('click', this._collapse, this);
+ // TODO keyboard accessibility
+ } else {
+ this._expand();
+ }
+
+ this._baseLayersList = L.DomUtil.create('div', className + '-base', form);
+ this._separator = L.DomUtil.create('div', className + '-separator', form);
+ this._overlaysList = L.DomUtil.create('div', className + '-overlays', form);
+
+ container.appendChild(form);
+ },
+
+ _addLayer: function (layer, name, overlay) {
+ var id = L.stamp(layer);
+
+ this._layers[id] = {
+ layer: layer,
+ name: name,
+ overlay: overlay
+ };
+
+ if (this.options.autoZIndex && layer.setZIndex) {
+ this._lastZIndex++;
+ layer.setZIndex(this._lastZIndex);
+ }
+ },
+
+ _update: function () {
+ if (!this._container) {
+ return;
+ }
+
+ this._baseLayersList.innerHTML = '';
+ this._overlaysList.innerHTML = '';
+
+ var baseLayersPresent = false,
+ overlaysPresent = false,
+ i, obj;
+
+ for (i in this._layers) {
+ obj = this._layers[i];
+ this._addItem(obj);
+ overlaysPresent = overlaysPresent || obj.overlay;
+ baseLayersPresent = baseLayersPresent || !obj.overlay;
+ }
+
+ this._separator.style.display = overlaysPresent && baseLayersPresent ? '' : 'none';
+ },
+
+ _onLayerChange: function (e) {
+ var obj = this._layers[L.stamp(e.layer)];
+
+ if (!obj) { return; }
+
+ if (!this._handlingClick) {
+ this._update();
+ }
+
+ var type = obj.overlay ?
+ (e.type === 'layeradd' ? 'overlayadd' : 'overlayremove') :
+ (e.type === 'layeradd' ? 'baselayerchange' : null);
+
+ if (type) {
+ this._map.fire(type, obj);
+ }
+ },
+
+ // IE7 bugs out if you create a radio dynamically, so you have to do it this hacky way (see http://bit.ly/PqYLBe)
+ _createRadioElement: function (name, checked) {
+
+ var radioHtml = ' ';
+
+ var radioFragment = document.createElement('div');
+ radioFragment.innerHTML = radioHtml;
+
+ return radioFragment.firstChild;
+ },
+
+ _addItem: function (obj) {
+ var label = document.createElement('label'),
+ input,
+ checked = this._map.hasLayer(obj.layer);
+
+ if (obj.overlay) {
+ input = document.createElement('input');
+ input.type = 'checkbox';
+ input.className = 'leaflet-control-layers-selector';
+ input.defaultChecked = checked;
+ } else {
+ input = this._createRadioElement('leaflet-base-layers', checked);
+ }
+
+ input.layerId = L.stamp(obj.layer);
+
+ L.DomEvent.on(input, 'click', this._onInputClick, this);
+
+ var name = document.createElement('span');
+ name.innerHTML = ' ' + obj.name;
+
+ label.appendChild(input);
+ label.appendChild(name);
+
+ var container = obj.overlay ? this._overlaysList : this._baseLayersList;
+ container.appendChild(label);
+
+ return label;
+ },
+
+ _onInputClick: function () {
+ var i, input, obj,
+ inputs = this._form.getElementsByTagName('input'),
+ inputsLen = inputs.length;
+
+ this._handlingClick = true;
+
+ for (i = 0; i < inputsLen; i++) {
+ input = inputs[i];
+ obj = this._layers[input.layerId];
+
+ if (input.checked && !this._map.hasLayer(obj.layer)) {
+ this._map.addLayer(obj.layer);
+
+ } else if (!input.checked && this._map.hasLayer(obj.layer)) {
+ this._map.removeLayer(obj.layer);
+ }
+ }
+
+ this._handlingClick = false;
+
+ this._refocusOnMap();
+ },
+
+ _expand: function () {
+ L.DomUtil.addClass(this._container, 'leaflet-control-layers-expanded');
+ },
+
+ _collapse: function () {
+ this._container.className = this._container.className.replace(' leaflet-control-layers-expanded', '');
+ }
+});
+
+L.control.layers = function (baseLayers, overlays, options) {
+ return new L.Control.Layers(baseLayers, overlays, options);
+};
+
+
+/*
+ * L.PosAnimation is used by Leaflet internally for pan animations.
+ */
+
+L.PosAnimation = L.Class.extend({
+ includes: L.Mixin.Events,
+
+ run: function (el, newPos, duration, easeLinearity) { // (HTMLElement, Point[, Number, Number])
+ this.stop();
+
+ this._el = el;
+ this._inProgress = true;
+ this._newPos = newPos;
+
+ this.fire('start');
+
+ el.style[L.DomUtil.TRANSITION] = 'all ' + (duration || 0.25) +
+ 's cubic-bezier(0,0,' + (easeLinearity || 0.5) + ',1)';
+
+ L.DomEvent.on(el, L.DomUtil.TRANSITION_END, this._onTransitionEnd, this);
+ L.DomUtil.setPosition(el, newPos);
+
+ // toggle reflow, Chrome flickers for some reason if you don't do this
+ L.Util.falseFn(el.offsetWidth);
+
+ // there's no native way to track value updates of transitioned properties, so we imitate this
+ this._stepTimer = setInterval(L.bind(this._onStep, this), 50);
+ },
+
+ stop: function () {
+ if (!this._inProgress) { return; }
+
+ // if we just removed the transition property, the element would jump to its final position,
+ // so we need to make it stay at the current position
+
+ L.DomUtil.setPosition(this._el, this._getPos());
+ this._onTransitionEnd();
+ L.Util.falseFn(this._el.offsetWidth); // force reflow in case we are about to start a new animation
+ },
+
+ _onStep: function () {
+ var stepPos = this._getPos();
+ if (!stepPos) {
+ this._onTransitionEnd();
+ return;
+ }
+ // jshint camelcase: false
+ // make L.DomUtil.getPosition return intermediate position value during animation
+ this._el._leaflet_pos = stepPos;
+
+ this.fire('step');
+ },
+
+ // you can't easily get intermediate values of properties animated with CSS3 Transitions,
+ // we need to parse computed style (in case of transform it returns matrix string)
+
+ _transformRe: /([-+]?(?:\d*\.)?\d+)\D*, ([-+]?(?:\d*\.)?\d+)\D*\)/,
+
+ _getPos: function () {
+ var left, top, matches,
+ el = this._el,
+ style = window.getComputedStyle(el);
+
+ if (L.Browser.any3d) {
+ matches = style[L.DomUtil.TRANSFORM].match(this._transformRe);
+ if (!matches) { return; }
+ left = parseFloat(matches[1]);
+ top = parseFloat(matches[2]);
+ } else {
+ left = parseFloat(style.left);
+ top = parseFloat(style.top);
+ }
+
+ return new L.Point(left, top, true);
+ },
+
+ _onTransitionEnd: function () {
+ L.DomEvent.off(this._el, L.DomUtil.TRANSITION_END, this._onTransitionEnd, this);
+
+ if (!this._inProgress) { return; }
+ this._inProgress = false;
+
+ this._el.style[L.DomUtil.TRANSITION] = '';
+
+ // jshint camelcase: false
+ // make sure L.DomUtil.getPosition returns the final position value after animation
+ this._el._leaflet_pos = this._newPos;
+
+ clearInterval(this._stepTimer);
+
+ this.fire('step').fire('end');
+ }
+
+});
+
+
+/*
+ * Extends L.Map to handle panning animations.
+ */
+
+L.Map.include({
+
+ setView: function (center, zoom, options) {
+
+ zoom = zoom === undefined ? this._zoom : this._limitZoom(zoom);
+ center = this._limitCenter(L.latLng(center), zoom, this.options.maxBounds);
+ options = options || {};
+
+ if (this._panAnim) {
+ this._panAnim.stop();
+ }
+
+ if (this._loaded && !options.reset && options !== true) {
+
+ if (options.animate !== undefined) {
+ options.zoom = L.extend({animate: options.animate}, options.zoom);
+ options.pan = L.extend({animate: options.animate}, options.pan);
+ }
+
+ // try animating pan or zoom
+ var animated = (this._zoom !== zoom) ?
+ this._tryAnimatedZoom && this._tryAnimatedZoom(center, zoom, options.zoom) :
+ this._tryAnimatedPan(center, options.pan);
+
+ if (animated) {
+ // prevent resize handler call, the view will refresh after animation anyway
+ clearTimeout(this._sizeTimer);
+ return this;
+ }
+ }
+
+ // animation didn't start, just reset the map view
+ this._resetView(center, zoom);
+
+ return this;
+ },
+
+ panBy: function (offset, options) {
+ offset = L.point(offset).round();
+ options = options || {};
+
+ if (!offset.x && !offset.y) {
+ return this;
+ }
+
+ if (!this._panAnim) {
+ this._panAnim = new L.PosAnimation();
+
+ this._panAnim.on({
+ 'step': this._onPanTransitionStep,
+ 'end': this._onPanTransitionEnd
+ }, this);
+ }
+
+ // don't fire movestart if animating inertia
+ if (!options.noMoveStart) {
+ this.fire('movestart');
+ }
+
+ // animate pan unless animate: false specified
+ if (options.animate !== false) {
+ L.DomUtil.addClass(this._mapPane, 'leaflet-pan-anim');
+
+ var newPos = this._getMapPanePos().subtract(offset);
+ this._panAnim.run(this._mapPane, newPos, options.duration || 0.25, options.easeLinearity);
+ } else {
+ this._rawPanBy(offset);
+ this.fire('move').fire('moveend');
+ }
+
+ return this;
+ },
+
+ _onPanTransitionStep: function () {
+ this.fire('move');
+ },
+
+ _onPanTransitionEnd: function () {
+ L.DomUtil.removeClass(this._mapPane, 'leaflet-pan-anim');
+ this.fire('moveend');
+ },
+
+ _tryAnimatedPan: function (center, options) {
+ // difference between the new and current centers in pixels
+ var offset = this._getCenterOffset(center)._floor();
+
+ // don't animate too far unless animate: true specified in options
+ if ((options && options.animate) !== true && !this.getSize().contains(offset)) { return false; }
+
+ this.panBy(offset, options);
+
+ return true;
+ }
+});
+
+
+/*
+ * L.PosAnimation fallback implementation that powers Leaflet pan animations
+ * in browsers that don't support CSS3 Transitions.
+ */
+
+L.PosAnimation = L.DomUtil.TRANSITION ? L.PosAnimation : L.PosAnimation.extend({
+
+ run: function (el, newPos, duration, easeLinearity) { // (HTMLElement, Point[, Number, Number])
+ this.stop();
+
+ this._el = el;
+ this._inProgress = true;
+ this._duration = duration || 0.25;
+ this._easeOutPower = 1 / Math.max(easeLinearity || 0.5, 0.2);
+
+ this._startPos = L.DomUtil.getPosition(el);
+ this._offset = newPos.subtract(this._startPos);
+ this._startTime = +new Date();
+
+ this.fire('start');
+
+ this._animate();
+ },
+
+ stop: function () {
+ if (!this._inProgress) { return; }
+
+ this._step();
+ this._complete();
+ },
+
+ _animate: function () {
+ // animation loop
+ this._animId = L.Util.requestAnimFrame(this._animate, this);
+ this._step();
+ },
+
+ _step: function () {
+ var elapsed = (+new Date()) - this._startTime,
+ duration = this._duration * 1000;
+
+ if (elapsed < duration) {
+ this._runFrame(this._easeOut(elapsed / duration));
+ } else {
+ this._runFrame(1);
+ this._complete();
+ }
+ },
+
+ _runFrame: function (progress) {
+ var pos = this._startPos.add(this._offset.multiplyBy(progress));
+ L.DomUtil.setPosition(this._el, pos);
+
+ this.fire('step');
+ },
+
+ _complete: function () {
+ L.Util.cancelAnimFrame(this._animId);
+
+ this._inProgress = false;
+ this.fire('end');
+ },
+
+ _easeOut: function (t) {
+ return 1 - Math.pow(1 - t, this._easeOutPower);
+ }
+});
+
+
+/*
+ * Extends L.Map to handle zoom animations.
+ */
+
+L.Map.mergeOptions({
+ zoomAnimation: true,
+ zoomAnimationThreshold: 4
+});
+
+if (L.DomUtil.TRANSITION) {
+
+ L.Map.addInitHook(function () {
+ // don't animate on browsers without hardware-accelerated transitions or old Android/Opera
+ this._zoomAnimated = this.options.zoomAnimation && L.DomUtil.TRANSITION &&
+ L.Browser.any3d && !L.Browser.android23 && !L.Browser.mobileOpera;
+
+ // zoom transitions run with the same duration for all layers, so if one of transitionend events
+ // happens after starting zoom animation (propagating to the map pane), we know that it ended globally
+ if (this._zoomAnimated) {
+ L.DomEvent.on(this._mapPane, L.DomUtil.TRANSITION_END, this._catchTransitionEnd, this);
+ }
+ });
+}
+
+L.Map.include(!L.DomUtil.TRANSITION ? {} : {
+
+ _catchTransitionEnd: function (e) {
+ if (this._animatingZoom && e.propertyName.indexOf('transform') >= 0) {
+ this._onZoomTransitionEnd();
+ }
+ },
+
+ _nothingToAnimate: function () {
+ return !this._container.getElementsByClassName('leaflet-zoom-animated').length;
+ },
+
+ _tryAnimatedZoom: function (center, zoom, options) {
+
+ if (this._animatingZoom) { return true; }
+
+ options = options || {};
+
+ // don't animate if disabled, not supported or zoom difference is too large
+ if (!this._zoomAnimated || options.animate === false || this._nothingToAnimate() ||
+ Math.abs(zoom - this._zoom) > this.options.zoomAnimationThreshold) { return false; }
+
+ // offset is the pixel coords of the zoom origin relative to the current center
+ var scale = this.getZoomScale(zoom),
+ offset = this._getCenterOffset(center)._divideBy(1 - 1 / scale),
+ origin = this._getCenterLayerPoint()._add(offset);
+
+ // don't animate if the zoom origin isn't within one screen from the current center, unless forced
+ if (options.animate !== true && !this.getSize().contains(offset)) { return false; }
+
+ this
+ .fire('movestart')
+ .fire('zoomstart');
+
+ this._animateZoom(center, zoom, origin, scale, null, true);
+
+ return true;
+ },
+
+ _animateZoom: function (center, zoom, origin, scale, delta, backwards) {
+
+ this._animatingZoom = true;
+
+ // put transform transition on all layers with leaflet-zoom-animated class
+ L.DomUtil.addClass(this._mapPane, 'leaflet-zoom-anim');
+
+ // remember what center/zoom to set after animation
+ this._animateToCenter = center;
+ this._animateToZoom = zoom;
+
+ // disable any dragging during animation
+ if (L.Draggable) {
+ L.Draggable._disabled = true;
+ }
+
+ this.fire('zoomanim', {
+ center: center,
+ zoom: zoom,
+ origin: origin,
+ scale: scale,
+ delta: delta,
+ backwards: backwards
+ });
+ },
+
+ _onZoomTransitionEnd: function () {
+
+ this._animatingZoom = false;
+
+ L.DomUtil.removeClass(this._mapPane, 'leaflet-zoom-anim');
+
+ this._resetView(this._animateToCenter, this._animateToZoom, true, true);
+
+ if (L.Draggable) {
+ L.Draggable._disabled = false;
+ }
+ }
+});
+
+
+/*
+ Zoom animation logic for L.TileLayer.
+*/
+
+L.TileLayer.include({
+ _animateZoom: function (e) {
+ if (!this._animating) {
+ this._animating = true;
+ this._prepareBgBuffer();
+ }
+
+ var bg = this._bgBuffer,
+ transform = L.DomUtil.TRANSFORM,
+ initialTransform = e.delta ? L.DomUtil.getTranslateString(e.delta) : bg.style[transform],
+ scaleStr = L.DomUtil.getScaleString(e.scale, e.origin);
+
+ bg.style[transform] = e.backwards ?
+ scaleStr + ' ' + initialTransform :
+ initialTransform + ' ' + scaleStr;
+ },
+
+ _endZoomAnim: function () {
+ var front = this._tileContainer,
+ bg = this._bgBuffer;
+
+ front.style.visibility = '';
+ front.parentNode.appendChild(front); // Bring to fore
+
+ // force reflow
+ L.Util.falseFn(bg.offsetWidth);
+
+ this._animating = false;
+ },
+
+ _clearBgBuffer: function () {
+ var map = this._map;
+
+ if (map && !map._animatingZoom && !map.touchZoom._zooming) {
+ this._bgBuffer.innerHTML = '';
+ this._bgBuffer.style[L.DomUtil.TRANSFORM] = '';
+ }
+ },
+
+ _prepareBgBuffer: function () {
+
+ var front = this._tileContainer,
+ bg = this._bgBuffer;
+
+ // if foreground layer doesn't have many tiles but bg layer does,
+ // keep the existing bg layer and just zoom it some more
+
+ var bgLoaded = this._getLoadedTilesPercentage(bg),
+ frontLoaded = this._getLoadedTilesPercentage(front);
+
+ if (bg && bgLoaded > 0.5 && frontLoaded < 0.5) {
+
+ front.style.visibility = 'hidden';
+ this._stopLoadingImages(front);
+ return;
+ }
+
+ // prepare the buffer to become the front tile pane
+ bg.style.visibility = 'hidden';
+ bg.style[L.DomUtil.TRANSFORM] = '';
+
+ // switch out the current layer to be the new bg layer (and vice-versa)
+ this._tileContainer = bg;
+ bg = this._bgBuffer = front;
+
+ this._stopLoadingImages(bg);
+
+ //prevent bg buffer from clearing right after zoom
+ clearTimeout(this._clearBgBufferTimer);
+ },
+
+ _getLoadedTilesPercentage: function (container) {
+ var tiles = container.getElementsByTagName('img'),
+ i, len, count = 0;
+
+ for (i = 0, len = tiles.length; i < len; i++) {
+ if (tiles[i].complete) {
+ count++;
+ }
+ }
+ return count / len;
+ },
+
+ // stops loading all tiles in the background layer
+ _stopLoadingImages: function (container) {
+ var tiles = Array.prototype.slice.call(container.getElementsByTagName('img')),
+ i, len, tile;
+
+ for (i = 0, len = tiles.length; i < len; i++) {
+ tile = tiles[i];
+
+ if (!tile.complete) {
+ tile.onload = L.Util.falseFn;
+ tile.onerror = L.Util.falseFn;
+ tile.src = L.Util.emptyImageUrl;
+
+ tile.parentNode.removeChild(tile);
+ }
+ }
+ }
+});
+
+
+/*
+ * Provides L.Map with convenient shortcuts for using browser geolocation features.
+ */
+
+L.Map.include({
+ _defaultLocateOptions: {
+ watch: false,
+ setView: false,
+ maxZoom: Infinity,
+ timeout: 10000,
+ maximumAge: 0,
+ enableHighAccuracy: false
+ },
+
+ locate: function (/*Object*/ options) {
+
+ options = this._locateOptions = L.extend(this._defaultLocateOptions, options);
+
+ if (!navigator.geolocation) {
+ this._handleGeolocationError({
+ code: 0,
+ message: 'Geolocation not supported.'
+ });
+ return this;
+ }
+
+ var onResponse = L.bind(this._handleGeolocationResponse, this),
+ onError = L.bind(this._handleGeolocationError, this);
+
+ if (options.watch) {
+ this._locationWatchId =
+ navigator.geolocation.watchPosition(onResponse, onError, options);
+ } else {
+ navigator.geolocation.getCurrentPosition(onResponse, onError, options);
+ }
+ return this;
+ },
+
+ stopLocate: function () {
+ if (navigator.geolocation) {
+ navigator.geolocation.clearWatch(this._locationWatchId);
+ }
+ if (this._locateOptions) {
+ this._locateOptions.setView = false;
+ }
+ return this;
+ },
+
+ _handleGeolocationError: function (error) {
+ var c = error.code,
+ message = error.message ||
+ (c === 1 ? 'permission denied' :
+ (c === 2 ? 'position unavailable' : 'timeout'));
+
+ if (this._locateOptions.setView && !this._loaded) {
+ this.fitWorld();
+ }
+
+ this.fire('locationerror', {
+ code: c,
+ message: 'Geolocation error: ' + message + '.'
+ });
+ },
+
+ _handleGeolocationResponse: function (pos) {
+ var lat = pos.coords.latitude,
+ lng = pos.coords.longitude,
+ latlng = new L.LatLng(lat, lng),
+
+ latAccuracy = 180 * pos.coords.accuracy / 40075017,
+ lngAccuracy = latAccuracy / Math.cos(L.LatLng.DEG_TO_RAD * lat),
+
+ bounds = L.latLngBounds(
+ [lat - latAccuracy, lng - lngAccuracy],
+ [lat + latAccuracy, lng + lngAccuracy]),
+
+ options = this._locateOptions;
+
+ if (options.setView) {
+ var zoom = Math.min(this.getBoundsZoom(bounds), options.maxZoom);
+ this.setView(latlng, zoom);
+ }
+
+ var data = {
+ latlng: latlng,
+ bounds: bounds,
+ timestamp: pos.timestamp
+ };
+
+ for (var i in pos.coords) {
+ if (typeof pos.coords[i] === 'number') {
+ data[i] = pos.coords[i];
+ }
+ }
+
+ this.fire('locationfound', data);
+ }
+});
+
+
+}(window, document));
\ No newline at end of file
diff --git a/node_modules/leaflet-draw/docs/examples-0.7.x/libs/leaflet.css b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/leaflet.css
new file mode 100644
index 00000000..12325502
--- /dev/null
+++ b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/leaflet.css
@@ -0,0 +1,478 @@
+/* required styles */
+
+.leaflet-map-pane,
+.leaflet-tile,
+.leaflet-marker-icon,
+.leaflet-marker-shadow,
+.leaflet-tile-pane,
+.leaflet-tile-container,
+.leaflet-overlay-pane,
+.leaflet-shadow-pane,
+.leaflet-marker-pane,
+.leaflet-popup-pane,
+.leaflet-overlay-pane svg,
+.leaflet-zoom-box,
+.leaflet-image-layer,
+.leaflet-layer {
+ position: absolute;
+ left: 0;
+ top: 0;
+ }
+.leaflet-container {
+ overflow: hidden;
+ -ms-touch-action: none;
+ }
+.leaflet-tile,
+.leaflet-marker-icon,
+.leaflet-marker-shadow {
+ -webkit-user-select: none;
+ -moz-user-select: none;
+ user-select: none;
+ -webkit-user-drag: none;
+ }
+.leaflet-marker-icon,
+.leaflet-marker-shadow {
+ display: block;
+ }
+/* map is broken in FF if you have max-width: 100% on tiles */
+.leaflet-container img {
+ max-width: none !important;
+ }
+/* stupid Android 2 doesn't understand "max-width: none" properly */
+.leaflet-container img.leaflet-image-layer {
+ max-width: 15000px !important;
+ }
+.leaflet-tile {
+ filter: inherit;
+ visibility: hidden;
+ }
+.leaflet-tile-loaded {
+ visibility: inherit;
+ }
+.leaflet-zoom-box {
+ width: 0;
+ height: 0;
+ }
+/* workaround for https://bugzilla.mozilla.org/show_bug.cgi?id=888319 */
+.leaflet-overlay-pane svg {
+ -moz-user-select: none;
+ }
+
+.leaflet-tile-pane { z-index: 2; }
+.leaflet-objects-pane { z-index: 3; }
+.leaflet-overlay-pane { z-index: 4; }
+.leaflet-shadow-pane { z-index: 5; }
+.leaflet-marker-pane { z-index: 6; }
+.leaflet-popup-pane { z-index: 7; }
+
+.leaflet-vml-shape {
+ width: 1px;
+ height: 1px;
+ }
+.lvml {
+ behavior: url(#default#VML);
+ display: inline-block;
+ position: absolute;
+ }
+
+
+/* control positioning */
+
+.leaflet-control {
+ position: relative;
+ z-index: 7;
+ pointer-events: auto;
+ }
+.leaflet-top,
+.leaflet-bottom {
+ position: absolute;
+ z-index: 1000;
+ pointer-events: none;
+ }
+.leaflet-top {
+ top: 0;
+ }
+.leaflet-right {
+ right: 0;
+ }
+.leaflet-bottom {
+ bottom: 0;
+ }
+.leaflet-left {
+ left: 0;
+ }
+.leaflet-control {
+ float: left;
+ clear: both;
+ }
+.leaflet-right .leaflet-control {
+ float: right;
+ }
+.leaflet-top .leaflet-control {
+ margin-top: 10px;
+ }
+.leaflet-bottom .leaflet-control {
+ margin-bottom: 10px;
+ }
+.leaflet-left .leaflet-control {
+ margin-left: 10px;
+ }
+.leaflet-right .leaflet-control {
+ margin-right: 10px;
+ }
+
+
+/* zoom and fade animations */
+
+.leaflet-fade-anim .leaflet-tile,
+.leaflet-fade-anim .leaflet-popup {
+ opacity: 0;
+ -webkit-transition: opacity 0.2s linear;
+ -moz-transition: opacity 0.2s linear;
+ -o-transition: opacity 0.2s linear;
+ transition: opacity 0.2s linear;
+ }
+.leaflet-fade-anim .leaflet-tile-loaded,
+.leaflet-fade-anim .leaflet-map-pane .leaflet-popup {
+ opacity: 1;
+ }
+
+.leaflet-zoom-anim .leaflet-zoom-animated {
+ -webkit-transition: -webkit-transform 0.25s cubic-bezier(0,0,0.25,1);
+ -moz-transition: -moz-transform 0.25s cubic-bezier(0,0,0.25,1);
+ -o-transition: -o-transform 0.25s cubic-bezier(0,0,0.25,1);
+ transition: transform 0.25s cubic-bezier(0,0,0.25,1);
+ }
+.leaflet-zoom-anim .leaflet-tile,
+.leaflet-pan-anim .leaflet-tile,
+.leaflet-touching .leaflet-zoom-animated {
+ -webkit-transition: none;
+ -moz-transition: none;
+ -o-transition: none;
+ transition: none;
+ }
+
+.leaflet-zoom-anim .leaflet-zoom-hide {
+ visibility: hidden;
+ }
+
+
+/* cursors */
+
+.leaflet-clickable {
+ cursor: pointer;
+ }
+.leaflet-container {
+ cursor: -webkit-grab;
+ cursor: -moz-grab;
+ }
+.leaflet-popup-pane,
+.leaflet-control {
+ cursor: auto;
+ }
+.leaflet-dragging .leaflet-container,
+.leaflet-dragging .leaflet-clickable {
+ cursor: move;
+ cursor: -webkit-grabbing;
+ cursor: -moz-grabbing;
+ }
+
+
+/* visual tweaks */
+
+.leaflet-container {
+ background: #ddd;
+ outline: 0;
+ }
+.leaflet-container a {
+ color: #0078A8;
+ }
+.leaflet-container a.leaflet-active {
+ outline: 2px solid orange;
+ }
+.leaflet-zoom-box {
+ border: 2px dotted #38f;
+ background: rgba(255,255,255,0.5);
+ }
+
+
+/* general typography */
+.leaflet-container {
+ font: 12px/1.5 "Helvetica Neue", Arial, Helvetica, sans-serif;
+ }
+
+
+/* general toolbar styles */
+
+.leaflet-bar {
+ box-shadow: 0 1px 5px rgba(0,0,0,0.65);
+ border-radius: 4px;
+ }
+.leaflet-bar a,
+.leaflet-bar a:hover {
+ background-color: #fff;
+ border-bottom: 1px solid #ccc;
+ width: 26px;
+ height: 26px;
+ line-height: 26px;
+ display: block;
+ text-align: center;
+ text-decoration: none;
+ color: black;
+ }
+.leaflet-bar a,
+.leaflet-control-layers-toggle {
+ background-position: 50% 50%;
+ background-repeat: no-repeat;
+ display: block;
+ }
+.leaflet-bar a:hover {
+ background-color: #f4f4f4;
+ }
+.leaflet-bar a:first-child {
+ border-top-left-radius: 4px;
+ border-top-right-radius: 4px;
+ }
+.leaflet-bar a:last-child {
+ border-bottom-left-radius: 4px;
+ border-bottom-right-radius: 4px;
+ border-bottom: none;
+ }
+.leaflet-bar a.leaflet-disabled {
+ cursor: default;
+ background-color: #f4f4f4;
+ color: #bbb;
+ }
+
+.leaflet-touch .leaflet-bar a {
+ width: 30px;
+ height: 30px;
+ line-height: 30px;
+ }
+
+
+/* zoom control */
+
+.leaflet-control-zoom-in,
+.leaflet-control-zoom-out {
+ font: bold 18px 'Lucida Console', Monaco, monospace;
+ text-indent: 1px;
+ }
+.leaflet-control-zoom-out {
+ font-size: 20px;
+ }
+
+.leaflet-touch .leaflet-control-zoom-in {
+ font-size: 22px;
+ }
+.leaflet-touch .leaflet-control-zoom-out {
+ font-size: 24px;
+ }
+
+
+/* layers control */
+
+.leaflet-control-layers {
+ box-shadow: 0 1px 5px rgba(0,0,0,0.4);
+ background: #fff;
+ border-radius: 5px;
+ }
+.leaflet-control-layers-toggle {
+ background-image: url(images/layers.png);
+ width: 36px;
+ height: 36px;
+ }
+.leaflet-retina .leaflet-control-layers-toggle {
+ background-image: url(images/layers-2x.png);
+ background-size: 26px 26px;
+ }
+.leaflet-touch .leaflet-control-layers-toggle {
+ width: 44px;
+ height: 44px;
+ }
+.leaflet-control-layers .leaflet-control-layers-list,
+.leaflet-control-layers-expanded .leaflet-control-layers-toggle {
+ display: none;
+ }
+.leaflet-control-layers-expanded .leaflet-control-layers-list {
+ display: block;
+ position: relative;
+ }
+.leaflet-control-layers-expanded {
+ padding: 6px 10px 6px 6px;
+ color: #333;
+ background: #fff;
+ }
+.leaflet-control-layers-selector {
+ margin-top: 2px;
+ position: relative;
+ top: 1px;
+ }
+.leaflet-control-layers label {
+ display: block;
+ }
+.leaflet-control-layers-separator {
+ height: 0;
+ border-top: 1px solid #ddd;
+ margin: 5px -10px 5px -6px;
+ }
+
+
+/* attribution and scale controls */
+
+.leaflet-container .leaflet-control-attribution {
+ background: #fff;
+ background: rgba(255, 255, 255, 0.7);
+ margin: 0;
+ }
+.leaflet-control-attribution,
+.leaflet-control-scale-line {
+ padding: 0 5px;
+ color: #333;
+ }
+.leaflet-control-attribution a {
+ text-decoration: none;
+ }
+.leaflet-control-attribution a:hover {
+ text-decoration: underline;
+ }
+.leaflet-container .leaflet-control-attribution,
+.leaflet-container .leaflet-control-scale {
+ font-size: 11px;
+ }
+.leaflet-left .leaflet-control-scale {
+ margin-left: 5px;
+ }
+.leaflet-bottom .leaflet-control-scale {
+ margin-bottom: 5px;
+ }
+.leaflet-control-scale-line {
+ border: 2px solid #777;
+ border-top: none;
+ line-height: 1.1;
+ padding: 2px 5px 1px;
+ font-size: 11px;
+ white-space: nowrap;
+ overflow: hidden;
+ -moz-box-sizing: content-box;
+ box-sizing: content-box;
+
+ background: #fff;
+ background: rgba(255, 255, 255, 0.5);
+ }
+.leaflet-control-scale-line:not(:first-child) {
+ border-top: 2px solid #777;
+ border-bottom: none;
+ margin-top: -2px;
+ }
+.leaflet-control-scale-line:not(:first-child):not(:last-child) {
+ border-bottom: 2px solid #777;
+ }
+
+.leaflet-touch .leaflet-control-attribution,
+.leaflet-touch .leaflet-control-layers,
+.leaflet-touch .leaflet-bar {
+ box-shadow: none;
+ }
+.leaflet-touch .leaflet-control-layers,
+.leaflet-touch .leaflet-bar {
+ border: 2px solid rgba(0,0,0,0.2);
+ background-clip: padding-box;
+ }
+
+
+/* popup */
+
+.leaflet-popup {
+ position: absolute;
+ text-align: center;
+ }
+.leaflet-popup-content-wrapper {
+ padding: 1px;
+ text-align: left;
+ border-radius: 12px;
+ }
+.leaflet-popup-content {
+ margin: 13px 19px;
+ line-height: 1.4;
+ }
+.leaflet-popup-content p {
+ margin: 18px 0;
+ }
+.leaflet-popup-tip-container {
+ margin: 0 auto;
+ width: 40px;
+ height: 20px;
+ position: relative;
+ overflow: hidden;
+ }
+.leaflet-popup-tip {
+ width: 17px;
+ height: 17px;
+ padding: 1px;
+
+ margin: -10px auto 0;
+
+ -webkit-transform: rotate(45deg);
+ -moz-transform: rotate(45deg);
+ -ms-transform: rotate(45deg);
+ -o-transform: rotate(45deg);
+ transform: rotate(45deg);
+ }
+.leaflet-popup-content-wrapper,
+.leaflet-popup-tip {
+ background: white;
+
+ box-shadow: 0 3px 14px rgba(0,0,0,0.4);
+ }
+.leaflet-container a.leaflet-popup-close-button {
+ position: absolute;
+ top: 0;
+ right: 0;
+ padding: 4px 4px 0 0;
+ text-align: center;
+ width: 18px;
+ height: 14px;
+ font: 16px/14px Tahoma, Verdana, sans-serif;
+ color: #c3c3c3;
+ text-decoration: none;
+ font-weight: bold;
+ background: transparent;
+ }
+.leaflet-container a.leaflet-popup-close-button:hover {
+ color: #999;
+ }
+.leaflet-popup-scrolled {
+ overflow: auto;
+ border-bottom: 1px solid #ddd;
+ border-top: 1px solid #ddd;
+ }
+
+.leaflet-oldie .leaflet-popup-content-wrapper {
+ zoom: 1;
+ }
+.leaflet-oldie .leaflet-popup-tip {
+ width: 24px;
+ margin: 0 auto;
+
+ -ms-filter: "progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678)";
+ filter: progid:DXImageTransform.Microsoft.Matrix(M11=0.70710678, M12=0.70710678, M21=-0.70710678, M22=0.70710678);
+ }
+.leaflet-oldie .leaflet-popup-tip-container {
+ margin-top: -1px;
+ }
+
+.leaflet-oldie .leaflet-control-zoom,
+.leaflet-oldie .leaflet-control-layers,
+.leaflet-oldie .leaflet-popup-content-wrapper,
+.leaflet-oldie .leaflet-popup-tip {
+ border: 1px solid #999;
+ }
+
+
+/* div icon */
+
+.leaflet-div-icon {
+ background: #fff;
+ border: 1px solid #666;
+ }
diff --git a/node_modules/leaflet-draw/docs/examples-0.7.x/libs/leaflet.geometryutil.js b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/leaflet.geometryutil.js
new file mode 100644
index 00000000..0d629541
--- /dev/null
+++ b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/leaflet.geometryutil.js
@@ -0,0 +1,682 @@
+// Packaging/modules magic dance.
+(function (factory) {
+ var L;
+ if (typeof define === 'function' && define.amd) {
+ // AMD
+ define(['leaflet'], factory);
+ } else if (typeof module !== 'undefined') {
+ // Node/CommonJS
+ L = require('leaflet');
+ module.exports = factory(L);
+ } else {
+ // Browser globals
+ if (typeof window.L === 'undefined')
+ throw 'Leaflet must be loaded first';
+ factory(window.L);
+ }
+}(function (L) {
+"use strict";
+
+/**
+ * @fileOverview Leaflet Geometry utilities for distances and linear referencing.
+ * @name L.GeometryUtil
+ */
+
+L.GeometryUtil = L.extend(L.GeometryUtil || {}, {
+
+ /**
+ Shortcut function for planar distance between two {L.LatLng} at current zoom.
+
+ @tutorial distance-length
+
+ @param {L.Map} map Leaflet map to be used for this method
+ @param {L.LatLng} latlngA geographical point A
+ @param {L.LatLng} latlngB geographical point B
+ @returns {Number} planar distance
+ */
+ distance: function (map, latlngA, latlngB) {
+ return map.latLngToLayerPoint(latlngA).distanceTo(map.latLngToLayerPoint(latlngB));
+ },
+
+ /**
+ Shortcut function for planar distance between a {L.LatLng} and a segment (A-B).
+ @param {L.Map} map Leaflet map to be used for this method
+ @param {L.LatLng} latlng - The position to search
+ @param {L.LatLng} latlngA geographical point A of the segment
+ @param {L.LatLng} latlngB geographical point B of the segment
+ @returns {Number} planar distance
+ */
+ distanceSegment: function (map, latlng, latlngA, latlngB) {
+ var p = map.latLngToLayerPoint(latlng),
+ p1 = map.latLngToLayerPoint(latlngA),
+ p2 = map.latLngToLayerPoint(latlngB);
+ return L.LineUtil.pointToSegmentDistance(p, p1, p2);
+ },
+
+ /**
+ Shortcut function for converting distance to readable distance.
+ @param {Number} distance distance to be converted
+ @param {String} unit 'metric' or 'imperial'
+ @returns {String} in yard or miles
+ */
+ readableDistance: function (distance, unit) {
+ var isMetric = (unit !== 'imperial'),
+ distanceStr;
+ if (isMetric) {
+ // show metres when distance is < 1km, then show km
+ if (distance > 1000) {
+ distanceStr = (distance / 1000).toFixed(2) + ' km';
+ }
+ else {
+ distanceStr = Math.ceil(distance) + ' m';
+ }
+ }
+ else {
+ distance *= 1.09361;
+ if (distance > 1760) {
+ distanceStr = (distance / 1760).toFixed(2) + ' miles';
+ }
+ else {
+ distanceStr = Math.ceil(distance) + ' yd';
+ }
+ }
+ return distanceStr;
+ },
+
+ /**
+ Returns true if the latlng belongs to segment A-B
+ @param {L.LatLng} latlng - The position to search
+ @param {L.LatLng} latlngA geographical point A of the segment
+ @param {L.LatLng} latlngB geographical point B of the segment
+ @param {?Number} [tolerance=0.2] tolerance to accept if latlng belongs really
+ @returns {boolean}
+ */
+ belongsSegment: function(latlng, latlngA, latlngB, tolerance) {
+ tolerance = tolerance === undefined ? 0.2 : tolerance;
+ var hypotenuse = latlngA.distanceTo(latlngB),
+ delta = latlngA.distanceTo(latlng) + latlng.distanceTo(latlngB) - hypotenuse;
+ return delta/hypotenuse < tolerance;
+ },
+
+ /**
+ * Returns total length of line
+ * @tutorial distance-length
+ *
+ * @param {L.Polyline|Array|Array} coords Set of coordinates
+ * @returns {Number} Total length (pixels for Point, meters for LatLng)
+ */
+ length: function (coords) {
+ var accumulated = L.GeometryUtil.accumulatedLengths(coords);
+ return accumulated.length > 0 ? accumulated[accumulated.length-1] : 0;
+ },
+
+ /**
+ * Returns a list of accumulated length along a line.
+ * @param {L.Polyline|Array|Array} coords Set of coordinates
+ * @returns {Array} Array of accumulated lengths (pixels for Point, meters for LatLng)
+ */
+ accumulatedLengths: function (coords) {
+ if (typeof coords.getLatLngs == 'function') {
+ coords = coords.getLatLngs();
+ }
+ if (coords.length === 0)
+ return [];
+ var total = 0,
+ lengths = [0];
+ for (var i = 0, n = coords.length - 1; i< n; i++) {
+ total += coords[i].distanceTo(coords[i+1]);
+ lengths.push(total);
+ }
+ return lengths;
+ },
+
+ /**
+ Returns the closest point of a {L.LatLng} on the segment (A-B)
+
+ @tutorial closest
+
+ @param {L.Map} map Leaflet map to be used for this method
+ @param {L.LatLng} latlng - The position to search
+ @param {L.LatLng} latlngA geographical point A of the segment
+ @param {L.LatLng} latlngB geographical point B of the segment
+ @returns {L.LatLng} Closest geographical point
+ */
+ closestOnSegment: function (map, latlng, latlngA, latlngB) {
+ var maxzoom = map.getMaxZoom();
+ if (maxzoom === Infinity)
+ maxzoom = map.getZoom();
+ var p = map.project(latlng, maxzoom),
+ p1 = map.project(latlngA, maxzoom),
+ p2 = map.project(latlngB, maxzoom),
+ closest = L.LineUtil.closestPointOnSegment(p, p1, p2);
+ return map.unproject(closest, maxzoom);
+ },
+
+ /**
+ Returns the closest latlng on layer.
+
+ Accept nested arrays
+
+ @tutorial closest
+
+ @param {L.Map} map Leaflet map to be used for this method
+ @param {Array|Array>|L.PolyLine|L.Polygon} layer - Layer that contains the result
+ @param {L.LatLng} latlng - The position to search
+ @param {?boolean} [vertices=false] - Whether to restrict to path vertices.
+ @returns {L.LatLng} Closest geographical point or null if layer param is incorrect
+ */
+ closest: function (map, layer, latlng, vertices) {
+
+ var latlngs,
+ mindist = Infinity,
+ result = null,
+ i, n, distance;
+
+ if (layer instanceof Array) {
+ // if layer is Array>
+ if (layer[0] instanceof Array && typeof layer[0][0] !== 'number') {
+ // if we have nested arrays, we calc the closest for each array
+ // recursive
+ for (var i = 0; i < layer.length; i++) {
+ var subResult = L.GeometryUtil.closest(map, layer[i], latlng, vertices);
+ if (subResult.distance < mindist) {
+ mindist = subResult.distance;
+ result = subResult;
+ }
+ }
+ return result;
+ } else if (layer[0] instanceof L.LatLng || typeof layer[0][0] === 'number') { // we could have a latlng as [x,y] with x & y numbers
+ layer = L.polyline(layer);
+ } else {
+ return result;
+ }
+ }
+
+ // if we don't have here a Polyline, that means layer is incorrect
+ // see https://github.com/makinacorpus/Leaflet.GeometryUtil/issues/23
+ if (! ( layer instanceof L.Polyline ) )
+ return result;
+
+ /**
+ * Flat an array upon a predicate, saying if we have to dig digger or not
+ * Specific use for Polygon, Polyline, MultiPolyline (0.7.7)
+ * Leaflet 1.0 change the structure of Polyline (could be MultiPolyline > nested arrays), idem for Polygon
+ */
+ function flattenArray(array, predicate, result) {
+
+ var index = -1,
+ length = array.length;
+
+ predicate || ( predicate = function(v) { return true } );
+ result || ( result = []);
+
+ if (predicate(array)) {
+ while (++index < length) {
+ var value = array[index];
+ if (predicate(value)) {
+ flattenArray(value, predicate, result);
+ } else {
+ result.push(value);
+ }
+ }
+ } else {
+ result.push(array);
+ }
+
+ return result;
+
+ }
+
+ latlngs = flattenArray(layer.getLatLngs().slice(0), function isFlattenable(value) {
+ return ( ( value instanceof Array && typeof value[0] !== 'number' ) && ! ( value instanceof L.LatLng ) )
+ });
+
+ // Lookup vertices
+ if (vertices) {
+ for(i = 0, n = latlngs.length; i < n; i++) {
+ var ll = latlngs[i];
+ distance = L.GeometryUtil.distance(map, latlng, ll);
+ if (distance < mindist) {
+ mindist = distance;
+ result = ll;
+ result.distance = distance;
+ }
+ }
+ return result;
+ }
+
+ // add the first point to close the polygon
+ if (layer instanceof L.Polygon) {
+ latlngs.push(latlngs[0]);
+ }
+
+ // Keep the closest point of all segments
+ for (i = 0, n = latlngs.length; i < n-1; i++) {
+ var latlngA = latlngs[i],
+ latlngB = latlngs[i+1];
+ distance = L.GeometryUtil.distanceSegment(map, latlng, latlngA, latlngB);
+ if (distance <= mindist) {
+ mindist = distance;
+ result = L.GeometryUtil.closestOnSegment(map, latlng, latlngA, latlngB);
+ result.distance = distance;
+ }
+ }
+ return result;
+ },
+
+ /**
+ Returns the closest layer to latlng among a list of layers.
+
+ @tutorial closest
+
+ @param {L.Map} map Leaflet map to be used for this method
+ @param {Array} layers Set of layers
+ @param {L.LatLng} latlng - The position to search
+ @returns {object} ``{layer, latlng, distance}`` or ``null`` if list is empty;
+ */
+ closestLayer: function (map, layers, latlng) {
+ var mindist = Infinity,
+ result = null,
+ ll = null,
+ distance = Infinity;
+
+ for (var i = 0, n = layers.length; i < n; i++) {
+ var layer = layers[i];
+ if (layer instanceof L.LayerGroup) {
+ // recursive
+ var subResult = L.GeometryUtil.closestLayer(map, layer.getLayers(), latlng);
+ if (subResult.distance < mindist) {
+ mindist = subResult.distance;
+ result = subResult;
+ }
+ } else {
+ // Single dimension, snap on points, else snap on closest
+ if (typeof layer.getLatLng == 'function') {
+ ll = layer.getLatLng();
+ distance = L.GeometryUtil.distance(map, latlng, ll);
+ }
+ else {
+ ll = L.GeometryUtil.closest(map, layer, latlng);
+ if (ll) distance = ll.distance; // Can return null if layer has no points.
+ }
+ if (distance < mindist) {
+ mindist = distance;
+ result = {layer: layer, latlng: ll, distance: distance};
+ }
+ }
+ }
+ return result;
+ },
+
+ /**
+ * Returns all layers within a radius of the given position, in an ascending order of distance.
+ @param {L.Map} map Leaflet map to be used for this method
+ @param {Array} layers - A list of layers.
+ @param {L.LatLng} latlng - The position to search
+ @param {?Number} [radius=Infinity] - Search radius in pixels
+ @return {object[]} an array of objects including layer within the radius, closest latlng, and distance
+ */
+ layersWithin: function(map, layers, latlng, radius) {
+ radius = typeof radius == 'number' ? radius : Infinity;
+
+ var results = [];
+ var ll = null;
+ var distance = 0;
+
+ for (var i = 0, n = layers.length; i < n; i++) {
+ var layer = layers[i];
+
+ if (typeof layer.getLatLng == 'function') {
+ ll = layer.getLatLng();
+ distance = L.GeometryUtil.distance(map, latlng, ll);
+ }
+ else {
+ ll = L.GeometryUtil.closest(map, layer, latlng);
+ if (ll) distance = ll.distance; // Can return null if layer has no points.
+ }
+
+ if (ll && distance < radius) {
+ results.push({layer: layer, latlng: ll, distance: distance});
+ }
+ }
+
+ var sortedResults = results.sort(function(a, b) {
+ return a.distance - b.distance;
+ });
+
+ return sortedResults;
+ },
+
+ /**
+ Returns the closest position from specified {LatLng} among specified layers,
+ with a maximum tolerance in pixels, providing snapping behaviour.
+
+ @tutorial closest
+
+ @param {L.Map} map Leaflet map to be used for this method
+ @param {Array} layers - A list of layers to snap on.
+ @param {L.LatLng} latlng - The position to snap
+ @param {?Number} [tolerance=Infinity] - Maximum number of pixels.
+ @param {?boolean} [withVertices=true] - Snap to layers vertices or segment points (not only vertex)
+ @returns {object} with snapped {LatLng} and snapped {Layer} or null if tolerance exceeded.
+ */
+ closestLayerSnap: function (map, layers, latlng, tolerance, withVertices) {
+ tolerance = typeof tolerance == 'number' ? tolerance : Infinity;
+ withVertices = typeof withVertices == 'boolean' ? withVertices : true;
+
+ var result = L.GeometryUtil.closestLayer(map, layers, latlng);
+ if (!result || result.distance > tolerance)
+ return null;
+
+ // If snapped layer is linear, try to snap on vertices (extremities and middle points)
+ if (withVertices && typeof result.layer.getLatLngs == 'function') {
+ var closest = L.GeometryUtil.closest(map, result.layer, result.latlng, true);
+ if (closest.distance < tolerance) {
+ result.latlng = closest;
+ result.distance = L.GeometryUtil.distance(map, closest, latlng);
+ }
+ }
+ return result;
+ },
+
+ /**
+ Returns the Point located on a segment at the specified ratio of the segment length.
+ @param {L.Point} pA coordinates of point A
+ @param {L.Point} pB coordinates of point B
+ @param {Number} the length ratio, expressed as a decimal between 0 and 1, inclusive.
+ @returns {L.Point} the interpolated point.
+ */
+ interpolateOnPointSegment: function (pA, pB, ratio) {
+ return L.point(
+ (pA.x * (1 - ratio)) + (ratio * pB.x),
+ (pA.y * (1 - ratio)) + (ratio * pB.y)
+ );
+ },
+
+ /**
+ Returns the coordinate of the point located on a line at the specified ratio of the line length.
+ @param {L.Map} map Leaflet map to be used for this method
+ @param {Array|L.PolyLine} latlngs Set of geographical points
+ @param {Number} ratio the length ratio, expressed as a decimal between 0 and 1, inclusive
+ @returns {Object} an object with latLng ({LatLng}) and predecessor ({Number}), the index of the preceding vertex in the Polyline
+ (-1 if the interpolated point is the first vertex)
+ */
+ interpolateOnLine: function (map, latLngs, ratio) {
+ latLngs = (latLngs instanceof L.Polyline) ? latLngs.getLatLngs() : latLngs;
+ var n = latLngs.length;
+ if (n < 2) {
+ return null;
+ }
+
+ // ensure the ratio is between 0 and 1;
+ ratio = Math.max(Math.min(ratio, 1), 0);
+
+ if (ratio === 0) {
+ return {
+ latLng: latLngs[0] instanceof L.LatLng ? latLngs[0] : L.latLng(latLngs[0]),
+ predecessor: -1
+ };
+ }
+ if (ratio == 1) {
+ return {
+ latLng: latLngs[latLngs.length -1] instanceof L.LatLng ? latLngs[latLngs.length -1] : L.latLng(latLngs[latLngs.length -1]),
+ predecessor: latLngs.length - 2
+ };
+ }
+
+ // project the LatLngs as Points,
+ // and compute total planar length of the line at max precision
+ var maxzoom = map.getMaxZoom();
+ if (maxzoom === Infinity)
+ maxzoom = map.getZoom();
+ var pts = [];
+ var lineLength = 0;
+ for(var i = 0; i < n; i++) {
+ pts[i] = map.project(latLngs[i], maxzoom);
+ if(i > 0)
+ lineLength += pts[i-1].distanceTo(pts[i]);
+ }
+
+ var ratioDist = lineLength * ratio;
+ var a = pts[0],
+ b = pts[1],
+ distA = 0,
+ distB = a.distanceTo(b);
+ // follow the line segments [ab], adding lengths,
+ // until we find the segment where the points should lie on
+ var index = 1;
+ for (; index < n && distB < ratioDist; index++) {
+ a = b;
+ distA = distB;
+ b = pts[index];
+ distB += a.distanceTo(b);
+ }
+ // compute the ratio relative to the segment [ab]
+ var segmentRatio = ((distB - distA) !== 0) ? ((ratioDist - distA) / (distB - distA)) : 0;
+ var interpolatedPoint = L.GeometryUtil.interpolateOnPointSegment(a, b, segmentRatio);
+ return {
+ latLng: map.unproject(interpolatedPoint, maxzoom),
+ predecessor: index-2
+ };
+ },
+
+ /**
+ Returns a float between 0 and 1 representing the location of the
+ closest point on polyline to the given latlng, as a fraction of total line length.
+ (opposite of L.GeometryUtil.interpolateOnLine())
+ @param {L.Map} map Leaflet map to be used for this method
+ @param {L.PolyLine} polyline Polyline on which the latlng will be search
+ @param {L.LatLng} latlng The position to search
+ @returns {Number} Float between 0 and 1
+ */
+ locateOnLine: function (map, polyline, latlng) {
+ var latlngs = polyline.getLatLngs();
+ if (latlng.equals(latlngs[0]))
+ return 0.0;
+ if (latlng.equals(latlngs[latlngs.length-1]))
+ return 1.0;
+
+ var point = L.GeometryUtil.closest(map, polyline, latlng, false),
+ lengths = L.GeometryUtil.accumulatedLengths(latlngs),
+ total_length = lengths[lengths.length-1],
+ portion = 0,
+ found = false;
+ for (var i=0, n = latlngs.length-1; i < n; i++) {
+ var l1 = latlngs[i],
+ l2 = latlngs[i+1];
+ portion = lengths[i];
+ if (L.GeometryUtil.belongsSegment(point, l1, l2)) {
+ portion += l1.distanceTo(point);
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ throw "Could not interpolate " + latlng.toString() + " within " + polyline.toString();
+ }
+ return portion / total_length;
+ },
+
+ /**
+ Returns a clone with reversed coordinates.
+ @param {L.PolyLine} polyline polyline to reverse
+ @returns {L.PolyLine} polyline reversed
+ */
+ reverse: function (polyline) {
+ return L.polyline(polyline.getLatLngs().slice(0).reverse());
+ },
+
+ /**
+ Returns a sub-part of the polyline, from start to end.
+ If start is superior to end, returns extraction from inverted line.
+ @param {L.Map} map Leaflet map to be used for this method
+ @param {L.PolyLine} polyline Polyline on which will be extracted the sub-part
+ @param {Number} start ratio, expressed as a decimal between 0 and 1, inclusive
+ @param {Number} end ratio, expressed as a decimal between 0 and 1, inclusive
+ @returns {Array} new polyline
+ */
+ extract: function (map, polyline, start, end) {
+ if (start > end) {
+ return L.GeometryUtil.extract(map, L.GeometryUtil.reverse(polyline), 1.0-start, 1.0-end);
+ }
+
+ // Bound start and end to [0-1]
+ start = Math.max(Math.min(start, 1), 0);
+ end = Math.max(Math.min(end, 1), 0);
+
+ var latlngs = polyline.getLatLngs(),
+ startpoint = L.GeometryUtil.interpolateOnLine(map, polyline, start),
+ endpoint = L.GeometryUtil.interpolateOnLine(map, polyline, end);
+ // Return single point if start == end
+ if (start == end) {
+ var point = L.GeometryUtil.interpolateOnLine(map, polyline, end);
+ return [point.latLng];
+ }
+ // Array.slice() works indexes at 0
+ if (startpoint.predecessor == -1)
+ startpoint.predecessor = 0;
+ if (endpoint.predecessor == -1)
+ endpoint.predecessor = 0;
+ var result = latlngs.slice(startpoint.predecessor+1, endpoint.predecessor+1);
+ result.unshift(startpoint.latLng);
+ result.push(endpoint.latLng);
+ return result;
+ },
+
+ /**
+ Returns true if first polyline ends where other second starts.
+ @param {L.PolyLine} polyline First polyline
+ @param {L.PolyLine} other Second polyline
+ @returns {bool}
+ */
+ isBefore: function (polyline, other) {
+ if (!other) return false;
+ var lla = polyline.getLatLngs(),
+ llb = other.getLatLngs();
+ return (lla[lla.length-1]).equals(llb[0]);
+ },
+
+ /**
+ Returns true if first polyline starts where second ends.
+ @param {L.PolyLine} polyline First polyline
+ @param {L.PolyLine} other Second polyline
+ @returns {bool}
+ */
+ isAfter: function (polyline, other) {
+ if (!other) return false;
+ var lla = polyline.getLatLngs(),
+ llb = other.getLatLngs();
+ return (lla[0]).equals(llb[llb.length-1]);
+ },
+
+ /**
+ Returns true if first polyline starts where second ends or start.
+ @param {L.PolyLine} polyline First polyline
+ @param {L.PolyLine} other Second polyline
+ @returns {bool}
+ */
+ startsAtExtremity: function (polyline, other) {
+ if (!other) return false;
+ var lla = polyline.getLatLngs(),
+ llb = other.getLatLngs(),
+ start = lla[0];
+ return start.equals(llb[0]) || start.equals(llb[llb.length-1]);
+ },
+
+ /**
+ Returns horizontal angle in degres between two points.
+ @param {L.Point} a Coordinates of point A
+ @param {L.Point} b Coordinates of point B
+ @returns {Number} horizontal angle
+ */
+ computeAngle: function(a, b) {
+ return (Math.atan2(b.y - a.y, b.x - a.x) * 180 / Math.PI);
+ },
+
+ /**
+ Returns slope (Ax+B) between two points.
+ @param {L.Point} a Coordinates of point A
+ @param {L.Point} b Coordinates of point B
+ @returns {Object} with ``a`` and ``b`` properties.
+ */
+ computeSlope: function(a, b) {
+ var s = (b.y - a.y) / (b.x - a.x),
+ o = a.y - (s * a.x);
+ return {'a': s, 'b': o};
+ },
+
+ /**
+ Returns LatLng of rotated point around specified LatLng center.
+ @param {L.LatLng} latlngPoint: point to rotate
+ @param {double} angleDeg: angle to rotate in degrees
+ @param {L.LatLng} latlngCenter: center of rotation
+ @returns {L.LatLng} rotated point
+ */
+ rotatePoint: function(map, latlngPoint, angleDeg, latlngCenter) {
+ var maxzoom = map.getMaxZoom();
+ if (maxzoom === Infinity)
+ maxzoom = map.getZoom();
+ var angleRad = angleDeg*Math.PI/180,
+ pPoint = map.project(latlngPoint, maxzoom),
+ pCenter = map.project(latlngCenter, maxzoom),
+ x2 = Math.cos(angleRad)*(pPoint.x-pCenter.x) - Math.sin(angleRad)*(pPoint.y-pCenter.y) + pCenter.x,
+ y2 = Math.sin(angleRad)*(pPoint.x-pCenter.x) + Math.cos(angleRad)*(pPoint.y-pCenter.y) + pCenter.y;
+ return map.unproject(new L.Point(x2,y2), maxzoom);
+ },
+
+ /**
+ Returns the bearing in degrees clockwise from north (0 degrees)
+ from the first L.LatLng to the second, at the first LatLng
+ @param {L.LatLng} latlng1: origin point of the bearing
+ @param {L.LatLng} latlng2: destination point of the bearing
+ @returns {float} degrees clockwise from north.
+ */
+ bearing: function(latlng1, latlng2) {
+ var rad = Math.PI / 180,
+ lat1 = latlng1.lat * rad,
+ lat2 = latlng2.lat * rad,
+ lon1 = latlng1.lng * rad,
+ lon2 = latlng2.lng * rad,
+ y = Math.sin(lon2 - lon1) * Math.cos(lat2),
+ x = Math.cos(lat1) * Math.sin(lat2) -
+ Math.sin(lat1) * Math.cos(lat2) * Math.cos(lon2 - lon1);
+
+ var bearing = ((Math.atan2(y, x) * 180 / Math.PI) + 360) % 360;
+ return bearing >= 180 ? bearing-360 : bearing;
+ },
+
+ /**
+ Returns the point that is a distance and heading away from
+ the given origin point.
+ @param {L.LatLng} latlng: origin point
+ @param {float}: heading in degrees, clockwise from 0 degrees north.
+ @param {float}: distance in meters
+ @returns {L.latLng} the destination point.
+ Many thanks to Chris Veness at http://www.movable-type.co.uk/scripts/latlong.html
+ for a great reference and examples.
+ */
+ destination: function(latlng, heading, distance) {
+ heading = (heading + 360) % 360;
+ var rad = Math.PI / 180,
+ radInv = 180 / Math.PI,
+ R = 6378137, // approximation of Earth's radius
+ lon1 = latlng.lng * rad,
+ lat1 = latlng.lat * rad,
+ rheading = heading * rad,
+ sinLat1 = Math.sin(lat1),
+ cosLat1 = Math.cos(lat1),
+ cosDistR = Math.cos(distance / R),
+ sinDistR = Math.sin(distance / R),
+ lat2 = Math.asin(sinLat1 * cosDistR + cosLat1 *
+ sinDistR * Math.cos(rheading)),
+ lon2 = lon1 + Math.atan2(Math.sin(rheading) * sinDistR *
+ cosLat1, cosDistR - sinLat1 * Math.sin(lat2));
+ lon2 = lon2 * radInv;
+ lon2 = lon2 > 180 ? lon2 - 360 : lon2 < -180 ? lon2 + 360 : lon2;
+ return L.latLng([lat2 * radInv, lon2]);
+ }
+});
+
+return L.GeometryUtil;
+
+}));
diff --git a/node_modules/leaflet-draw/docs/examples-0.7.x/libs/leaflet.snap.js b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/leaflet.snap.js
new file mode 100644
index 00000000..2b7f7965
--- /dev/null
+++ b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/leaflet.snap.js
@@ -0,0 +1,360 @@
+(function () {
+
+L.Handler.MarkerSnap = L.Handler.extend({
+ options: {
+ snapDistance: 15, // in pixels
+ snapVertices: true
+ },
+
+ initialize: function (map, marker, options) {
+ L.Handler.prototype.initialize.call(this, map);
+ this._markers = [];
+ this._guides = [];
+
+ if (arguments.length == 2) {
+ if (!(marker instanceof L.Class)) {
+ options = marker;
+ marker = null;
+ }
+ }
+
+ L.Util.setOptions(this, options || {});
+
+ if (marker) {
+ // new markers should be draggable !
+ if (!marker.dragging) marker.dragging = new L.Handler.MarkerDrag(marker);
+ marker.dragging.enable();
+ this.watchMarker(marker);
+ }
+
+ // Convert snap distance in pixels into buffer in degres, for searching around mouse
+ // It changes at each zoom change.
+ function computeBuffer() {
+ this._buffer = map.layerPointToLatLng(new L.Point(0,0)).lat -
+ map.layerPointToLatLng(new L.Point(this.options.snapDistance, 0)).lat;
+ }
+ map.on('zoomend', computeBuffer, this);
+ map.whenReady(computeBuffer, this);
+ computeBuffer.call(this);
+ },
+
+ enable: function () {
+ this.disable();
+ for (var i=0; i) */
+.sp-replacer {
+ margin:0;
+ overflow:hidden;
+ cursor:pointer;
+ padding: 4px;
+ display:inline-block;
+ *zoom: 1;
+ *display: inline;
+ border: solid 1px #91765d;
+ background: #eee;
+ color: #333;
+ vertical-align: middle;
+}
+.sp-replacer:hover, .sp-replacer.sp-active {
+ border-color: #F0C49B;
+ color: #111;
+}
+.sp-replacer.sp-disabled {
+ cursor:default;
+ border-color: silver;
+ color: silver;
+}
+.sp-dd {
+ padding: 2px 0;
+ height: 16px;
+ line-height: 16px;
+ float:left;
+ font-size:10px;
+}
+.sp-preview
+{
+ position:relative;
+ width:25px;
+ height: 20px;
+ border: solid 1px #222;
+ margin-right: 5px;
+ float:left;
+ z-index: 0;
+}
+
+.sp-palette
+{
+ *width: 220px;
+ max-width: 220px;
+}
+.sp-palette .sp-thumb-el
+{
+ width:16px;
+ height: 16px;
+ margin:2px 1px;
+ border: solid 1px #d0d0d0;
+}
+
+.sp-container
+{
+ padding-bottom:0;
+}
+
+
+/* Buttons: http://hellohappy.org/css3-buttons/ */
+.sp-container button {
+ background-color: #eeeeee;
+ background-image: -webkit-linear-gradient(top, #eeeeee, #cccccc);
+ background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);
+ background-image: -ms-linear-gradient(top, #eeeeee, #cccccc);
+ background-image: -o-linear-gradient(top, #eeeeee, #cccccc);
+ background-image: linear-gradient(to bottom, #eeeeee, #cccccc);
+ border: 1px solid #ccc;
+ border-bottom: 1px solid #bbb;
+ border-radius: 3px;
+ color: #333;
+ font-size: 14px;
+ line-height: 1;
+ padding: 5px 4px;
+ text-align: center;
+ text-shadow: 0 1px 0 #eee;
+ vertical-align: middle;
+}
+.sp-container button:hover {
+ background-color: #dddddd;
+ background-image: -webkit-linear-gradient(top, #dddddd, #bbbbbb);
+ background-image: -moz-linear-gradient(top, #dddddd, #bbbbbb);
+ background-image: -ms-linear-gradient(top, #dddddd, #bbbbbb);
+ background-image: -o-linear-gradient(top, #dddddd, #bbbbbb);
+ background-image: linear-gradient(to bottom, #dddddd, #bbbbbb);
+ border: 1px solid #bbb;
+ border-bottom: 1px solid #999;
+ cursor: pointer;
+ text-shadow: 0 1px 0 #ddd;
+}
+.sp-container button:active {
+ border: 1px solid #aaa;
+ border-bottom: 1px solid #888;
+ -webkit-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
+ -moz-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
+ -ms-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
+ -o-box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
+ box-shadow: inset 0 0 5px 2px #aaaaaa, 0 1px 0 0 #eeeeee;
+}
+.sp-cancel
+{
+ font-size: 11px;
+ color: #d93f3f !important;
+ margin:0;
+ padding:2px;
+ margin-right: 5px;
+ vertical-align: middle;
+ text-decoration:none;
+
+}
+.sp-cancel:hover
+{
+ color: #d93f3f !important;
+ text-decoration: underline;
+}
+
+
+.sp-palette span:hover, .sp-palette span.sp-thumb-active
+{
+ border-color: #000;
+}
+
+.sp-preview, .sp-alpha, .sp-thumb-el
+{
+ position:relative;
+ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAIAAADZF8uwAAAAGUlEQVQYV2M4gwH+YwCGIasIUwhT25BVBADtzYNYrHvv4gAAAABJRU5ErkJggg==);
+}
+.sp-preview-inner, .sp-alpha-inner, .sp-thumb-inner
+{
+ display:block;
+ position:absolute;
+ top:0;left:0;bottom:0;right:0;
+}
+
+.sp-palette .sp-thumb-inner
+{
+ background-position: 50% 50%;
+ background-repeat: no-repeat;
+}
+
+.sp-palette .sp-thumb-light.sp-thumb-active .sp-thumb-inner
+{
+ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAIVJREFUeNpiYBhsgJFMffxAXABlN5JruT4Q3wfi/0DsT64h8UD8HmpIPCWG/KemIfOJCUB+Aoacx6EGBZyHBqI+WsDCwuQ9mhxeg2A210Ntfo8klk9sOMijaURm7yc1UP2RNCMbKE9ODK1HM6iegYLkfx8pligC9lCD7KmRof0ZhjQACDAAceovrtpVBRkAAAAASUVORK5CYII=);
+}
+
+.sp-palette .sp-thumb-dark.sp-thumb-active .sp-thumb-inner
+{
+ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAYAAABWzo5XAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAadEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjEwMPRyoQAAAMdJREFUOE+tkgsNwzAMRMugEAahEAahEAZhEAqlEAZhEAohEAYh81X2dIm8fKpEspLGvudPOsUYpxE2BIJCroJmEW9qJ+MKaBFhEMNabSy9oIcIPwrB+afvAUFoK4H0tMaQ3XtlrggDhOVVMuT4E5MMG0FBbCEYzjYT7OxLEvIHQLY2zWwQ3D+9luyOQTfKDiFD3iUIfPk8VqrKjgAiSfGFPecrg6HN6m/iBcwiDAo7WiBeawa+Kwh7tZoSCGLMqwlSAzVDhoK+6vH4G0P5wdkAAAAASUVORK5CYII=);
+}
+
+.sp-clear-display {
+ background-repeat:no-repeat;
+ background-position: center;
+ background-image: url(data:image/gif;base64,R0lGODlhFAAUAPcAAAAAAJmZmZ2dnZ6enqKioqOjo6SkpKWlpaampqenp6ioqKmpqaqqqqurq/Hx8fLy8vT09PX19ff39/j4+Pn5+fr6+vv7+wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAEAAP8ALAAAAAAUABQAAAihAP9FoPCvoMGDBy08+EdhQAIJCCMybCDAAYUEARBAlFiQQoMABQhKUJBxY0SPICEYHBnggEmDKAuoPMjS5cGYMxHW3IiT478JJA8M/CjTZ0GgLRekNGpwAsYABHIypcAgQMsITDtWJYBR6NSqMico9cqR6tKfY7GeBCuVwlipDNmefAtTrkSzB1RaIAoXodsABiZAEFB06gIBWC1mLVgBa0AAOw==);
+}
diff --git a/node_modules/leaflet-draw/docs/examples-0.7.x/libs/spectrum.js b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/spectrum.js
new file mode 100755
index 00000000..8ced40ae
--- /dev/null
+++ b/node_modules/leaflet-draw/docs/examples-0.7.x/libs/spectrum.js
@@ -0,0 +1,2080 @@
+// Spectrum Colorpicker v1.3.4
+// https://github.com/bgrins/spectrum
+// Author: Brian Grinstead
+// License: MIT
+
+(function (window, $, undefined) {
+ var defaultOpts = {
+
+ // Callbacks
+ beforeShow: noop,
+ move: noop,
+ change: noop,
+ show: noop,
+ hide: noop,
+
+ // Options
+ color: false,
+ flat: false,
+ showInput: false,
+ allowEmpty: false,
+ showButtons: true,
+ clickoutFiresChange: false,
+ showInitial: false,
+ showPalette: false,
+ showPaletteOnly: false,
+ showSelectionPalette: true,
+ localStorageKey: false,
+ appendTo: "body",
+ maxSelectionSize: 7,
+ cancelText: "cancel",
+ chooseText: "choose",
+ clearText: "Clear Color Selection",
+ preferredFormat: false,
+ className: "", // Deprecated - use containerClassName and replacerClassName instead.
+ containerClassName: "",
+ replacerClassName: "",
+ showAlpha: false,
+ theme: "sp-light",
+ palette: [["#ffffff", "#000000", "#ff0000", "#ff8000", "#ffff00", "#008000", "#0000ff", "#4b0082", "#9400d3"]],
+ selectionPalette: [],
+ disabled: false
+ },
+ spectrums = [],
+ IE = !!/msie/i.exec( window.navigator.userAgent ),
+ rgbaSupport = (function() {
+ function contains( str, substr ) {
+ return !!~('' + str).indexOf(substr);
+ }
+
+ var elem = document.createElement('div');
+ var style = elem.style;
+ style.cssText = 'background-color:rgba(0,0,0,.5)';
+ return contains(style.backgroundColor, 'rgba') || contains(style.backgroundColor, 'hsla');
+ })(),
+ inputTypeColorSupport = (function() {
+ var colorInput = $(" ")[0];
+ return colorInput.type === "color" && colorInput.value !== "!";
+ })(),
+ replaceInput = [
+ ""
+ ].join(''),
+ markup = (function () {
+
+ // IE does not support gradients with multiple stops, so we need to simulate
+ // that for the rainbow slider with 8 divs that each have a single gradient
+ var gradientFix = "";
+ if (IE) {
+ for (var i = 1; i <= 6; i++) {
+ gradientFix += "
";
+ }
+ }
+
+ return [
+ "",
+ "
",
+ "
",
+ "
",
+ "
",
+ "
",
+ "
",
+ "
",
+ "
",
+ "
",
+ "
",
+ gradientFix,
+ "
",
+ "
",
+ "
",
+ "
",
+ "
",
+ " ",
+ "
",
+ "
",
+ "
",
+ "
",
+ "
"
+ ].join("");
+ })();
+
+ function paletteTemplate (p, color, className, tooltipFormat) {
+ var html = [];
+ for (var i = 0; i < p.length; i++) {
+ var current = p[i];
+ if(current) {
+ var tiny = tinycolor(current);
+ var c = tiny.toHsl().l < 0.5 ? "sp-thumb-el sp-thumb-dark" : "sp-thumb-el sp-thumb-light";
+ c += (tinycolor.equals(color, current)) ? " sp-thumb-active" : "";
+
+ var formattedString = tiny.toString(tooltipFormat || "rgb");
+ var swatchStyle = rgbaSupport ? ("background-color:" + tiny.toRgbString()) : "filter:" + tiny.toFilter();
+ html.push(' ');
+ } else {
+ var cls = 'sp-clear-display';
+ html.push(' ');
+ }
+ }
+ return "" + html.join('') + "
";
+ }
+
+ function hideAll() {
+ for (var i = 0; i < spectrums.length; i++) {
+ if (spectrums[i]) {
+ spectrums[i].hide();
+ }
+ }
+ }
+
+ function instanceOptions(o, callbackContext) {
+ var opts = $.extend({}, defaultOpts, o);
+ opts.callbacks = {
+ 'move': bind(opts.move, callbackContext),
+ 'change': bind(opts.change, callbackContext),
+ 'show': bind(opts.show, callbackContext),
+ 'hide': bind(opts.hide, callbackContext),
+ 'beforeShow': bind(opts.beforeShow, callbackContext)
+ };
+
+ return opts;
+ }
+
+ function spectrum(element, o) {
+
+ var opts = instanceOptions(o, element),
+ flat = opts.flat,
+ showSelectionPalette = opts.showSelectionPalette,
+ localStorageKey = opts.localStorageKey,
+ theme = opts.theme,
+ callbacks = opts.callbacks,
+ resize = throttle(reflow, 10),
+ visible = false,
+ dragWidth = 0,
+ dragHeight = 0,
+ dragHelperHeight = 0,
+ slideHeight = 0,
+ slideWidth = 0,
+ alphaWidth = 0,
+ alphaSlideHelperWidth = 0,
+ slideHelperHeight = 0,
+ currentHue = 0,
+ currentSaturation = 0,
+ currentValue = 0,
+ currentAlpha = 1,
+ palette = [],
+ paletteArray = [],
+ paletteLookup = {},
+ selectionPalette = opts.selectionPalette.slice(0),
+ maxSelectionSize = opts.maxSelectionSize,
+ draggingClass = "sp-dragging",
+ shiftMovementDirection = null;
+
+ var doc = element.ownerDocument,
+ body = doc.body,
+ boundElement = $(element),
+ disabled = false,
+ container = $(markup, doc).addClass(theme),
+ dragger = container.find(".sp-color"),
+ dragHelper = container.find(".sp-dragger"),
+ slider = container.find(".sp-hue"),
+ slideHelper = container.find(".sp-slider"),
+ alphaSliderInner = container.find(".sp-alpha-inner"),
+ alphaSlider = container.find(".sp-alpha"),
+ alphaSlideHelper = container.find(".sp-alpha-handle"),
+ textInput = container.find(".sp-input"),
+ paletteContainer = container.find(".sp-palette"),
+ initialColorContainer = container.find(".sp-initial"),
+ cancelButton = container.find(".sp-cancel"),
+ clearButton = container.find(".sp-clear"),
+ chooseButton = container.find(".sp-choose"),
+ isInput = boundElement.is("input"),
+ isInputTypeColor = isInput && inputTypeColorSupport && boundElement.attr("type") === "color",
+ shouldReplace = isInput && !flat,
+ replacer = (shouldReplace) ? $(replaceInput).addClass(theme).addClass(opts.className).addClass(opts.replacerClassName) : $([]),
+ offsetElement = (shouldReplace) ? replacer : boundElement,
+ previewElement = replacer.find(".sp-preview-inner"),
+ initialColor = opts.color || (isInput && boundElement.val()),
+ colorOnShow = false,
+ preferredFormat = opts.preferredFormat,
+ currentPreferredFormat = preferredFormat,
+ clickoutFiresChange = !opts.showButtons || opts.clickoutFiresChange,
+ isEmpty = !initialColor,
+ allowEmpty = opts.allowEmpty && !isInputTypeColor;
+
+ function applyOptions() {
+
+ if (opts.showPaletteOnly) {
+ opts.showPalette = true;
+ }
+
+ if (opts.palette) {
+ palette = opts.palette.slice(0);
+ paletteArray = $.isArray(palette[0]) ? palette : [palette];
+ paletteLookup = {};
+ for (var i = 0; i < paletteArray.length; i++) {
+ for (var j = 0; j < paletteArray[i].length; j++) {
+ var rgb = tinycolor(paletteArray[i][j]).toRgbString();
+ paletteLookup[rgb] = true;
+ }
+ }
+ }
+
+ container.toggleClass("sp-flat", flat);
+ container.toggleClass("sp-input-disabled", !opts.showInput);
+ container.toggleClass("sp-alpha-enabled", opts.showAlpha);
+ container.toggleClass("sp-clear-enabled", allowEmpty);
+ container.toggleClass("sp-buttons-disabled", !opts.showButtons);
+ container.toggleClass("sp-palette-disabled", !opts.showPalette);
+ container.toggleClass("sp-palette-only", opts.showPaletteOnly);
+ container.toggleClass("sp-initial-disabled", !opts.showInitial);
+ container.addClass(opts.className).addClass(opts.containerClassName);
+
+ reflow();
+ }
+
+ function initialize() {
+
+ if (IE) {
+ container.find("*:not(input)").attr("unselectable", "on");
+ }
+
+ applyOptions();
+
+ if (shouldReplace) {
+ boundElement.after(replacer).hide();
+ }
+
+ if (!allowEmpty) {
+ clearButton.hide();
+ }
+
+ if (flat) {
+ boundElement.after(container).hide();
+ }
+ else {
+
+ var appendTo = opts.appendTo === "parent" ? boundElement.parent() : $(opts.appendTo);
+ if (appendTo.length !== 1) {
+ appendTo = $("body");
+ }
+
+ appendTo.append(container);
+ }
+
+ updateSelectionPaletteFromStorage();
+
+ offsetElement.bind("click.spectrum touchstart.spectrum", function (e) {
+ if (!disabled) {
+ toggle();
+ }
+
+ e.stopPropagation();
+
+ if (!$(e.target).is("input")) {
+ e.preventDefault();
+ }
+ });
+
+ if(boundElement.is(":disabled") || (opts.disabled === true)) {
+ disable();
+ }
+
+ // Prevent clicks from bubbling up to document. This would cause it to be hidden.
+ container.click(stopPropagation);
+
+ // Handle user typed input
+ textInput.change(setFromTextInput);
+ textInput.bind("paste", function () {
+ setTimeout(setFromTextInput, 1);
+ });
+ textInput.keydown(function (e) { if (e.keyCode == 13) { setFromTextInput(); } });
+
+ cancelButton.text(opts.cancelText);
+ cancelButton.bind("click.spectrum", function (e) {
+ e.stopPropagation();
+ e.preventDefault();
+ hide("cancel");
+ });
+
+ clearButton.attr("title", opts.clearText);
+ clearButton.bind("click.spectrum", function (e) {
+ e.stopPropagation();
+ e.preventDefault();
+ isEmpty = true;
+ move();
+
+ if(flat) {
+ //for the flat style, this is a change event
+ updateOriginalInput(true);
+ }
+ });
+
+ chooseButton.text(opts.chooseText);
+ chooseButton.bind("click.spectrum", function (e) {
+ e.stopPropagation();
+ e.preventDefault();
+
+ if (isValid()) {
+ updateOriginalInput(true);
+ hide();
+ }
+ });
+
+ draggable(alphaSlider, function (dragX, dragY, e) {
+ currentAlpha = (dragX / alphaWidth);
+ isEmpty = false;
+ if (e.shiftKey) {
+ currentAlpha = Math.round(currentAlpha * 10) / 10;
+ }
+
+ move();
+ }, dragStart, dragStop);
+
+ draggable(slider, function (dragX, dragY) {
+ currentHue = parseFloat(dragY / slideHeight);
+ isEmpty = false;
+ if (!opts.showAlpha) {
+ currentAlpha = 1;
+ }
+ move();
+ }, dragStart, dragStop);
+
+ draggable(dragger, function (dragX, dragY, e) {
+
+ // shift+drag should snap the movement to either the x or y axis.
+ if (!e.shiftKey) {
+ shiftMovementDirection = null;
+ }
+ else if (!shiftMovementDirection) {
+ var oldDragX = currentSaturation * dragWidth;
+ var oldDragY = dragHeight - (currentValue * dragHeight);
+ var furtherFromX = Math.abs(dragX - oldDragX) > Math.abs(dragY - oldDragY);
+
+ shiftMovementDirection = furtherFromX ? "x" : "y";
+ }
+
+ var setSaturation = !shiftMovementDirection || shiftMovementDirection === "x";
+ var setValue = !shiftMovementDirection || shiftMovementDirection === "y";
+
+ if (setSaturation) {
+ currentSaturation = parseFloat(dragX / dragWidth);
+ }
+ if (setValue) {
+ currentValue = parseFloat((dragHeight - dragY) / dragHeight);
+ }
+
+ isEmpty = false;
+ if (!opts.showAlpha) {
+ currentAlpha = 1;
+ }
+
+ move();
+
+ }, dragStart, dragStop);
+
+ if (!!initialColor) {
+ set(initialColor);
+
+ // In case color was black - update the preview UI and set the format
+ // since the set function will not run (default color is black).
+ updateUI();
+ currentPreferredFormat = preferredFormat || tinycolor(initialColor).format;
+
+ addColorToSelectionPalette(initialColor);
+ }
+ else {
+ updateUI();
+ }
+
+ if (flat) {
+ show();
+ }
+
+ function palletElementClick(e) {
+ if (e.data && e.data.ignore) {
+ set($(this).data("color"));
+ move();
+ }
+ else {
+ set($(this).data("color"));
+ move();
+ updateOriginalInput(true);
+ hide();
+ }
+
+ return false;
+ }
+
+ var paletteEvent = IE ? "mousedown.spectrum" : "click.spectrum touchstart.spectrum";
+ paletteContainer.delegate(".sp-thumb-el", paletteEvent, palletElementClick);
+ initialColorContainer.delegate(".sp-thumb-el:nth-child(1)", paletteEvent, { ignore: true }, palletElementClick);
+ }
+
+ function updateSelectionPaletteFromStorage() {
+
+ if (localStorageKey && window.localStorage) {
+
+ // Migrate old palettes over to new format. May want to remove this eventually.
+ try {
+ var oldPalette = window.localStorage[localStorageKey].split(",#");
+ if (oldPalette.length > 1) {
+ delete window.localStorage[localStorageKey];
+ $.each(oldPalette, function(i, c) {
+ addColorToSelectionPalette(c);
+ });
+ }
+ }
+ catch(e) { }
+
+ try {
+ selectionPalette = window.localStorage[localStorageKey].split(";");
+ }
+ catch (e) { }
+ }
+ }
+
+ function addColorToSelectionPalette(color) {
+ if (showSelectionPalette) {
+ var rgb = tinycolor(color).toRgbString();
+ if (!paletteLookup[rgb] && $.inArray(rgb, selectionPalette) === -1) {
+ selectionPalette.push(rgb);
+ while(selectionPalette.length > maxSelectionSize) {
+ selectionPalette.shift();
+ }
+ }
+
+ if (localStorageKey && window.localStorage) {
+ try {
+ window.localStorage[localStorageKey] = selectionPalette.join(";");
+ }
+ catch(e) { }
+ }
+ }
+ }
+
+ function getUniqueSelectionPalette() {
+ var unique = [];
+ if (opts.showPalette) {
+ for (i = 0; i < selectionPalette.length; i++) {
+ var rgb = tinycolor(selectionPalette[i]).toRgbString();
+
+ if (!paletteLookup[rgb]) {
+ unique.push(selectionPalette[i]);
+ }
+ }
+ }
+
+ return unique.reverse().slice(0, opts.maxSelectionSize);
+ }
+
+ function drawPalette() {
+
+ var currentColor = get();
+
+ var html = $.map(paletteArray, function (palette, i) {
+ return paletteTemplate(palette, currentColor, "sp-palette-row sp-palette-row-" + i, opts.preferredFormat);
+ });
+
+ updateSelectionPaletteFromStorage();
+
+ if (selectionPalette) {
+ html.push(paletteTemplate(getUniqueSelectionPalette(), currentColor, "sp-palette-row sp-palette-row-selection", opts.preferredFormat));
+ }
+
+ paletteContainer.html(html.join(""));
+ }
+
+ function drawInitial() {
+ if (opts.showInitial) {
+ var initial = colorOnShow;
+ var current = get();
+ initialColorContainer.html(paletteTemplate([initial, current], current, "sp-palette-row-initial", opts.preferredFormat));
+ }
+ }
+
+ function dragStart() {
+ if (dragHeight <= 0 || dragWidth <= 0 || slideHeight <= 0) {
+ reflow();
+ }
+ container.addClass(draggingClass);
+ shiftMovementDirection = null;
+ boundElement.trigger('dragstart.spectrum', [ get() ]);
+ }
+
+ function dragStop() {
+ container.removeClass(draggingClass);
+ boundElement.trigger('dragstop.spectrum', [ get() ]);
+ }
+
+ function setFromTextInput() {
+
+ var value = textInput.val();
+
+ if ((value === null || value === "") && allowEmpty) {
+ set(null);
+ updateOriginalInput(true);
+ }
+ else {
+ var tiny = tinycolor(value);
+ if (tiny.ok) {
+ set(tiny);
+ updateOriginalInput(true);
+ }
+ else {
+ textInput.addClass("sp-validation-error");
+ }
+ }
+ }
+
+ function toggle() {
+ if (visible) {
+ hide();
+ }
+ else {
+ show();
+ }
+ }
+
+ function show() {
+ var event = $.Event('beforeShow.spectrum');
+
+ if (visible) {
+ reflow();
+ return;
+ }
+
+ boundElement.trigger(event, [ get() ]);
+
+ if (callbacks.beforeShow(get()) === false || event.isDefaultPrevented()) {
+ return;
+ }
+
+ hideAll();
+ visible = true;
+
+ $(doc).bind("click.spectrum", hide);
+ $(window).bind("resize.spectrum", resize);
+ replacer.addClass("sp-active");
+ container.removeClass("sp-hidden");
+
+ reflow();
+ updateUI();
+
+ colorOnShow = get();
+
+ drawInitial();
+ callbacks.show(colorOnShow);
+ boundElement.trigger('show.spectrum', [ colorOnShow ]);
+ }
+
+ function hide(e) {
+
+ // Return on right click
+ if (e && e.type == "click" && e.button == 2) { return; }
+
+ // Return if hiding is unnecessary
+ if (!visible || flat) { return; }
+ visible = false;
+
+ $(doc).unbind("click.spectrum", hide);
+ $(window).unbind("resize.spectrum", resize);
+
+ replacer.removeClass("sp-active");
+ container.addClass("sp-hidden");
+
+ var colorHasChanged = !tinycolor.equals(get(), colorOnShow);
+
+ if (colorHasChanged) {
+ if (clickoutFiresChange && e !== "cancel") {
+ updateOriginalInput(true);
+ }
+ else {
+ revert();
+ }
+ }
+
+ callbacks.hide(get());
+ boundElement.trigger('hide.spectrum', [ get() ]);
+ }
+
+ function revert() {
+ set(colorOnShow, true);
+ }
+
+ function set(color, ignoreFormatChange) {
+ if (tinycolor.equals(color, get())) {
+ // Update UI just in case a validation error needs
+ // to be cleared.
+ updateUI();
+ return;
+ }
+
+ var newColor, newHsv;
+ if (!color && allowEmpty) {
+ isEmpty = true;
+ } else {
+ isEmpty = false;
+ newColor = tinycolor(color);
+ newHsv = newColor.toHsv();
+
+ currentHue = (newHsv.h % 360) / 360;
+ currentSaturation = newHsv.s;
+ currentValue = newHsv.v;
+ currentAlpha = newHsv.a;
+ }
+ updateUI();
+
+ if (newColor && newColor.ok && !ignoreFormatChange) {
+ currentPreferredFormat = preferredFormat || newColor.format;
+ }
+ }
+
+ function get(opts) {
+ opts = opts || { };
+
+ if (allowEmpty && isEmpty) {
+ return null;
+ }
+
+ return tinycolor.fromRatio({
+ h: currentHue,
+ s: currentSaturation,
+ v: currentValue,
+ a: Math.round(currentAlpha * 100) / 100
+ }, { format: opts.format || currentPreferredFormat });
+ }
+
+ function isValid() {
+ return !textInput.hasClass("sp-validation-error");
+ }
+
+ function move() {
+ updateUI();
+
+ callbacks.move(get());
+ boundElement.trigger('move.spectrum', [ get() ]);
+ }
+
+ function updateUI() {
+
+ textInput.removeClass("sp-validation-error");
+
+ updateHelperLocations();
+
+ // Update dragger background color (gradients take care of saturation and value).
+ var flatColor = tinycolor.fromRatio({ h: currentHue, s: 1, v: 1 });
+ dragger.css("background-color", flatColor.toHexString());
+
+ // Get a format that alpha will be included in (hex and names ignore alpha)
+ var format = currentPreferredFormat;
+ if (currentAlpha < 1 && !(currentAlpha === 0 && format === "name")) {
+ if (format === "hex" || format === "hex3" || format === "hex6" || format === "name") {
+ format = "rgb";
+ }
+ }
+
+ var realColor = get({ format: format }),
+ displayColor = '';
+
+ //reset background info for preview element
+ previewElement.removeClass("sp-clear-display");
+ previewElement.css('background-color', 'transparent');
+
+ if (!realColor && allowEmpty) {
+ // Update the replaced elements background with icon indicating no color selection
+ previewElement.addClass("sp-clear-display");
+ }
+ else {
+ var realHex = realColor.toHexString(),
+ realRgb = realColor.toRgbString();
+
+ // Update the replaced elements background color (with actual selected color)
+ if (rgbaSupport || realColor.alpha === 1) {
+ previewElement.css("background-color", realRgb);
+ }
+ else {
+ previewElement.css("background-color", "transparent");
+ previewElement.css("filter", realColor.toFilter());
+ }
+
+ if (opts.showAlpha) {
+ var rgb = realColor.toRgb();
+ rgb.a = 0;
+ var realAlpha = tinycolor(rgb).toRgbString();
+ var gradient = "linear-gradient(left, " + realAlpha + ", " + realHex + ")";
+
+ if (IE) {
+ alphaSliderInner.css("filter", tinycolor(realAlpha).toFilter({ gradientType: 1 }, realHex));
+ }
+ else {
+ alphaSliderInner.css("background", "-webkit-" + gradient);
+ alphaSliderInner.css("background", "-moz-" + gradient);
+ alphaSliderInner.css("background", "-ms-" + gradient);
+ // Use current syntax gradient on unprefixed property.
+ alphaSliderInner.css("background",
+ "linear-gradient(to right, " + realAlpha + ", " + realHex + ")");
+ }
+ }
+
+ displayColor = realColor.toString(format);
+ }
+
+ // Update the text entry input as it changes happen
+ if (opts.showInput) {
+ textInput.val(displayColor);
+ }
+
+ if (opts.showPalette) {
+ drawPalette();
+ }
+
+ drawInitial();
+ }
+
+ function updateHelperLocations() {
+ var s = currentSaturation;
+ var v = currentValue;
+
+ if(allowEmpty && isEmpty) {
+ //if selected color is empty, hide the helpers
+ alphaSlideHelper.hide();
+ slideHelper.hide();
+ dragHelper.hide();
+ }
+ else {
+ //make sure helpers are visible
+ alphaSlideHelper.show();
+ slideHelper.show();
+ dragHelper.show();
+
+ // Where to show the little circle in that displays your current selected color
+ var dragX = s * dragWidth;
+ var dragY = dragHeight - (v * dragHeight);
+ dragX = Math.max(
+ -dragHelperHeight,
+ Math.min(dragWidth - dragHelperHeight, dragX - dragHelperHeight)
+ );
+ dragY = Math.max(
+ -dragHelperHeight,
+ Math.min(dragHeight - dragHelperHeight, dragY - dragHelperHeight)
+ );
+ dragHelper.css({
+ "top": dragY + "px",
+ "left": dragX + "px"
+ });
+
+ var alphaX = currentAlpha * alphaWidth;
+ alphaSlideHelper.css({
+ "left": (alphaX - (alphaSlideHelperWidth / 2)) + "px"
+ });
+
+ // Where to show the bar that displays your current selected hue
+ var slideY = (currentHue) * slideHeight;
+ slideHelper.css({
+ "top": (slideY - slideHelperHeight) + "px"
+ });
+ }
+ }
+
+ function updateOriginalInput(fireCallback) {
+ var color = get(),
+ displayColor = '',
+ hasChanged = !tinycolor.equals(color, colorOnShow);
+
+ if (color) {
+ displayColor = color.toString(currentPreferredFormat);
+ // Update the selection palette with the current color
+ addColorToSelectionPalette(color);
+ }
+
+ if (isInput) {
+ boundElement.val(displayColor);
+ }
+
+ colorOnShow = color;
+
+ if (fireCallback && hasChanged) {
+ callbacks.change(color);
+ boundElement.trigger('change', [ color ]);
+ }
+ }
+
+ function reflow() {
+ dragWidth = dragger.width();
+ dragHeight = dragger.height();
+ dragHelperHeight = dragHelper.height();
+ slideWidth = slider.width();
+ slideHeight = slider.height();
+ slideHelperHeight = slideHelper.height();
+ alphaWidth = alphaSlider.width();
+ alphaSlideHelperWidth = alphaSlideHelper.width();
+
+ if (!flat) {
+ container.css("position", "absolute");
+ container.offset(getOffset(container, offsetElement));
+ }
+
+ updateHelperLocations();
+
+ if (opts.showPalette) {
+ drawPalette();
+ }
+
+ boundElement.trigger('reflow.spectrum');
+ }
+
+ function destroy() {
+ boundElement.show();
+ offsetElement.unbind("click.spectrum touchstart.spectrum");
+ container.remove();
+ replacer.remove();
+ spectrums[spect.id] = null;
+ }
+
+ function option(optionName, optionValue) {
+ if (optionName === undefined) {
+ return $.extend({}, opts);
+ }
+ if (optionValue === undefined) {
+ return opts[optionName];
+ }
+
+ opts[optionName] = optionValue;
+ applyOptions();
+ }
+
+ function enable() {
+ disabled = false;
+ boundElement.attr("disabled", false);
+ offsetElement.removeClass("sp-disabled");
+ }
+
+ function disable() {
+ hide();
+ disabled = true;
+ boundElement.attr("disabled", true);
+ offsetElement.addClass("sp-disabled");
+ }
+
+ initialize();
+
+ var spect = {
+ show: show,
+ hide: hide,
+ toggle: toggle,
+ reflow: reflow,
+ option: option,
+ enable: enable,
+ disable: disable,
+ set: function (c) {
+ set(c);
+ updateOriginalInput();
+ },
+ get: get,
+ destroy: destroy,
+ container: container
+ };
+
+ spect.id = spectrums.push(spect) - 1;
+
+ return spect;
+ }
+
+ /**
+ * checkOffset - get the offset below/above and left/right element depending on screen position
+ * Thanks https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.datepicker.js
+ */
+ function getOffset(picker, input) {
+ var extraY = 0;
+ var dpWidth = picker.outerWidth();
+ var dpHeight = picker.outerHeight();
+ var inputHeight = input.outerHeight();
+ var doc = picker[0].ownerDocument;
+ var docElem = doc.documentElement;
+ var viewWidth = docElem.clientWidth + $(doc).scrollLeft();
+ var viewHeight = docElem.clientHeight + $(doc).scrollTop();
+ var offset = input.offset();
+ offset.top += inputHeight;
+
+ offset.left -=
+ Math.min(offset.left, (offset.left + dpWidth > viewWidth && viewWidth > dpWidth) ?
+ Math.abs(offset.left + dpWidth - viewWidth) : 0);
+
+ offset.top -=
+ Math.min(offset.top, ((offset.top + dpHeight > viewHeight && viewHeight > dpHeight) ?
+ Math.abs(dpHeight + inputHeight - extraY) : extraY));
+
+ return offset;
+ }
+
+ /**
+ * noop - do nothing
+ */
+ function noop() {
+
+ }
+
+ /**
+ * stopPropagation - makes the code only doing this a little easier to read in line
+ */
+ function stopPropagation(e) {
+ e.stopPropagation();
+ }
+
+ /**
+ * Create a function bound to a given object
+ * Thanks to underscore.js
+ */
+ function bind(func, obj) {
+ var slice = Array.prototype.slice;
+ var args = slice.call(arguments, 2);
+ return function () {
+ return func.apply(obj, args.concat(slice.call(arguments)));
+ };
+ }
+
+ /**
+ * Lightweight drag helper. Handles containment within the element, so that
+ * when dragging, the x is within [0,element.width] and y is within [0,element.height]
+ */
+ function draggable(element, onmove, onstart, onstop) {
+ onmove = onmove || function () { };
+ onstart = onstart || function () { };
+ onstop = onstop || function () { };
+ var doc = element.ownerDocument || document;
+ var dragging = false;
+ var offset = {};
+ var maxHeight = 0;
+ var maxWidth = 0;
+ var hasTouch = ('ontouchstart' in window);
+
+ var duringDragEvents = {};
+ duringDragEvents["selectstart"] = prevent;
+ duringDragEvents["dragstart"] = prevent;
+ duringDragEvents["touchmove mousemove"] = move;
+ duringDragEvents["touchend mouseup"] = stop;
+
+ function prevent(e) {
+ if (e.stopPropagation) {
+ e.stopPropagation();
+ }
+ if (e.preventDefault) {
+ e.preventDefault();
+ }
+ e.returnValue = false;
+ }
+
+ function move(e) {
+ if (dragging) {
+ // Mouseup happened outside of window
+ if (IE && document.documentMode < 9 && !e.button) {
+ return stop();
+ }
+
+ var touches = e.originalEvent.touches;
+ var pageX = touches ? touches[0].pageX : e.pageX;
+ var pageY = touches ? touches[0].pageY : e.pageY;
+
+ var dragX = Math.max(0, Math.min(pageX - offset.left, maxWidth));
+ var dragY = Math.max(0, Math.min(pageY - offset.top, maxHeight));
+
+ if (hasTouch) {
+ // Stop scrolling in iOS
+ prevent(e);
+ }
+
+ onmove.apply(element, [dragX, dragY, e]);
+ }
+ }
+
+ function start(e) {
+ var rightclick = (e.which) ? (e.which == 3) : (e.button == 2);
+ var touches = e.originalEvent.touches;
+
+ if (!rightclick && !dragging) {
+ if (onstart.apply(element, arguments) !== false) {
+ dragging = true;
+ maxHeight = $(element).height();
+ maxWidth = $(element).width();
+ offset = $(element).offset();
+
+ $(doc).bind(duringDragEvents);
+ $(doc.body).addClass("sp-dragging");
+
+ if (!hasTouch) {
+ move(e);
+ }
+
+ prevent(e);
+ }
+ }
+ }
+
+ function stop() {
+ if (dragging) {
+ $(doc).unbind(duringDragEvents);
+ $(doc.body).removeClass("sp-dragging");
+ onstop.apply(element, arguments);
+ }
+ dragging = false;
+ }
+
+ $(element).bind("touchstart mousedown", start);
+ }
+
+ function throttle(func, wait, debounce) {
+ var timeout;
+ return function () {
+ var context = this, args = arguments;
+ var throttler = function () {
+ timeout = null;
+ func.apply(context, args);
+ };
+ if (debounce) clearTimeout(timeout);
+ if (debounce || !timeout) timeout = setTimeout(throttler, wait);
+ };
+ }
+
+ function log(){/* jshint -W021 */if(window.console){if(Function.prototype.bind)log=Function.prototype.bind.call(console.log,console);else log=function(){Function.prototype.apply.call(console.log,console,arguments);};log.apply(this,arguments);}}
+
+ /**
+ * Define a jQuery plugin
+ */
+ var dataID = "spectrum.id";
+ $.fn.spectrum = function (opts, extra) {
+
+ if (typeof opts == "string") {
+
+ var returnValue = this;
+ var args = Array.prototype.slice.call( arguments, 1 );
+
+ this.each(function () {
+ var spect = spectrums[$(this).data(dataID)];
+ if (spect) {
+ var method = spect[opts];
+ if (!method) {
+ throw new Error( "Spectrum: no such method: '" + opts + "'" );
+ }
+
+ if (opts == "get") {
+ returnValue = spect.get();
+ }
+ else if (opts == "container") {
+ returnValue = spect.container;
+ }
+ else if (opts == "option") {
+ returnValue = spect.option.apply(spect, args);
+ }
+ else if (opts == "destroy") {
+ spect.destroy();
+ $(this).removeData(dataID);
+ }
+ else {
+ method.apply(spect, args);
+ }
+ }
+ });
+
+ return returnValue;
+ }
+
+ // Initializing a new instance of spectrum
+ return this.spectrum("destroy").each(function () {
+ var options = $.extend({}, opts, $(this).data());
+ var spect = spectrum(this, options);
+ $(this).data(dataID, spect.id);
+ });
+ };
+
+ $.fn.spectrum.load = true;
+ $.fn.spectrum.loadOpts = {};
+ $.fn.spectrum.draggable = draggable;
+ $.fn.spectrum.defaults = defaultOpts;
+
+ $.spectrum = { };
+ $.spectrum.localization = { };
+ $.spectrum.palettes = { };
+
+ $.fn.spectrum.processNativeColorInputs = function () {
+ if (!inputTypeColorSupport) {
+ $("input[type=color]").spectrum({
+ preferredFormat: "hex6"
+ });
+ }
+ };
+
+ // TinyColor v0.9.17
+ // https://github.com/bgrins/TinyColor
+ // 2013-08-10, Brian Grinstead, MIT License
+
+ (function() {
+
+ var trimLeft = /^[\s,#]+/,
+ trimRight = /\s+$/,
+ tinyCounter = 0,
+ math = Math,
+ mathRound = math.round,
+ mathMin = math.min,
+ mathMax = math.max,
+ mathRandom = math.random;
+
+ function tinycolor (color, opts) {
+
+ color = (color) ? color : '';
+ opts = opts || { };
+
+ // If input is already a tinycolor, return itself
+ if (typeof color == "object" && color.hasOwnProperty("_tc_id")) {
+ return color;
+ }
+
+ var rgb = inputToRGB(color);
+ var r = rgb.r,
+ g = rgb.g,
+ b = rgb.b,
+ a = rgb.a,
+ roundA = mathRound(100*a) / 100,
+ format = opts.format || rgb.format;
+
+ // Don't let the range of [0,255] come back in [0,1].
+ // Potentially lose a little bit of precision here, but will fix issues where
+ // .5 gets interpreted as half of the total, instead of half of 1
+ // If it was supposed to be 128, this was already taken care of by `inputToRgb`
+ if (r < 1) { r = mathRound(r); }
+ if (g < 1) { g = mathRound(g); }
+ if (b < 1) { b = mathRound(b); }
+
+ return {
+ ok: rgb.ok,
+ format: format,
+ _tc_id: tinyCounter++,
+ alpha: a,
+ getAlpha: function() {
+ return a;
+ },
+ setAlpha: function(value) {
+ a = boundAlpha(value);
+ roundA = mathRound(100*a) / 100;
+ },
+ toHsv: function() {
+ var hsv = rgbToHsv(r, g, b);
+ return { h: hsv.h * 360, s: hsv.s, v: hsv.v, a: a };
+ },
+ toHsvString: function() {
+ var hsv = rgbToHsv(r, g, b);
+ var h = mathRound(hsv.h * 360), s = mathRound(hsv.s * 100), v = mathRound(hsv.v * 100);
+ return (a == 1) ?
+ "hsv(" + h + ", " + s + "%, " + v + "%)" :
+ "hsva(" + h + ", " + s + "%, " + v + "%, "+ roundA + ")";
+ },
+ toHsl: function() {
+ var hsl = rgbToHsl(r, g, b);
+ return { h: hsl.h * 360, s: hsl.s, l: hsl.l, a: a };
+ },
+ toHslString: function() {
+ var hsl = rgbToHsl(r, g, b);
+ var h = mathRound(hsl.h * 360), s = mathRound(hsl.s * 100), l = mathRound(hsl.l * 100);
+ return (a == 1) ?
+ "hsl(" + h + ", " + s + "%, " + l + "%)" :
+ "hsla(" + h + ", " + s + "%, " + l + "%, "+ roundA + ")";
+ },
+ toHex: function(allow3Char) {
+ return rgbToHex(r, g, b, allow3Char);
+ },
+ toHexString: function(allow3Char) {
+ return '#' + this.toHex(allow3Char);
+ },
+ toHex8: function() {
+ return rgbaToHex(r, g, b, a);
+ },
+ toHex8String: function() {
+ return '#' + this.toHex8();
+ },
+ toRgb: function() {
+ return { r: mathRound(r), g: mathRound(g), b: mathRound(b), a: a };
+ },
+ toRgbString: function() {
+ return (a == 1) ?
+ "rgb(" + mathRound(r) + ", " + mathRound(g) + ", " + mathRound(b) + ")" :
+ "rgba(" + mathRound(r) + ", " + mathRound(g) + ", " + mathRound(b) + ", " + roundA + ")";
+ },
+ toPercentageRgb: function() {
+ return { r: mathRound(bound01(r, 255) * 100) + "%", g: mathRound(bound01(g, 255) * 100) + "%", b: mathRound(bound01(b, 255) * 100) + "%", a: a };
+ },
+ toPercentageRgbString: function() {
+ return (a == 1) ?
+ "rgb(" + mathRound(bound01(r, 255) * 100) + "%, " + mathRound(bound01(g, 255) * 100) + "%, " + mathRound(bound01(b, 255) * 100) + "%)" :
+ "rgba(" + mathRound(bound01(r, 255) * 100) + "%, " + mathRound(bound01(g, 255) * 100) + "%, " + mathRound(bound01(b, 255) * 100) + "%, " + roundA + ")";
+ },
+ toName: function() {
+ if (a === 0) {
+ return "transparent";
+ }
+
+ return hexNames[rgbToHex(r, g, b, true)] || false;
+ },
+ toFilter: function(secondColor) {
+ var hex8String = '#' + rgbaToHex(r, g, b, a);
+ var secondHex8String = hex8String;
+ var gradientType = opts && opts.gradientType ? "GradientType = 1, " : "";
+
+ if (secondColor) {
+ var s = tinycolor(secondColor);
+ secondHex8String = s.toHex8String();
+ }
+
+ return "progid:DXImageTransform.Microsoft.gradient("+gradientType+"startColorstr="+hex8String+",endColorstr="+secondHex8String+")";
+ },
+ toString: function(format) {
+ var formatSet = !!format;
+ format = format || this.format;
+
+ var formattedString = false;
+ var hasAlphaAndFormatNotSet = !formatSet && a < 1 && a > 0;
+ var formatWithAlpha = hasAlphaAndFormatNotSet && (format === "hex" || format === "hex6" || format === "hex3" || format === "name");
+
+ if (format === "rgb") {
+ formattedString = this.toRgbString();
+ }
+ if (format === "prgb") {
+ formattedString = this.toPercentageRgbString();
+ }
+ if (format === "hex" || format === "hex6") {
+ formattedString = this.toHexString();
+ }
+ if (format === "hex3") {
+ formattedString = this.toHexString(true);
+ }
+ if (format === "hex8") {
+ formattedString = this.toHex8String();
+ }
+ if (format === "name") {
+ formattedString = this.toName();
+ }
+ if (format === "hsl") {
+ formattedString = this.toHslString();
+ }
+ if (format === "hsv") {
+ formattedString = this.toHsvString();
+ }
+
+ if (formatWithAlpha) {
+ return this.toRgbString();
+ }
+
+ return formattedString || this.toHexString();
+ }
+ };
+ }
+
+ // If input is an object, force 1 into "1.0" to handle ratios properly
+ // String input requires "1.0" as input, so 1 will be treated as 1
+ tinycolor.fromRatio = function(color, opts) {
+ if (typeof color == "object") {
+ var newColor = {};
+ for (var i in color) {
+ if (color.hasOwnProperty(i)) {
+ if (i === "a") {
+ newColor[i] = color[i];
+ }
+ else {
+ newColor[i] = convertToPercentage(color[i]);
+ }
+ }
+ }
+ color = newColor;
+ }
+
+ return tinycolor(color, opts);
+ };
+
+ // Given a string or object, convert that input to RGB
+ // Possible string inputs:
+ //
+ // "red"
+ // "#f00" or "f00"
+ // "#ff0000" or "ff0000"
+ // "#ff000000" or "ff000000"
+ // "rgb 255 0 0" or "rgb (255, 0, 0)"
+ // "rgb 1.0 0 0" or "rgb (1, 0, 0)"
+ // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
+ // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
+ // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
+ // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
+ // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
+ //
+ function inputToRGB(color) {
+
+ var rgb = { r: 0, g: 0, b: 0 };
+ var a = 1;
+ var ok = false;
+ var format = false;
+
+ if (typeof color == "string") {
+ color = stringInputToObject(color);
+ }
+
+ if (typeof color == "object") {
+ if (color.hasOwnProperty("r") && color.hasOwnProperty("g") && color.hasOwnProperty("b")) {
+ rgb = rgbToRgb(color.r, color.g, color.b);
+ ok = true;
+ format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
+ }
+ else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("v")) {
+ color.s = convertToPercentage(color.s);
+ color.v = convertToPercentage(color.v);
+ rgb = hsvToRgb(color.h, color.s, color.v);
+ ok = true;
+ format = "hsv";
+ }
+ else if (color.hasOwnProperty("h") && color.hasOwnProperty("s") && color.hasOwnProperty("l")) {
+ color.s = convertToPercentage(color.s);
+ color.l = convertToPercentage(color.l);
+ rgb = hslToRgb(color.h, color.s, color.l);
+ ok = true;
+ format = "hsl";
+ }
+
+ if (color.hasOwnProperty("a")) {
+ a = color.a;
+ }
+ }
+
+ a = boundAlpha(a);
+
+ return {
+ ok: ok,
+ format: color.format || format,
+ r: mathMin(255, mathMax(rgb.r, 0)),
+ g: mathMin(255, mathMax(rgb.g, 0)),
+ b: mathMin(255, mathMax(rgb.b, 0)),
+ a: a
+ };
+ }
+
+
+ // Conversion Functions
+ // --------------------
+
+ // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
+ //
+
+ // `rgbToRgb`
+ // Handle bounds / percentage checking to conform to CSS color spec
+ //
+ // *Assumes:* r, g, b in [0, 255] or [0, 1]
+ // *Returns:* { r, g, b } in [0, 255]
+ function rgbToRgb(r, g, b){
+ return {
+ r: bound01(r, 255) * 255,
+ g: bound01(g, 255) * 255,
+ b: bound01(b, 255) * 255
+ };
+ }
+
+ // `rgbToHsl`
+ // Converts an RGB color value to HSL.
+ // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
+ // *Returns:* { h, s, l } in [0,1]
+ function rgbToHsl(r, g, b) {
+
+ r = bound01(r, 255);
+ g = bound01(g, 255);
+ b = bound01(b, 255);
+
+ var max = mathMax(r, g, b), min = mathMin(r, g, b);
+ var h, s, l = (max + min) / 2;
+
+ if(max == min) {
+ h = s = 0; // achromatic
+ }
+ else {
+ var d = max - min;
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
+ switch(max) {
+ case r: h = (g - b) / d + (g < b ? 6 : 0); break;
+ case g: h = (b - r) / d + 2; break;
+ case b: h = (r - g) / d + 4; break;
+ }
+
+ h /= 6;
+ }
+
+ return { h: h, s: s, l: l };
+ }
+
+ // `hslToRgb`
+ // Converts an HSL color value to RGB.
+ // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
+ // *Returns:* { r, g, b } in the set [0, 255]
+ function hslToRgb(h, s, l) {
+ var r, g, b;
+
+ h = bound01(h, 360);
+ s = bound01(s, 100);
+ l = bound01(l, 100);
+
+ function hue2rgb(p, q, t) {
+ if(t < 0) t += 1;
+ if(t > 1) t -= 1;
+ if(t < 1/6) return p + (q - p) * 6 * t;
+ if(t < 1/2) return q;
+ if(t < 2/3) return p + (q - p) * (2/3 - t) * 6;
+ return p;
+ }
+
+ if(s === 0) {
+ r = g = b = l; // achromatic
+ }
+ else {
+ var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
+ var p = 2 * l - q;
+ r = hue2rgb(p, q, h + 1/3);
+ g = hue2rgb(p, q, h);
+ b = hue2rgb(p, q, h - 1/3);
+ }
+
+ return { r: r * 255, g: g * 255, b: b * 255 };
+ }
+
+ // `rgbToHsv`
+ // Converts an RGB color value to HSV
+ // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
+ // *Returns:* { h, s, v } in [0,1]
+ function rgbToHsv(r, g, b) {
+
+ r = bound01(r, 255);
+ g = bound01(g, 255);
+ b = bound01(b, 255);
+
+ var max = mathMax(r, g, b), min = mathMin(r, g, b);
+ var h, s, v = max;
+
+ var d = max - min;
+ s = max === 0 ? 0 : d / max;
+
+ if(max == min) {
+ h = 0; // achromatic
+ }
+ else {
+ switch(max) {
+ case r: h = (g - b) / d + (g < b ? 6 : 0); break;
+ case g: h = (b - r) / d + 2; break;
+ case b: h = (r - g) / d + 4; break;
+ }
+ h /= 6;
+ }
+ return { h: h, s: s, v: v };
+ }
+
+ // `hsvToRgb`
+ // Converts an HSV color value to RGB.
+ // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
+ // *Returns:* { r, g, b } in the set [0, 255]
+ function hsvToRgb(h, s, v) {
+
+ h = bound01(h, 360) * 6;
+ s = bound01(s, 100);
+ v = bound01(v, 100);
+
+ var i = math.floor(h),
+ f = h - i,
+ p = v * (1 - s),
+ q = v * (1 - f * s),
+ t = v * (1 - (1 - f) * s),
+ mod = i % 6,
+ r = [v, q, p, p, t, v][mod],
+ g = [t, v, v, q, p, p][mod],
+ b = [p, p, t, v, v, q][mod];
+
+ return { r: r * 255, g: g * 255, b: b * 255 };
+ }
+
+ // `rgbToHex`
+ // Converts an RGB color to hex
+ // Assumes r, g, and b are contained in the set [0, 255]
+ // Returns a 3 or 6 character hex
+ function rgbToHex(r, g, b, allow3Char) {
+
+ var hex = [
+ pad2(mathRound(r).toString(16)),
+ pad2(mathRound(g).toString(16)),
+ pad2(mathRound(b).toString(16))
+ ];
+
+ // Return a 3 character hex if possible
+ if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
+ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
+ }
+
+ return hex.join("");
+ }
+ // `rgbaToHex`
+ // Converts an RGBA color plus alpha transparency to hex
+ // Assumes r, g, b and a are contained in the set [0, 255]
+ // Returns an 8 character hex
+ function rgbaToHex(r, g, b, a) {
+
+ var hex = [
+ pad2(convertDecimalToHex(a)),
+ pad2(mathRound(r).toString(16)),
+ pad2(mathRound(g).toString(16)),
+ pad2(mathRound(b).toString(16))
+ ];
+
+ return hex.join("");
+ }
+
+ // `equals`
+ // Can be called with any tinycolor input
+ tinycolor.equals = function (color1, color2) {
+ if (!color1 || !color2) { return false; }
+ return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
+ };
+ tinycolor.random = function() {
+ return tinycolor.fromRatio({
+ r: mathRandom(),
+ g: mathRandom(),
+ b: mathRandom()
+ });
+ };
+
+
+ // Modification Functions
+ // ----------------------
+ // Thanks to less.js for some of the basics here
+ //
+
+ tinycolor.desaturate = function (color, amount) {
+ amount = (amount === 0) ? 0 : (amount || 10);
+ var hsl = tinycolor(color).toHsl();
+ hsl.s -= amount / 100;
+ hsl.s = clamp01(hsl.s);
+ return tinycolor(hsl);
+ };
+ tinycolor.saturate = function (color, amount) {
+ amount = (amount === 0) ? 0 : (amount || 10);
+ var hsl = tinycolor(color).toHsl();
+ hsl.s += amount / 100;
+ hsl.s = clamp01(hsl.s);
+ return tinycolor(hsl);
+ };
+ tinycolor.greyscale = function(color) {
+ return tinycolor.desaturate(color, 100);
+ };
+ tinycolor.lighten = function(color, amount) {
+ amount = (amount === 0) ? 0 : (amount || 10);
+ var hsl = tinycolor(color).toHsl();
+ hsl.l += amount / 100;
+ hsl.l = clamp01(hsl.l);
+ return tinycolor(hsl);
+ };
+ tinycolor.darken = function (color, amount) {
+ amount = (amount === 0) ? 0 : (amount || 10);
+ var hsl = tinycolor(color).toHsl();
+ hsl.l -= amount / 100;
+ hsl.l = clamp01(hsl.l);
+ return tinycolor(hsl);
+ };
+ tinycolor.complement = function(color) {
+ var hsl = tinycolor(color).toHsl();
+ hsl.h = (hsl.h + 180) % 360;
+ return tinycolor(hsl);
+ };
+
+
+ // Combination Functions
+ // ---------------------
+ // Thanks to jQuery xColor for some of the ideas behind these
+ //
+
+ tinycolor.triad = function(color) {
+ var hsl = tinycolor(color).toHsl();
+ var h = hsl.h;
+ return [
+ tinycolor(color),
+ tinycolor({ h: (h + 120) % 360, s: hsl.s, l: hsl.l }),
+ tinycolor({ h: (h + 240) % 360, s: hsl.s, l: hsl.l })
+ ];
+ };
+ tinycolor.tetrad = function(color) {
+ var hsl = tinycolor(color).toHsl();
+ var h = hsl.h;
+ return [
+ tinycolor(color),
+ tinycolor({ h: (h + 90) % 360, s: hsl.s, l: hsl.l }),
+ tinycolor({ h: (h + 180) % 360, s: hsl.s, l: hsl.l }),
+ tinycolor({ h: (h + 270) % 360, s: hsl.s, l: hsl.l })
+ ];
+ };
+ tinycolor.splitcomplement = function(color) {
+ var hsl = tinycolor(color).toHsl();
+ var h = hsl.h;
+ return [
+ tinycolor(color),
+ tinycolor({ h: (h + 72) % 360, s: hsl.s, l: hsl.l}),
+ tinycolor({ h: (h + 216) % 360, s: hsl.s, l: hsl.l})
+ ];
+ };
+ tinycolor.analogous = function(color, results, slices) {
+ results = results || 6;
+ slices = slices || 30;
+
+ var hsl = tinycolor(color).toHsl();
+ var part = 360 / slices;
+ var ret = [tinycolor(color)];
+
+ for (hsl.h = ((hsl.h - (part * results >> 1)) + 720) % 360; --results; ) {
+ hsl.h = (hsl.h + part) % 360;
+ ret.push(tinycolor(hsl));
+ }
+ return ret;
+ };
+ tinycolor.monochromatic = function(color, results) {
+ results = results || 6;
+ var hsv = tinycolor(color).toHsv();
+ var h = hsv.h, s = hsv.s, v = hsv.v;
+ var ret = [];
+ var modification = 1 / results;
+
+ while (results--) {
+ ret.push(tinycolor({ h: h, s: s, v: v}));
+ v = (v + modification) % 1;
+ }
+
+ return ret;
+ };
+
+
+ // Readability Functions
+ // ---------------------
+ //
+
+ // `readability`
+ // Analyze the 2 colors and returns an object with the following properties:
+ // `brightness`: difference in brightness between the two colors
+ // `color`: difference in color/hue between the two colors
+ tinycolor.readability = function(color1, color2) {
+ var a = tinycolor(color1).toRgb();
+ var b = tinycolor(color2).toRgb();
+ var brightnessA = (a.r * 299 + a.g * 587 + a.b * 114) / 1000;
+ var brightnessB = (b.r * 299 + b.g * 587 + b.b * 114) / 1000;
+ var colorDiff = (
+ Math.max(a.r, b.r) - Math.min(a.r, b.r) +
+ Math.max(a.g, b.g) - Math.min(a.g, b.g) +
+ Math.max(a.b, b.b) - Math.min(a.b, b.b)
+ );
+
+ return {
+ brightness: Math.abs(brightnessA - brightnessB),
+ color: colorDiff
+ };
+ };
+
+ // `readable`
+ // http://www.w3.org/TR/AERT#color-contrast
+ // Ensure that foreground and background color combinations provide sufficient contrast.
+ // *Example*
+ // tinycolor.readable("#000", "#111") => false
+ tinycolor.readable = function(color1, color2) {
+ var readability = tinycolor.readability(color1, color2);
+ return readability.brightness > 125 && readability.color > 500;
+ };
+
+ // `mostReadable`
+ // Given a base color and a list of possible foreground or background
+ // colors for that base, returns the most readable color.
+ // *Example*
+ // tinycolor.mostReadable("#123", ["#fff", "#000"]) => "#000"
+ tinycolor.mostReadable = function(baseColor, colorList) {
+ var bestColor = null;
+ var bestScore = 0;
+ var bestIsReadable = false;
+ for (var i=0; i < colorList.length; i++) {
+
+ // We normalize both around the "acceptable" breaking point,
+ // but rank brightness constrast higher than hue.
+
+ var readability = tinycolor.readability(baseColor, colorList[i]);
+ var readable = readability.brightness > 125 && readability.color > 500;
+ var score = 3 * (readability.brightness / 125) + (readability.color / 500);
+
+ if ((readable && ! bestIsReadable) ||
+ (readable && bestIsReadable && score > bestScore) ||
+ ((! readable) && (! bestIsReadable) && score > bestScore)) {
+ bestIsReadable = readable;
+ bestScore = score;
+ bestColor = tinycolor(colorList[i]);
+ }
+ }
+ return bestColor;
+ };
+
+
+ // Big List of Colors
+ // ------------------
+ //
+ var names = tinycolor.names = {
+ aliceblue: "f0f8ff",
+ antiquewhite: "faebd7",
+ aqua: "0ff",
+ aquamarine: "7fffd4",
+ azure: "f0ffff",
+ beige: "f5f5dc",
+ bisque: "ffe4c4",
+ black: "000",
+ blanchedalmond: "ffebcd",
+ blue: "00f",
+ blueviolet: "8a2be2",
+ brown: "a52a2a",
+ burlywood: "deb887",
+ burntsienna: "ea7e5d",
+ cadetblue: "5f9ea0",
+ chartreuse: "7fff00",
+ chocolate: "d2691e",
+ coral: "ff7f50",
+ cornflowerblue: "6495ed",
+ cornsilk: "fff8dc",
+ crimson: "dc143c",
+ cyan: "0ff",
+ darkblue: "00008b",
+ darkcyan: "008b8b",
+ darkgoldenrod: "b8860b",
+ darkgray: "a9a9a9",
+ darkgreen: "006400",
+ darkgrey: "a9a9a9",
+ darkkhaki: "bdb76b",
+ darkmagenta: "8b008b",
+ darkolivegreen: "556b2f",
+ darkorange: "ff8c00",
+ darkorchid: "9932cc",
+ darkred: "8b0000",
+ darksalmon: "e9967a",
+ darkseagreen: "8fbc8f",
+ darkslateblue: "483d8b",
+ darkslategray: "2f4f4f",
+ darkslategrey: "2f4f4f",
+ darkturquoise: "00ced1",
+ darkviolet: "9400d3",
+ deeppink: "ff1493",
+ deepskyblue: "00bfff",
+ dimgray: "696969",
+ dimgrey: "696969",
+ dodgerblue: "1e90ff",
+ firebrick: "b22222",
+ floralwhite: "fffaf0",
+ forestgreen: "228b22",
+ fuchsia: "f0f",
+ gainsboro: "dcdcdc",
+ ghostwhite: "f8f8ff",
+ gold: "ffd700",
+ goldenrod: "daa520",
+ gray: "808080",
+ green: "008000",
+ greenyellow: "adff2f",
+ grey: "808080",
+ honeydew: "f0fff0",
+ hotpink: "ff69b4",
+ indianred: "cd5c5c",
+ indigo: "4b0082",
+ ivory: "fffff0",
+ khaki: "f0e68c",
+ lavender: "e6e6fa",
+ lavenderblush: "fff0f5",
+ lawngreen: "7cfc00",
+ lemonchiffon: "fffacd",
+ lightblue: "add8e6",
+ lightcoral: "f08080",
+ lightcyan: "e0ffff",
+ lightgoldenrodyellow: "fafad2",
+ lightgray: "d3d3d3",
+ lightgreen: "90ee90",
+ lightgrey: "d3d3d3",
+ lightpink: "ffb6c1",
+ lightsalmon: "ffa07a",
+ lightseagreen: "20b2aa",
+ lightskyblue: "87cefa",
+ lightslategray: "789",
+ lightslategrey: "789",
+ lightsteelblue: "b0c4de",
+ lightyellow: "ffffe0",
+ lime: "0f0",
+ limegreen: "32cd32",
+ linen: "faf0e6",
+ magenta: "f0f",
+ maroon: "800000",
+ mediumaquamarine: "66cdaa",
+ mediumblue: "0000cd",
+ mediumorchid: "ba55d3",
+ mediumpurple: "9370db",
+ mediumseagreen: "3cb371",
+ mediumslateblue: "7b68ee",
+ mediumspringgreen: "00fa9a",
+ mediumturquoise: "48d1cc",
+ mediumvioletred: "c71585",
+ midnightblue: "191970",
+ mintcream: "f5fffa",
+ mistyrose: "ffe4e1",
+ moccasin: "ffe4b5",
+ navajowhite: "ffdead",
+ navy: "000080",
+ oldlace: "fdf5e6",
+ olive: "808000",
+ olivedrab: "6b8e23",
+ orange: "ffa500",
+ orangered: "ff4500",
+ orchid: "da70d6",
+ palegoldenrod: "eee8aa",
+ palegreen: "98fb98",
+ paleturquoise: "afeeee",
+ palevioletred: "db7093",
+ papayawhip: "ffefd5",
+ peachpuff: "ffdab9",
+ peru: "cd853f",
+ pink: "ffc0cb",
+ plum: "dda0dd",
+ powderblue: "b0e0e6",
+ purple: "800080",
+ red: "f00",
+ rosybrown: "bc8f8f",
+ royalblue: "4169e1",
+ saddlebrown: "8b4513",
+ salmon: "fa8072",
+ sandybrown: "f4a460",
+ seagreen: "2e8b57",
+ seashell: "fff5ee",
+ sienna: "a0522d",
+ silver: "c0c0c0",
+ skyblue: "87ceeb",
+ slateblue: "6a5acd",
+ slategray: "708090",
+ slategrey: "708090",
+ snow: "fffafa",
+ springgreen: "00ff7f",
+ steelblue: "4682b4",
+ tan: "d2b48c",
+ teal: "008080",
+ thistle: "d8bfd8",
+ tomato: "ff6347",
+ turquoise: "40e0d0",
+ violet: "ee82ee",
+ wheat: "f5deb3",
+ white: "fff",
+ whitesmoke: "f5f5f5",
+ yellow: "ff0",
+ yellowgreen: "9acd32"
+ };
+
+ // Make it easy to access colors via `hexNames[hex]`
+ var hexNames = tinycolor.hexNames = flip(names);
+
+
+ // Utilities
+ // ---------
+
+ // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
+ function flip(o) {
+ var flipped = { };
+ for (var i in o) {
+ if (o.hasOwnProperty(i)) {
+ flipped[o[i]] = i;
+ }
+ }
+ return flipped;
+ }
+
+ // Return a valid alpha value [0,1] with all invalid values being set to 1
+ function boundAlpha(a) {
+ a = parseFloat(a);
+
+ if (isNaN(a) || a < 0 || a > 1) {
+ a = 1;
+ }
+
+ return a;
+ }
+
+ // Take input from [0, n] and return it as [0, 1]
+ function bound01(n, max) {
+ if (isOnePointZero(n)) { n = "100%"; }
+
+ var processPercent = isPercentage(n);
+ n = mathMin(max, mathMax(0, parseFloat(n)));
+
+ // Automatically convert percentage into number
+ if (processPercent) {
+ n = parseInt(n * max, 10) / 100;
+ }
+
+ // Handle floating point rounding errors
+ if ((math.abs(n - max) < 0.000001)) {
+ return 1;
+ }
+
+ // Convert into [0, 1] range if it isn't already
+ return (n % max) / parseFloat(max);
+ }
+
+ // Force a number between 0 and 1
+ function clamp01(val) {
+ return mathMin(1, mathMax(0, val));
+ }
+
+ // Parse a base-16 hex value into a base-10 integer
+ function parseIntFromHex(val) {
+ return parseInt(val, 16);
+ }
+
+ // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
+ //
+ function isOnePointZero(n) {
+ return typeof n == "string" && n.indexOf('.') != -1 && parseFloat(n) === 1;
+ }
+
+ // Check to see if string passed in is a percentage
+ function isPercentage(n) {
+ return typeof n === "string" && n.indexOf('%') != -1;
+ }
+
+ // Force a hex value to have 2 characters
+ function pad2(c) {
+ return c.length == 1 ? '0' + c : '' + c;
+ }
+
+ // Replace a decimal with it's percentage value
+ function convertToPercentage(n) {
+ if (n <= 1) {
+ n = (n * 100) + "%";
+ }
+
+ return n;
+ }
+
+ // Converts a decimal to a hex value
+ function convertDecimalToHex(d) {
+ return Math.round(parseFloat(d) * 255).toString(16);
+ }
+ // Converts a hex value to a decimal
+ function convertHexToDecimal(h) {
+ return (parseIntFromHex(h) / 255);
+ }
+
+ var matchers = (function() {
+
+ //
+ var CSS_INTEGER = "[-\\+]?\\d+%?";
+
+ //
+ var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
+
+ // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
+ var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
+
+ // Actual matching.
+ // Parentheses and commas are optional, but not required.
+ // Whitespace can take the place of commas or opening paren
+ var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
+ var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
+
+ return {
+ rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
+ rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
+ hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
+ hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
+ hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
+ hex3: /^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
+ hex6: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
+ hex8: /^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
+ };
+ })();
+
+ // `stringInputToObject`
+ // Permissive string parsing. Take in a number of formats, and output an object
+ // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
+ function stringInputToObject(color) {
+
+ color = color.replace(trimLeft,'').replace(trimRight, '').toLowerCase();
+ var named = false;
+ if (names[color]) {
+ color = names[color];
+ named = true;
+ }
+ else if (color == 'transparent') {
+ return { r: 0, g: 0, b: 0, a: 0, format: "name" };
+ }
+
+ // Try to match string input using regular expressions.
+ // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
+ // Just return an object and let the conversion functions handle that.
+ // This way the result will be the same whether the tinycolor is initialized with string or object.
+ var match;
+ if ((match = matchers.rgb.exec(color))) {
+ return { r: match[1], g: match[2], b: match[3] };
+ }
+ if ((match = matchers.rgba.exec(color))) {
+ return { r: match[1], g: match[2], b: match[3], a: match[4] };
+ }
+ if ((match = matchers.hsl.exec(color))) {
+ return { h: match[1], s: match[2], l: match[3] };
+ }
+ if ((match = matchers.hsla.exec(color))) {
+ return { h: match[1], s: match[2], l: match[3], a: match[4] };
+ }
+ if ((match = matchers.hsv.exec(color))) {
+ return { h: match[1], s: match[2], v: match[3] };
+ }
+ if ((match = matchers.hex8.exec(color))) {
+ return {
+ a: convertHexToDecimal(match[1]),
+ r: parseIntFromHex(match[2]),
+ g: parseIntFromHex(match[3]),
+ b: parseIntFromHex(match[4]),
+ format: named ? "name" : "hex8"
+ };
+ }
+ if ((match = matchers.hex6.exec(color))) {
+ return {
+ r: parseIntFromHex(match[1]),
+ g: parseIntFromHex(match[2]),
+ b: parseIntFromHex(match[3]),
+ format: named ? "name" : "hex"
+ };
+ }
+ if ((match = matchers.hex3.exec(color))) {
+ return {
+ r: parseIntFromHex(match[1] + '' + match[1]),
+ g: parseIntFromHex(match[2] + '' + match[2]),
+ b: parseIntFromHex(match[3] + '' + match[3]),
+ format: named ? "name" : "hex"
+ };
+ }
+
+ return false;
+ }
+
+ // Expose tinycolor to window, does not need to run in non-browser context.
+ window.tinycolor = tinycolor;
+
+ })();
+
+
+ $(function () {
+ if ($.fn.spectrum.load) {
+ $.fn.spectrum.processNativeColorInputs();
+ }
+ });
+
+})(window, jQuery);
diff --git a/node_modules/leaflet-draw/docs/examples-0.7.x/snapping.html b/node_modules/leaflet-draw/docs/examples-0.7.x/snapping.html
new file mode 100644
index 00000000..ced11664
--- /dev/null
+++ b/node_modules/leaflet-draw/docs/examples-0.7.x/snapping.html
@@ -0,0 +1,171 @@
+
+
+
+ Leaflet.draw drawing with snapping
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Rectangle -> Blue
+
+
+
diff --git a/node_modules/leaflet-draw/docs/examples/basic.html b/node_modules/leaflet-draw/docs/examples/basic.html
new file mode 100644
index 00000000..10b3d896
--- /dev/null
+++ b/node_modules/leaflet-draw/docs/examples/basic.html
@@ -0,0 +1,108 @@
+
+
+
+ Leaflet.draw drawing and editing tools
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+Rectangle -> Blue
+
+
+
diff --git a/node_modules/leaflet-draw/docs/examples/edithandlers.html b/node_modules/leaflet-draw/docs/examples/edithandlers.html
new file mode 100644
index 00000000..4d6326ca
--- /dev/null
+++ b/node_modules/leaflet-draw/docs/examples/edithandlers.html
@@ -0,0 +1,79 @@
+
+
+
+ Leaflet.draw vector editing handlers
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/node_modules/leaflet-draw/docs/examples/full.html b/node_modules/leaflet-draw/docs/examples/full.html
new file mode 100644
index 00000000..f8f2b832
--- /dev/null
+++ b/node_modules/leaflet-draw/docs/examples/full.html
@@ -0,0 +1,85 @@
+
+
+
+ Leaflet.draw vector editing handlers
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/node_modules/leaflet-draw/docs/examples/libs/Leaflet.draw.drag-src.js b/node_modules/leaflet-draw/docs/examples/libs/Leaflet.draw.drag-src.js
new file mode 100644
index 00000000..c7468241
--- /dev/null
+++ b/node_modules/leaflet-draw/docs/examples/libs/Leaflet.draw.drag-src.js
@@ -0,0 +1,894 @@
+/**
+ * Matrix transform path for SVG/VML
+ * TODO: adapt to Leaflet 0.8 upon release
+ */
+
+"use strict";
+
+if (L.Browser.svg) { // SVG transformation
+
+ L.Path.include({
+
+ /**
+ * Reset transform matrix
+ */
+ _resetTransform: function() {
+ this._container.setAttributeNS(null, 'transform', '');
+ },
+
+ /**
+ * Applies matrix transformation to SVG
+ * @param {Array.} matrix
+ */
+ _applyTransform: function(matrix) {
+ this._container.setAttributeNS(null, "transform",
+ 'matrix(' + matrix.join(' ') + ')');
+ }
+
+ });
+
+} else { // VML transform routines
+
+ L.Path.include({
+
+ /**
+ * Reset transform matrix
+ */
+ _resetTransform: function() {
+ if (this._skew) {
+ // super important! workaround for a 'jumping' glitch:
+ // disable transform before removing it
+ this._skew.on = false;
+ this._container.removeChild(this._skew);
+ this._skew = null;
+ }
+ },
+
+ /**
+ * Applies matrix transformation to VML
+ * @param {Array.} matrix
+ */
+ _applyTransform: function(matrix) {
+ var skew = this._skew;
+
+ if (!skew) {
+ skew = this._createElement('skew');
+ this._container.appendChild(skew);
+ skew.style.behavior = 'url(#default#VML)';
+ this._skew = skew;
+ }
+
+ // handle skew/translate separately, cause it's broken
+ var mt = matrix[0].toFixed(8) + " " + matrix[1].toFixed(8) + " " +
+ matrix[2].toFixed(8) + " " + matrix[3].toFixed(8) + " 0 0";
+ var offset = Math.floor(matrix[4]).toFixed() + ", " +
+ Math.floor(matrix[5]).toFixed() + "";
+
+ var s = this._container.style;
+ var l = parseFloat(s.left);
+ var t = parseFloat(s.top);
+ var w = parseFloat(s.width);
+ var h = parseFloat(s.height);
+
+ if (isNaN(l)) l = 0;
+ if (isNaN(t)) t = 0;
+ if (isNaN(w) || !w) w = 1;
+ if (isNaN(h) || !h) h = 1;
+
+ var origin = (-l / w - 0.5).toFixed(8) + " " + (-t / h - 0.5).toFixed(8);
+
+ skew.on = "f";
+ skew.matrix = mt;
+ skew.origin = origin;
+ skew.offset = offset;
+ skew.on = true;
+ }
+
+ });
+}
+
+// Renderer-independent
+L.Path.include({
+
+ /**
+ * Check if the feature was dragged, that'll supress the click event
+ * on mouseup. That fixes popups for example
+ *
+ * @param {MouseEvent} e
+ */
+ _onMouseClick: function(e) {
+ if ((this.dragging && this.dragging.moved()) ||
+ (this._map.dragging && this._map.dragging.moved())) {
+ return;
+ }
+
+ this._fireMouseEvent(e);
+ }
+});
+/**
+ * Leaflet vector features drag functionality
+ * @preserve
+ */
+
+"use strict";
+
+/**
+ * Drag handler
+ * @class L.Path.Drag
+ * @extends {L.Handler}
+ */
+L.Handler.PathDrag = L.Handler.extend( /** @lends L.Path.Drag.prototype */ {
+
+ /**
+ * @param {L.Path} path
+ * @constructor
+ */
+ initialize: function(path) {
+
+ /**
+ * @type {L.Path}
+ */
+ this._path = path;
+
+ /**
+ * @type {Array.}
+ */
+ this._matrix = null;
+
+ /**
+ * @type {L.Point}
+ */
+ this._startPoint = null;
+
+ /**
+ * @type {L.Point}
+ */
+ this._dragStartPoint = null;
+
+ },
+
+ /**
+ * Enable dragging
+ */
+ addHooks: function() {
+ this._path.on('mousedown', this._onDragStart, this);
+ L.DomUtil.addClass(this._path._container, 'leaflet-path-draggable');
+ },
+
+ /**
+ * Disable dragging
+ */
+ removeHooks: function() {
+ this._path.off('mousedown', this._onDragStart, this);
+ L.DomUtil.removeClass(this._path._container, 'leaflet-path-draggable');
+ },
+
+ /**
+ * @return {Boolean}
+ */
+ moved: function() {
+ return this._path._dragMoved;
+ },
+
+ /**
+ * Start drag
+ * @param {L.MouseEvent} evt
+ */
+ _onDragStart: function(evt) {
+ this._startPoint = evt.containerPoint.clone();
+ this._dragStartPoint = evt.containerPoint.clone();
+ this._matrix = [1, 0, 0, 1, 0, 0];
+
+ this._path._map
+ .on('mousemove', this._onDrag, this)
+ .on('mouseup', this._onDragEnd, this)
+ this._path._dragMoved = false;
+ },
+
+ /**
+ * Dragging
+ * @param {L.MouseEvent} evt
+ */
+ _onDrag: function(evt) {
+ var x = evt.containerPoint.x;
+ var y = evt.containerPoint.y;
+
+ var dx = x - this._startPoint.x;
+ var dy = y - this._startPoint.y;
+
+ if (!this._path._dragMoved && (dx || dy)) {
+ this._path._dragMoved = true;
+ this._path.fire('dragstart');
+ }
+
+ this._matrix[4] += dx;
+ this._matrix[5] += dy;
+
+ this._startPoint.x = x;
+ this._startPoint.y = y;
+
+ this._path._applyTransform(this._matrix);
+ this._path.fire('drag');
+ L.DomEvent.stop(evt.originalEvent);
+ },
+
+ /**
+ * Dragging stopped, apply
+ * @param {L.MouseEvent} evt
+ */
+ _onDragEnd: function(evt) {
+ L.DomEvent.stop(evt);
+ // undo container transform
+ this._path._resetTransform();
+ // apply matrix
+ this._transformPoints(this._matrix);
+
+ this._path._map
+ .off('mousemove', this._onDrag, this)
+ .off('mouseup', this._onDragEnd, this);
+
+ // consistency
+ this._path.fire('dragend', {
+ distance: Math.sqrt(
+ L.LineUtil._sqDist(this._dragStartPoint, evt.containerPoint)
+ )
+ });
+
+ this._matrix = null;
+ this._startPoint = null;
+ this._dragStartPoint = null;
+ },
+
+ /**
+ * Applies transformation, does it in one sweep for performance,
+ * so don't be surprised about the code repetition.
+ *
+ * [ x ] [ a b tx ] [ x ] [ a * x + b * y + tx ]
+ * [ y ] = [ c d ty ] [ y ] = [ c * x + d * y + ty ]
+ *
+ * @param {Array.} matrix
+ */
+ _transformPoints: function(matrix) {
+ var path = this._path;
+ var i, len, latlng;
+
+ var px = L.point(matrix[4], matrix[5]);
+
+ var crs = path._map.options.crs;
+ var transformation = crs.transformation;
+ var scale = crs.scale(path._map.getZoom());
+ var projection = crs.projection;
+
+ var diff = transformation.untransform(px, scale)
+ .subtract(transformation.untransform(L.point(0, 0), scale));
+
+ // console.time('transform');
+
+ // all shifts are in-place
+ if (path._point) { // L.Circle
+ path._latlng = projection.unproject(
+ projection.project(path._latlng)._add(diff));
+ path._point._add(px);
+ } else if (path._originalPoints) { // everything else
+ for (i = 0, len = path._originalPoints.length; i < len; i++) {
+ latlng = path._latlngs[i];
+ path._latlngs[i] = projection
+ .unproject(projection.project(latlng)._add(diff));
+ path._originalPoints[i]._add(px);
+ }
+ }
+
+ // holes operations
+ if (path._holes) {
+ for (i = 0, len = path._holes.length; i < len; i++) {
+ for (var j = 0, len2 = path._holes[i].length; j < len2; j++) {
+ latlng = path._holes[i][j];
+ path._holes[i][j] = projection
+ .unproject(projection.project(latlng)._add(diff));
+ path._holePoints[i][j]._add(px);
+ }
+ }
+ }
+
+ // console.timeEnd('transform');
+
+ path._updatePath();
+ }
+
+});
+
+L.Path.prototype.__initEvents = L.Path.prototype._initEvents;
+L.Path.prototype._initEvents = function() {
+ this.__initEvents();
+
+ if (this.options.draggable) {
+ if (this.dragging) {
+ this.dragging.enable();
+ } else {
+ this.dragging = new L.Handler.PathDrag(this);
+ this.dragging.enable();
+ }
+ } else if (this.dragging) {
+ this.dragging.disable();
+ }
+};
+(function() {
+
+ // listen and propagate dragstart on sub-layers
+ L.FeatureGroup.EVENTS += ' dragstart';
+
+ function wrapMethod(klasses, methodName, method) {
+ for (var i = 0, len = klasses.length; i < len; i++) {
+ var klass = klasses[i];
+ klass.prototype['_' + methodName] = klass.prototype[methodName];
+ klass.prototype[methodName] = method;
+ }
+ }
+
+ /**
+ * @param {L.Polygon|L.Polyline} layer
+ * @return {L.MultiPolygon|L.MultiPolyline}
+ */
+ function addLayer(layer) {
+ if (this.hasLayer(layer)) {
+ return this;
+ }
+ layer
+ .on('drag', this._onDrag, this)
+ .on('dragend', this._onDragEnd, this);
+ return this._addLayer.call(this, layer);
+ }
+
+ /**
+ * @param {L.Polygon|L.Polyline} layer
+ * @return {L.MultiPolygon|L.MultiPolyline}
+ */
+ function removeLayer(layer) {
+ if (!this.hasLayer(layer)) {
+ return this;
+ }
+ layer
+ .off('drag', this._onDrag, this)
+ .off('dragend', this._onDragEnd, this);
+ return this._removeLayer.call(this, layer);
+ }
+
+ // duck-type methods to listen to the drag events
+ wrapMethod([L.MultiPolygon, L.MultiPolyline], 'addLayer', addLayer);
+ wrapMethod([L.MultiPolygon, L.MultiPolyline], 'removeLayer', removeLayer);
+
+ var dragMethods = {
+ _onDrag: function(evt) {
+ var layer = evt.target;
+ this.eachLayer(function(otherLayer) {
+ if (otherLayer !== layer) {
+ otherLayer._applyTransform(layer.dragging._matrix);
+ }
+ });
+
+ this._propagateEvent(evt);
+ },
+
+ _onDragEnd: function(evt) {
+ var layer = evt.target;
+
+ this.eachLayer(function(otherLayer) {
+ if (otherLayer !== layer) {
+ otherLayer._resetTransform();
+ otherLayer.dragging._transformPoints(layer.dragging._matrix);
+ }
+ });
+
+ this._propagateEvent(evt);
+ }
+ };
+
+ L.MultiPolygon.include(dragMethods);
+ L.MultiPolyline.include(dragMethods);
+
+})();
+// TODO: dismiss that on Leaflet 0.8.x release
+
+L.Polygon.include( /** @lends L.Polygon.prototype */ {
+
+ /**
+ * @return {L.LatLng}
+ */
+ getCenter: function() {
+ var i, j, len, p1, p2, f, area, x, y,
+ points = this._parts[0];
+
+ // polygon centroid algorithm; only uses the first ring if there are multiple
+
+ area = x = y = 0;
+
+ for (i = 0, len = points.length, j = len - 1; i < len; j = i++) {
+ p1 = points[i];
+ p2 = points[j];
+
+ f = p1.y * p2.x - p2.y * p1.x;
+ x += (p1.x + p2.x) * f;
+ y += (p1.y + p2.y) * f;
+ area += f * 3;
+ }
+
+ return this._map.layerPointToLatLng([x / area, y / area]);
+ }
+
+});
+"use strict";
+
+/**
+ * Static flag for move markers
+ * @type {Boolean}
+ */
+L.EditToolbar.Edit.MOVE_MARKERS = false;
+
+L.EditToolbar.Edit.include( /** @lends L.EditToolbar.Edit.prototype */ {
+
+ /**
+ * @override
+ */
+ initialize: function(map, options) {
+ L.EditToolbar.Edit.MOVE_MARKERS = !!options.selectedPathOptions.moveMarkers;
+ this._initialize(map, options);
+ },
+
+ /**
+ * @param {L.Map} map
+ * @param {Object} options
+ */
+ _initialize: L.EditToolbar.Edit.prototype.initialize
+
+});
+/**
+ * Mainly central marker routines
+ */
+
+L.Edit.SimpleShape.include( /** @lends L.Edit.SimpleShape.prototype */ {
+
+ /**
+ * Put move marker into center
+ */
+ _updateMoveMarker: function() {
+ if (this._moveMarker) {
+ this._moveMarker.setLatLng(this._getShapeCenter());
+ }
+ },
+
+ /**
+ * Shape centroid
+ * @return {L.LatLng}
+ */
+ _getShapeCenter: function() {
+ return this._shape.getBounds().getCenter();
+ },
+
+ /**
+ * @override
+ */
+ _createMoveMarker: function() {
+ if (L.EditToolbar.Edit.MOVE_MARKERS) {
+ this._moveMarker = this._createMarker(this._getShapeCenter(),
+ this.options.moveIcon);
+ }
+ }
+
+});
+
+/**
+ * Override this if you don't want the central marker
+ * @type {Boolean}
+ */
+L.Edit.SimpleShape.mergeOptions({
+ moveMarker: false
+});
+/**
+ * Dragging routines for circle
+ */
+
+L.Edit.Circle.include( /** @lends L.Edit.Circle.prototype */ {
+
+ /**
+ * @override
+ */
+ addHooks: function() {
+ if (this._shape._map) {
+ this._map = this._shape._map;
+ if (!this._markerGroup) {
+ this._enableDragging();
+ this._initMarkers();
+ }
+ this._shape._map.addLayer(this._markerGroup);
+ }
+ },
+
+ /**
+ * @override
+ */
+ removeHooks: function() {
+ if (this._shape._map) {
+ for (var i = 0, l = this._resizeMarkers.length; i < l; i++) {
+ this._unbindMarker(this._resizeMarkers[i]);
+ }
+
+ this._disableDragging();
+ this._resizeMarkers = null;
+ this._map.removeLayer(this._markerGroup);
+ delete this._markerGroup;
+ }
+
+ this._map = null;
+ },
+
+ /**
+ * @override
+ */
+ _createMoveMarker: L.Edit.SimpleShape.prototype._createMoveMarker,
+
+ /**
+ * Change
+ * @param {L.LatLng} latlng
+ */
+ _resize: function(latlng) {
+ var center = this._shape.getLatLng();
+ var radius = center.distanceTo(latlng);
+
+ this._shape.setRadius(radius);
+
+ this._updateMoveMarker();
+ },
+
+ /**
+ * Adds drag start listeners
+ */
+ _enableDragging: function() {
+ if (!this._shape.dragging) {
+ this._shape.dragging = new L.Handler.PathDrag(this._shape);
+ }
+ this._shape.dragging.enable();
+ this._shape
+ .on('dragstart', this._onStartDragFeature, this)
+ .on('dragend', this._onStopDragFeature, this);
+ },
+
+ /**
+ * Removes drag start listeners
+ */
+ _disableDragging: function() {
+ this._shape.dragging.disable();
+ this._shape
+ .off('dragstart', this._onStartDragFeature, this)
+ .off('dragend', this._onStopDragFeature, this);
+ },
+
+ /**
+ * Start drag
+ * @param {L.MouseEvent} evt
+ */
+ _onStartDragFeature: function() {
+ this._shape._map.removeLayer(this._markerGroup);
+ this._shape.fire('editstart');
+ },
+
+ /**
+ * Dragging stopped, apply
+ * @param {L.MouseEvent} evt
+ */
+ _onStopDragFeature: function() {
+ var center = this._shape.getLatLng();
+
+ //this._moveMarker.setLatLng(center);
+ this._resizeMarkers[0].setLatLng(this._getResizeMarkerPoint(center));
+
+ // show resize marker
+ this._shape._map.addLayer(this._markerGroup);
+ this._updateMoveMarker();
+ this._fireEdit();
+ }
+});
+/**
+ * Dragging routines for poly handler
+ */
+
+L.Edit.Rectangle.include( /** @lends L.Edit.Rectangle.prototype */ {
+
+ /**
+ * @override
+ */
+ addHooks: function() {
+ if (this._shape._map) {
+ if (!this._markerGroup) {
+ this._enableDragging();
+ this._initMarkers();
+ }
+ this._shape._map.addLayer(this._markerGroup);
+ }
+ },
+
+ /**
+ * @override
+ */
+ removeHooks: function() {
+ if (this._shape._map) {
+ this._shape._map.removeLayer(this._markerGroup);
+ this._disableDragging();
+ delete this._markerGroup;
+ delete this._markers;
+ }
+ },
+
+ /**
+ * @override
+ */
+ _resize: function(latlng) {
+ // Update the shape based on the current position of
+ // this corner and the opposite point
+ this._shape.setBounds(L.latLngBounds(latlng, this._oppositeCorner));
+ this._updateMoveMarker();
+ },
+
+ /**
+ * @override
+ */
+ _onMarkerDragEnd: function(e) {
+ this._toggleCornerMarkers(1);
+ this._repositionCornerMarkers();
+
+ L.Edit.SimpleShape.prototype._onMarkerDragEnd.call(this, e);
+ },
+
+ /**
+ * Adds drag start listeners
+ */
+ _enableDragging: function() {
+ if (!this._shape.dragging) {
+ this._shape.dragging = new L.Handler.PathDrag(this._shape);
+ }
+ this._shape.dragging.enable();
+ this._shape
+ .on('dragstart', this._onStartDragFeature, this)
+ .on('dragend', this._onStopDragFeature, this);
+ },
+
+ /**
+ * Removes drag start listeners
+ */
+ _disableDragging: function() {
+ this._shape.dragging.disable();
+ this._shape
+ .off('dragstart', this._onStartDragFeature, this)
+ .off('dragend', this._onStopDragFeature, this);
+ },
+
+ /**
+ * Start drag
+ * @param {L.MouseEvent} evt
+ */
+ _onStartDragFeature: function() {
+ this._shape._map.removeLayer(this._markerGroup);
+ this._shape.fire('editstart');
+ },
+
+ /**
+ * Dragging stopped, apply
+ * @param {L.MouseEvent} evt
+ */
+ _onStopDragFeature: function() {
+ var polygon = this._shape;
+ for (var i = 0, len = polygon._latlngs.length; i < len; i++) {
+ // update marker
+ var marker = this._resizeMarkers[i];
+ marker.setLatLng(polygon._latlngs[i]);
+
+ // this one's needed to update the path
+ marker._origLatLng = polygon._latlngs[i];
+ if (marker._middleLeft) {
+ marker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));
+ }
+ if (marker._middleRight) {
+ marker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));
+ }
+ }
+ // this._moveMarker.setLatLng(polygon.getBounds().getCenter());
+
+ // show vertices
+ this._shape._map.addLayer(this._markerGroup);
+ this._updateMoveMarker();
+
+ this._repositionCornerMarkers();
+ this._fireEdit();
+ }
+});
+/**
+ * Dragging routines for poly handler
+ */
+
+L.Edit.PolyVerticesEdit.include( /** @lends L.Edit.PolyVerticesEdit.prototype */ {
+
+ // store methods to call them in overrides
+ __createMarker: L.Edit.PolyVerticesEdit.prototype._createMarker,
+ __removeMarker: L.Edit.PolyVerticesEdit.prototype._removeMarker,
+
+ /**
+ * @override
+ */
+ addHooks: function() {
+ if (this._poly._map) {
+ if (!this._markerGroup) {
+ this._enableDragging();
+ this._initMarkers();
+ // Create center marker
+ this._createMoveMarker();
+ }
+ this._poly._map.addLayer(this._markerGroup);
+ }
+ },
+
+ /**
+ * @override
+ */
+ _createMoveMarker: function() {
+ if (L.EditToolbar.Edit.MOVE_MARKERS && (this._poly instanceof L.Polygon)) {
+ this._moveMarker = new L.Marker(this._getShapeCenter(), {
+ icon: this.options.moveIcon
+ });
+ this._moveMarker.on('mousedown', this._delegateToShape, this);
+ this._markerGroup.addLayer(this._moveMarker);
+ }
+ },
+
+ /**
+ * Start dragging through the marker
+ * @param {L.MouseEvent} evt
+ */
+ _delegateToShape: function(evt) {
+ var poly = this._shape || this._poly;
+ var marker = evt.target;
+ poly.fire('mousedown', L.Util.extend(evt, {
+ containerPoint: L.DomUtil.getPosition(marker._icon)
+ .add(poly._map._getMapPanePos())
+ }));
+ },
+
+ /**
+ * Polygon centroid
+ * @return {L.LatLng}
+ */
+ _getShapeCenter: function() {
+ return this._poly.getCenter();
+ },
+
+ /**
+ * @override
+ */
+ removeHooks: function() {
+ if (this._poly._map) {
+ this._poly._map.removeLayer(this._markerGroup);
+ this._disableDragging();
+ delete this._markerGroup;
+ delete this._markers;
+ }
+ },
+
+ /**
+ * Adds drag start listeners
+ */
+ _enableDragging: function() {
+ if (!this._poly.dragging) {
+ this._poly.dragging = new L.Handler.PathDrag(this._poly);
+ }
+ this._poly.dragging.enable();
+ this._poly
+ .on('dragstart', this._onStartDragFeature, this)
+ .on('dragend', this._onStopDragFeature, this);
+ },
+
+ /**
+ * Removes drag start listeners
+ */
+ _disableDragging: function() {
+ this._poly.dragging.disable();
+ this._poly
+ .off('dragstart', this._onStartDragFeature, this)
+ .off('dragend', this._onStopDragFeature, this);
+ },
+
+ /**
+ * Start drag
+ * @param {L.MouseEvent} evt
+ */
+ _onStartDragFeature: function(evt) {
+ this._poly._map.removeLayer(this._markerGroup);
+ this._poly.fire('editstart');
+ },
+
+ /**
+ * Dragging stopped, apply
+ * @param {L.MouseEvent} evt
+ */
+ _onStopDragFeature: function(evt) {
+ // var polygon = this._poly;
+ for (var i = 0, len = this._latlngs.length; i < len; i++) {
+ // update marker
+ var marker = this._markers[i];
+ marker.setLatLng(this._latlngs[i]);
+
+ // this one's needed to update the path
+ marker._origLatLng = this._latlngs[i];
+ if (marker._middleLeft) {
+ marker._middleLeft.setLatLng(this._getMiddleLatLng(marker._prev, marker));
+ }
+ if (marker._middleRight) {
+ marker._middleRight.setLatLng(this._getMiddleLatLng(marker, marker._next));
+ }
+ }
+
+ // show vertices
+ this._poly._map.addLayer(this._markerGroup);
+ L.Edit.SimpleShape.prototype._updateMoveMarker.call(this);
+ this._fireEdit();
+ },
+
+ /**
+ * Copy from simple shape
+ */
+ _updateMoveMarker: L.Edit.SimpleShape.prototype._updateMoveMarker,
+
+ /**
+ * @override
+ */
+ _createMarker: function(latlng, index) {
+ var marker = this.__createMarker(latlng, index);
+ marker
+ .on('dragstart', this._hideMoveMarker, this)
+ .on('dragend', this._showUpdateMoveMarker, this);
+ return marker;
+ },
+
+ /**
+ * @override
+ */
+ _removeMarker: function(marker) {
+ this.__removeMarker(marker);
+ marker
+ .off('dragstart', this._hideMoveMarker, this)
+ .off('dragend', this._showUpdateMoveMarker, this);
+ },
+
+ /**
+ * Hide move marker while dragging a vertex
+ */
+ _hideMoveMarker: function() {
+ if (this._moveMarker) {
+ this._markerGroup.removeLayer(this._moveMarker);
+ }
+ },
+
+ /**
+ * Show and update move marker
+ */
+ _showUpdateMoveMarker: function() {
+ if (this._moveMarker) {
+ this._markerGroup.addLayer(this._moveMarker);
+ this._updateMoveMarker();
+ }
+ }
+
+});
+
+/**
+ * @type {L.DivIcon}
+ */
+L.Edit.PolyVerticesEdit.prototype.options.moveIcon = new L.DivIcon({
+ iconSize: new L.Point(8, 8),
+ className: 'leaflet-div-icon leaflet-editing-icon leaflet-edit-move'
+});
+
+/**
+ * Override this if you don't want the central marker
+ * @type {Boolean}
+ */
+L.Edit.PolyVerticesEdit.mergeOptions({
+ moveMarker: false
+});
diff --git a/node_modules/leaflet-draw/docs/examples/libs/images/layers-2x.png b/node_modules/leaflet-draw/docs/examples/libs/images/layers-2x.png
new file mode 100644
index 00000000..200c333d
Binary files /dev/null and b/node_modules/leaflet-draw/docs/examples/libs/images/layers-2x.png differ
diff --git a/node_modules/leaflet-draw/docs/examples/libs/images/layers.png b/node_modules/leaflet-draw/docs/examples/libs/images/layers.png
new file mode 100644
index 00000000..1a72e578
Binary files /dev/null and b/node_modules/leaflet-draw/docs/examples/libs/images/layers.png differ
diff --git a/node_modules/leaflet-draw/docs/examples/libs/images/marker-icon-2x.png b/node_modules/leaflet-draw/docs/examples/libs/images/marker-icon-2x.png
new file mode 100644
index 00000000..e4abba3b
Binary files /dev/null and b/node_modules/leaflet-draw/docs/examples/libs/images/marker-icon-2x.png differ
diff --git a/node_modules/leaflet-draw/docs/examples/libs/images/marker-icon.png b/node_modules/leaflet-draw/docs/examples/libs/images/marker-icon.png
new file mode 100644
index 00000000..950edf24
Binary files /dev/null and b/node_modules/leaflet-draw/docs/examples/libs/images/marker-icon.png differ
diff --git a/node_modules/leaflet-draw/docs/examples/libs/images/marker-shadow.png b/node_modules/leaflet-draw/docs/examples/libs/images/marker-shadow.png
new file mode 100644
index 00000000..9fd29795
Binary files /dev/null and b/node_modules/leaflet-draw/docs/examples/libs/images/marker-shadow.png differ
diff --git a/node_modules/leaflet-draw/docs/examples/libs/leaflet-src.js b/node_modules/leaflet-draw/docs/examples/libs/leaflet-src.js
new file mode 100644
index 00000000..63f6fb79
--- /dev/null
+++ b/node_modules/leaflet-draw/docs/examples/libs/leaflet-src.js
@@ -0,0 +1,13802 @@
+/* @preserve
+ * Leaflet 1.3.1, a JS library for interactive maps. http://leafletjs.com
+ * (c) 2010-2017 Vladimir Agafonkin, (c) 2010-2011 CloudMade
+ */
+
+(function (global, factory) {
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
+ typeof define === 'function' && define.amd ? define(['exports'], factory) :
+ (factory((global.L = {})));
+}(this, (function (exports) { 'use strict';
+
+var version = "1.3.1";
+
+/*
+ * @namespace Util
+ *
+ * Various utility functions, used by Leaflet internally.
+ */
+
+var freeze = Object.freeze;
+Object.freeze = function (obj) { return obj; };
+
+// @function extend(dest: Object, src?: Object): Object
+// Merges the properties of the `src` object (or multiple objects) into `dest` object and returns the latter. Has an `L.extend` shortcut.
+function extend(dest) {
+ var i, j, len, src;
+
+ for (j = 1, len = arguments.length; j < len; j++) {
+ src = arguments[j];
+ for (i in src) {
+ dest[i] = src[i];
+ }
+ }
+ return dest;
+}
+
+// @function create(proto: Object, properties?: Object): Object
+// Compatibility polyfill for [Object.create](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/create)
+var create = Object.create || (function () {
+ function F() {}
+ return function (proto) {
+ F.prototype = proto;
+ return new F();
+ };
+})();
+
+// @function bind(fn: Function, …): Function
+// Returns a new function bound to the arguments passed, like [Function.prototype.bind](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).
+// Has a `L.bind()` shortcut.
+function bind(fn, obj) {
+ var slice = Array.prototype.slice;
+
+ if (fn.bind) {
+ return fn.bind.apply(fn, slice.call(arguments, 1));
+ }
+
+ var args = slice.call(arguments, 2);
+
+ return function () {
+ return fn.apply(obj, args.length ? args.concat(slice.call(arguments)) : arguments);
+ };
+}
+
+// @property lastId: Number
+// Last unique ID used by [`stamp()`](#util-stamp)
+var lastId = 0;
+
+// @function stamp(obj: Object): Number
+// Returns the unique ID of an object, assigning it one if it doesn't have it.
+function stamp(obj) {
+ /*eslint-disable */
+ obj._leaflet_id = obj._leaflet_id || ++lastId;
+ return obj._leaflet_id;
+ /* eslint-enable */
+}
+
+// @function throttle(fn: Function, time: Number, context: Object): Function
+// Returns a function which executes function `fn` with the given scope `context`
+// (so that the `this` keyword refers to `context` inside `fn`'s code). The function
+// `fn` will be called no more than one time per given amount of `time`. The arguments
+// received by the bound function will be any arguments passed when binding the
+// function, followed by any arguments passed when invoking the bound function.
+// Has an `L.throttle` shortcut.
+function throttle(fn, time, context) {
+ var lock, args, wrapperFn, later;
+
+ later = function () {
+ // reset lock and call if queued
+ lock = false;
+ if (args) {
+ wrapperFn.apply(context, args);
+ args = false;
+ }
+ };
+
+ wrapperFn = function () {
+ if (lock) {
+ // called too soon, queue to call later
+ args = arguments;
+
+ } else {
+ // call and lock until later
+ fn.apply(context, arguments);
+ setTimeout(later, time);
+ lock = true;
+ }
+ };
+
+ return wrapperFn;
+}
+
+// @function wrapNum(num: Number, range: Number[], includeMax?: Boolean): Number
+// Returns the number `num` modulo `range` in such a way so it lies within
+// `range[0]` and `range[1]`. The returned value will be always smaller than
+// `range[1]` unless `includeMax` is set to `true`.
+function wrapNum(x, range, includeMax) {
+ var max = range[1],
+ min = range[0],
+ d = max - min;
+ return x === max && includeMax ? x : ((x - min) % d + d) % d + min;
+}
+
+// @function falseFn(): Function
+// Returns a function which always returns `false`.
+function falseFn() { return false; }
+
+// @function formatNum(num: Number, digits?: Number): Number
+// Returns the number `num` rounded to `digits` decimals, or to 6 decimals by default.
+function formatNum(num, digits) {
+ var pow = Math.pow(10, (digits === undefined ? 6 : digits));
+ return Math.round(num * pow) / pow;
+}
+
+// @function trim(str: String): String
+// Compatibility polyfill for [String.prototype.trim](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String/Trim)
+function trim(str) {
+ return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
+}
+
+// @function splitWords(str: String): String[]
+// Trims and splits the string on whitespace and returns the array of parts.
+function splitWords(str) {
+ return trim(str).split(/\s+/);
+}
+
+// @function setOptions(obj: Object, options: Object): Object
+// Merges the given properties to the `options` of the `obj` object, returning the resulting options. See `Class options`. Has an `L.setOptions` shortcut.
+function setOptions(obj, options) {
+ if (!obj.hasOwnProperty('options')) {
+ obj.options = obj.options ? create(obj.options) : {};
+ }
+ for (var i in options) {
+ obj.options[i] = options[i];
+ }
+ return obj.options;
+}
+
+// @function getParamString(obj: Object, existingUrl?: String, uppercase?: Boolean): String
+// Converts an object into a parameter URL string, e.g. `{a: "foo", b: "bar"}`
+// translates to `'?a=foo&b=bar'`. If `existingUrl` is set, the parameters will
+// be appended at the end. If `uppercase` is `true`, the parameter names will
+// be uppercased (e.g. `'?A=foo&B=bar'`)
+function getParamString(obj, existingUrl, uppercase) {
+ var params = [];
+ for (var i in obj) {
+ params.push(encodeURIComponent(uppercase ? i.toUpperCase() : i) + '=' + encodeURIComponent(obj[i]));
+ }
+ return ((!existingUrl || existingUrl.indexOf('?') === -1) ? '?' : '&') + params.join('&');
+}
+
+var templateRe = /\{ *([\w_-]+) *\}/g;
+
+// @function template(str: String, data: Object): String
+// Simple templating facility, accepts a template string of the form `'Hello {a}, {b}'`
+// and a data object like `{a: 'foo', b: 'bar'}`, returns evaluated string
+// `('Hello foo, bar')`. You can also specify functions instead of strings for
+// data values — they will be evaluated passing `data` as an argument.
+function template(str, data) {
+ return str.replace(templateRe, function (str, key) {
+ var value = data[key];
+
+ if (value === undefined) {
+ throw new Error('No value provided for variable ' + str);
+
+ } else if (typeof value === 'function') {
+ value = value(data);
+ }
+ return value;
+ });
+}
+
+// @function isArray(obj): Boolean
+// Compatibility polyfill for [Array.isArray](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray)
+var isArray = Array.isArray || function (obj) {
+ return (Object.prototype.toString.call(obj) === '[object Array]');
+};
+
+// @function indexOf(array: Array, el: Object): Number
+// Compatibility polyfill for [Array.prototype.indexOf](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf)
+function indexOf(array, el) {
+ for (var i = 0; i < array.length; i++) {
+ if (array[i] === el) { return i; }
+ }
+ return -1;
+}
+
+// @property emptyImageUrl: String
+// Data URI string containing a base64-encoded empty GIF image.
+// Used as a hack to free memory from unused images on WebKit-powered
+// mobile devices (by setting image `src` to this string).
+var emptyImageUrl = 'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=';
+
+// inspired by http://paulirish.com/2011/requestanimationframe-for-smart-animating/
+
+function getPrefixed(name) {
+ return window['webkit' + name] || window['moz' + name] || window['ms' + name];
+}
+
+var lastTime = 0;
+
+// fallback for IE 7-8
+function timeoutDefer(fn) {
+ var time = +new Date(),
+ timeToCall = Math.max(0, 16 - (time - lastTime));
+
+ lastTime = time + timeToCall;
+ return window.setTimeout(fn, timeToCall);
+}
+
+var requestFn = window.requestAnimationFrame || getPrefixed('RequestAnimationFrame') || timeoutDefer;
+var cancelFn = window.cancelAnimationFrame || getPrefixed('CancelAnimationFrame') ||
+ getPrefixed('CancelRequestAnimationFrame') || function (id) { window.clearTimeout(id); };
+
+// @function requestAnimFrame(fn: Function, context?: Object, immediate?: Boolean): Number
+// Schedules `fn` to be executed when the browser repaints. `fn` is bound to
+// `context` if given. When `immediate` is set, `fn` is called immediately if
+// the browser doesn't have native support for
+// [`window.requestAnimationFrame`](https://developer.mozilla.org/docs/Web/API/window/requestAnimationFrame),
+// otherwise it's delayed. Returns a request ID that can be used to cancel the request.
+function requestAnimFrame(fn, context, immediate) {
+ if (immediate && requestFn === timeoutDefer) {
+ fn.call(context);
+ } else {
+ return requestFn.call(window, bind(fn, context));
+ }
+}
+
+// @function cancelAnimFrame(id: Number): undefined
+// Cancels a previous `requestAnimFrame`. See also [window.cancelAnimationFrame](https://developer.mozilla.org/docs/Web/API/window/cancelAnimationFrame).
+function cancelAnimFrame(id) {
+ if (id) {
+ cancelFn.call(window, id);
+ }
+}
+
+
+var Util = (Object.freeze || Object)({
+ freeze: freeze,
+ extend: extend,
+ create: create,
+ bind: bind,
+ lastId: lastId,
+ stamp: stamp,
+ throttle: throttle,
+ wrapNum: wrapNum,
+ falseFn: falseFn,
+ formatNum: formatNum,
+ trim: trim,
+ splitWords: splitWords,
+ setOptions: setOptions,
+ getParamString: getParamString,
+ template: template,
+ isArray: isArray,
+ indexOf: indexOf,
+ emptyImageUrl: emptyImageUrl,
+ requestFn: requestFn,
+ cancelFn: cancelFn,
+ requestAnimFrame: requestAnimFrame,
+ cancelAnimFrame: cancelAnimFrame
+});
+
+// @class Class
+// @aka L.Class
+
+// @section
+// @uninheritable
+
+// Thanks to John Resig and Dean Edwards for inspiration!
+
+function Class() {}
+
+Class.extend = function (props) {
+
+ // @function extend(props: Object): Function
+ // [Extends the current class](#class-inheritance) given the properties to be included.
+ // Returns a Javascript function that is a class constructor (to be called with `new`).
+ var NewClass = function () {
+
+ // call the constructor
+ if (this.initialize) {
+ this.initialize.apply(this, arguments);
+ }
+
+ // call all constructor hooks
+ this.callInitHooks();
+ };
+
+ var parentProto = NewClass.__super__ = this.prototype;
+
+ var proto = create(parentProto);
+ proto.constructor = NewClass;
+
+ NewClass.prototype = proto;
+
+ // inherit parent's statics
+ for (var i in this) {
+ if (this.hasOwnProperty(i) && i !== 'prototype' && i !== '__super__') {
+ NewClass[i] = this[i];
+ }
+ }
+
+ // mix static properties into the class
+ if (props.statics) {
+ extend(NewClass, props.statics);
+ delete props.statics;
+ }
+
+ // mix includes into the prototype
+ if (props.includes) {
+ checkDeprecatedMixinEvents(props.includes);
+ extend.apply(null, [proto].concat(props.includes));
+ delete props.includes;
+ }
+
+ // merge options
+ if (proto.options) {
+ props.options = extend(create(proto.options), props.options);
+ }
+
+ // mix given properties into the prototype
+ extend(proto, props);
+
+ proto._initHooks = [];
+
+ // add method for calling all hooks
+ proto.callInitHooks = function () {
+
+ if (this._initHooksCalled) { return; }
+
+ if (parentProto.callInitHooks) {
+ parentProto.callInitHooks.call(this);
+ }
+
+ this._initHooksCalled = true;
+
+ for (var i = 0, len = proto._initHooks.length; i < len; i++) {
+ proto._initHooks[i].call(this);
+ }
+ };
+
+ return NewClass;
+};
+
+
+// @function include(properties: Object): this
+// [Includes a mixin](#class-includes) into the current class.
+Class.include = function (props) {
+ extend(this.prototype, props);
+ return this;
+};
+
+// @function mergeOptions(options: Object): this
+// [Merges `options`](#class-options) into the defaults of the class.
+Class.mergeOptions = function (options) {
+ extend(this.prototype.options, options);
+ return this;
+};
+
+// @function addInitHook(fn: Function): this
+// Adds a [constructor hook](#class-constructor-hooks) to the class.
+Class.addInitHook = function (fn) { // (Function) || (String, args...)
+ var args = Array.prototype.slice.call(arguments, 1);
+
+ var init = typeof fn === 'function' ? fn : function () {
+ this[fn].apply(this, args);
+ };
+
+ this.prototype._initHooks = this.prototype._initHooks || [];
+ this.prototype._initHooks.push(init);
+ return this;
+};
+
+function checkDeprecatedMixinEvents(includes) {
+ if (typeof L === 'undefined' || !L || !L.Mixin) { return; }
+
+ includes = isArray(includes) ? includes : [includes];
+
+ for (var i = 0; i < includes.length; i++) {
+ if (includes[i] === L.Mixin.Events) {
+ console.warn('Deprecated include of L.Mixin.Events: ' +
+ 'this property will be removed in future releases, ' +
+ 'please inherit from L.Evented instead.', new Error().stack);
+ }
+ }
+}
+
+/*
+ * @class Evented
+ * @aka L.Evented
+ * @inherits Class
+ *
+ * A set of methods shared between event-powered classes (like `Map` and `Marker`). Generally, events allow you to execute some function when something happens with an object (e.g. the user clicks on the map, causing the map to fire `'click'` event).
+ *
+ * @example
+ *
+ * ```js
+ * map.on('click', function(e) {
+ * alert(e.latlng);
+ * } );
+ * ```
+ *
+ * Leaflet deals with event listeners by reference, so if you want to add a listener and then remove it, define it as a function:
+ *
+ * ```js
+ * function onClick(e) { ... }
+ *
+ * map.on('click', onClick);
+ * map.off('click', onClick);
+ * ```
+ */
+
+var Events = {
+ /* @method on(type: String, fn: Function, context?: Object): this
+ * Adds a listener function (`fn`) to a particular event type of the object. You can optionally specify the context of the listener (object the this keyword will point to). You can also pass several space-separated types (e.g. `'click dblclick'`).
+ *
+ * @alternative
+ * @method on(eventMap: Object): this
+ * Adds a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}`
+ */
+ on: function (types, fn, context) {
+
+ // types can be a map of types/handlers
+ if (typeof types === 'object') {
+ for (var type in types) {
+ // we don't process space-separated events here for performance;
+ // it's a hot path since Layer uses the on(obj) syntax
+ this._on(type, types[type], fn);
+ }
+
+ } else {
+ // types can be a string of space-separated words
+ types = splitWords(types);
+
+ for (var i = 0, len = types.length; i < len; i++) {
+ this._on(types[i], fn, context);
+ }
+ }
+
+ return this;
+ },
+
+ /* @method off(type: String, fn?: Function, context?: Object): this
+ * Removes a previously added listener function. If no function is specified, it will remove all the listeners of that particular event from the object. Note that if you passed a custom context to `on`, you must pass the same context to `off` in order to remove the listener.
+ *
+ * @alternative
+ * @method off(eventMap: Object): this
+ * Removes a set of type/listener pairs.
+ *
+ * @alternative
+ * @method off: this
+ * Removes all listeners to all events on the object.
+ */
+ off: function (types, fn, context) {
+
+ if (!types) {
+ // clear all listeners if called without arguments
+ delete this._events;
+
+ } else if (typeof types === 'object') {
+ for (var type in types) {
+ this._off(type, types[type], fn);
+ }
+
+ } else {
+ types = splitWords(types);
+
+ for (var i = 0, len = types.length; i < len; i++) {
+ this._off(types[i], fn, context);
+ }
+ }
+
+ return this;
+ },
+
+ // attach listener (without syntactic sugar now)
+ _on: function (type, fn, context) {
+ this._events = this._events || {};
+
+ /* get/init listeners for type */
+ var typeListeners = this._events[type];
+ if (!typeListeners) {
+ typeListeners = [];
+ this._events[type] = typeListeners;
+ }
+
+ if (context === this) {
+ // Less memory footprint.
+ context = undefined;
+ }
+ var newListener = {fn: fn, ctx: context},
+ listeners = typeListeners;
+
+ // check if fn already there
+ for (var i = 0, len = listeners.length; i < len; i++) {
+ if (listeners[i].fn === fn && listeners[i].ctx === context) {
+ return;
+ }
+ }
+
+ listeners.push(newListener);
+ },
+
+ _off: function (type, fn, context) {
+ var listeners,
+ i,
+ len;
+
+ if (!this._events) { return; }
+
+ listeners = this._events[type];
+
+ if (!listeners) {
+ return;
+ }
+
+ if (!fn) {
+ // Set all removed listeners to noop so they are not called if remove happens in fire
+ for (i = 0, len = listeners.length; i < len; i++) {
+ listeners[i].fn = falseFn;
+ }
+ // clear all listeners for a type if function isn't specified
+ delete this._events[type];
+ return;
+ }
+
+ if (context === this) {
+ context = undefined;
+ }
+
+ if (listeners) {
+
+ // find fn and remove it
+ for (i = 0, len = listeners.length; i < len; i++) {
+ var l = listeners[i];
+ if (l.ctx !== context) { continue; }
+ if (l.fn === fn) {
+
+ // set the removed listener to noop so that's not called if remove happens in fire
+ l.fn = falseFn;
+
+ if (this._firingCount) {
+ /* copy array in case events are being fired */
+ this._events[type] = listeners = listeners.slice();
+ }
+ listeners.splice(i, 1);
+
+ return;
+ }
+ }
+ }
+ },
+
+ // @method fire(type: String, data?: Object, propagate?: Boolean): this
+ // Fires an event of the specified type. You can optionally provide an data
+ // object — the first argument of the listener function will contain its
+ // properties. The event can optionally be propagated to event parents.
+ fire: function (type, data, propagate) {
+ if (!this.listens(type, propagate)) { return this; }
+
+ var event = extend({}, data, {
+ type: type,
+ target: this,
+ sourceTarget: data && data.sourceTarget || this
+ });
+
+ if (this._events) {
+ var listeners = this._events[type];
+
+ if (listeners) {
+ this._firingCount = (this._firingCount + 1) || 1;
+ for (var i = 0, len = listeners.length; i < len; i++) {
+ var l = listeners[i];
+ l.fn.call(l.ctx || this, event);
+ }
+
+ this._firingCount--;
+ }
+ }
+
+ if (propagate) {
+ // propagate the event to parents (set with addEventParent)
+ this._propagateEvent(event);
+ }
+
+ return this;
+ },
+
+ // @method listens(type: String): Boolean
+ // Returns `true` if a particular event type has any listeners attached to it.
+ listens: function (type, propagate) {
+ var listeners = this._events && this._events[type];
+ if (listeners && listeners.length) { return true; }
+
+ if (propagate) {
+ // also check parents for listeners if event propagates
+ for (var id in this._eventParents) {
+ if (this._eventParents[id].listens(type, propagate)) { return true; }
+ }
+ }
+ return false;
+ },
+
+ // @method once(…): this
+ // Behaves as [`on(…)`](#evented-on), except the listener will only get fired once and then removed.
+ once: function (types, fn, context) {
+
+ if (typeof types === 'object') {
+ for (var type in types) {
+ this.once(type, types[type], fn);
+ }
+ return this;
+ }
+
+ var handler = bind(function () {
+ this
+ .off(types, fn, context)
+ .off(types, handler, context);
+ }, this);
+
+ // add a listener that's executed once and removed after that
+ return this
+ .on(types, fn, context)
+ .on(types, handler, context);
+ },
+
+ // @method addEventParent(obj: Evented): this
+ // Adds an event parent - an `Evented` that will receive propagated events
+ addEventParent: function (obj) {
+ this._eventParents = this._eventParents || {};
+ this._eventParents[stamp(obj)] = obj;
+ return this;
+ },
+
+ // @method removeEventParent(obj: Evented): this
+ // Removes an event parent, so it will stop receiving propagated events
+ removeEventParent: function (obj) {
+ if (this._eventParents) {
+ delete this._eventParents[stamp(obj)];
+ }
+ return this;
+ },
+
+ _propagateEvent: function (e) {
+ for (var id in this._eventParents) {
+ this._eventParents[id].fire(e.type, extend({
+ layer: e.target,
+ propagatedFrom: e.target
+ }, e), true);
+ }
+ }
+};
+
+// aliases; we should ditch those eventually
+
+// @method addEventListener(…): this
+// Alias to [`on(…)`](#evented-on)
+Events.addEventListener = Events.on;
+
+// @method removeEventListener(…): this
+// Alias to [`off(…)`](#evented-off)
+
+// @method clearAllEventListeners(…): this
+// Alias to [`off()`](#evented-off)
+Events.removeEventListener = Events.clearAllEventListeners = Events.off;
+
+// @method addOneTimeEventListener(…): this
+// Alias to [`once(…)`](#evented-once)
+Events.addOneTimeEventListener = Events.once;
+
+// @method fireEvent(…): this
+// Alias to [`fire(…)`](#evented-fire)
+Events.fireEvent = Events.fire;
+
+// @method hasEventListeners(…): Boolean
+// Alias to [`listens(…)`](#evented-listens)
+Events.hasEventListeners = Events.listens;
+
+var Evented = Class.extend(Events);
+
+/*
+ * @class Point
+ * @aka L.Point
+ *
+ * Represents a point with `x` and `y` coordinates in pixels.
+ *
+ * @example
+ *
+ * ```js
+ * var point = L.point(200, 300);
+ * ```
+ *
+ * All Leaflet methods and options that accept `Point` objects also accept them in a simple Array form (unless noted otherwise), so these lines are equivalent:
+ *
+ * ```js
+ * map.panBy([200, 300]);
+ * map.panBy(L.point(200, 300));
+ * ```
+ *
+ * Note that `Point` does not inherit from Leafet's `Class` object,
+ * which means new classes can't inherit from it, and new methods
+ * can't be added to it with the `include` function.
+ */
+
+function Point(x, y, round) {
+ // @property x: Number; The `x` coordinate of the point
+ this.x = (round ? Math.round(x) : x);
+ // @property y: Number; The `y` coordinate of the point
+ this.y = (round ? Math.round(y) : y);
+}
+
+var trunc = Math.trunc || function (v) {
+ return v > 0 ? Math.floor(v) : Math.ceil(v);
+};
+
+Point.prototype = {
+
+ // @method clone(): Point
+ // Returns a copy of the current point.
+ clone: function () {
+ return new Point(this.x, this.y);
+ },
+
+ // @method add(otherPoint: Point): Point
+ // Returns the result of addition of the current and the given points.
+ add: function (point) {
+ // non-destructive, returns a new point
+ return this.clone()._add(toPoint(point));
+ },
+
+ _add: function (point) {
+ // destructive, used directly for performance in situations where it's safe to modify existing point
+ this.x += point.x;
+ this.y += point.y;
+ return this;
+ },
+
+ // @method subtract(otherPoint: Point): Point
+ // Returns the result of subtraction of the given point from the current.
+ subtract: function (point) {
+ return this.clone()._subtract(toPoint(point));
+ },
+
+ _subtract: function (point) {
+ this.x -= point.x;
+ this.y -= point.y;
+ return this;
+ },
+
+ // @method divideBy(num: Number): Point
+ // Returns the result of division of the current point by the given number.
+ divideBy: function (num) {
+ return this.clone()._divideBy(num);
+ },
+
+ _divideBy: function (num) {
+ this.x /= num;
+ this.y /= num;
+ return this;
+ },
+
+ // @method multiplyBy(num: Number): Point
+ // Returns the result of multiplication of the current point by the given number.
+ multiplyBy: function (num) {
+ return this.clone()._multiplyBy(num);
+ },
+
+ _multiplyBy: function (num) {
+ this.x *= num;
+ this.y *= num;
+ return this;
+ },
+
+ // @method scaleBy(scale: Point): Point
+ // Multiply each coordinate of the current point by each coordinate of
+ // `scale`. In linear algebra terms, multiply the point by the
+ // [scaling matrix](https://en.wikipedia.org/wiki/Scaling_%28geometry%29#Matrix_representation)
+ // defined by `scale`.
+ scaleBy: function (point) {
+ return new Point(this.x * point.x, this.y * point.y);
+ },
+
+ // @method unscaleBy(scale: Point): Point
+ // Inverse of `scaleBy`. Divide each coordinate of the current point by
+ // each coordinate of `scale`.
+ unscaleBy: function (point) {
+ return new Point(this.x / point.x, this.y / point.y);
+ },
+
+ // @method round(): Point
+ // Returns a copy of the current point with rounded coordinates.
+ round: function () {
+ return this.clone()._round();
+ },
+
+ _round: function () {
+ this.x = Math.round(this.x);
+ this.y = Math.round(this.y);
+ return this;
+ },
+
+ // @method floor(): Point
+ // Returns a copy of the current point with floored coordinates (rounded down).
+ floor: function () {
+ return this.clone()._floor();
+ },
+
+ _floor: function () {
+ this.x = Math.floor(this.x);
+ this.y = Math.floor(this.y);
+ return this;
+ },
+
+ // @method ceil(): Point
+ // Returns a copy of the current point with ceiled coordinates (rounded up).
+ ceil: function () {
+ return this.clone()._ceil();
+ },
+
+ _ceil: function () {
+ this.x = Math.ceil(this.x);
+ this.y = Math.ceil(this.y);
+ return this;
+ },
+
+ // @method trunc(): Point
+ // Returns a copy of the current point with truncated coordinates (rounded towards zero).
+ trunc: function () {
+ return this.clone()._trunc();
+ },
+
+ _trunc: function () {
+ this.x = trunc(this.x);
+ this.y = trunc(this.y);
+ return this;
+ },
+
+ // @method distanceTo(otherPoint: Point): Number
+ // Returns the cartesian distance between the current and the given points.
+ distanceTo: function (point) {
+ point = toPoint(point);
+
+ var x = point.x - this.x,
+ y = point.y - this.y;
+
+ return Math.sqrt(x * x + y * y);
+ },
+
+ // @method equals(otherPoint: Point): Boolean
+ // Returns `true` if the given point has the same coordinates.
+ equals: function (point) {
+ point = toPoint(point);
+
+ return point.x === this.x &&
+ point.y === this.y;
+ },
+
+ // @method contains(otherPoint: Point): Boolean
+ // Returns `true` if both coordinates of the given point are less than the corresponding current point coordinates (in absolute values).
+ contains: function (point) {
+ point = toPoint(point);
+
+ return Math.abs(point.x) <= Math.abs(this.x) &&
+ Math.abs(point.y) <= Math.abs(this.y);
+ },
+
+ // @method toString(): String
+ // Returns a string representation of the point for debugging purposes.
+ toString: function () {
+ return 'Point(' +
+ formatNum(this.x) + ', ' +
+ formatNum(this.y) + ')';
+ }
+};
+
+// @factory L.point(x: Number, y: Number, round?: Boolean)
+// Creates a Point object with the given `x` and `y` coordinates. If optional `round` is set to true, rounds the `x` and `y` values.
+
+// @alternative
+// @factory L.point(coords: Number[])
+// Expects an array of the form `[x, y]` instead.
+
+// @alternative
+// @factory L.point(coords: Object)
+// Expects a plain object of the form `{x: Number, y: Number}` instead.
+function toPoint(x, y, round) {
+ if (x instanceof Point) {
+ return x;
+ }
+ if (isArray(x)) {
+ return new Point(x[0], x[1]);
+ }
+ if (x === undefined || x === null) {
+ return x;
+ }
+ if (typeof x === 'object' && 'x' in x && 'y' in x) {
+ return new Point(x.x, x.y);
+ }
+ return new Point(x, y, round);
+}
+
+/*
+ * @class Bounds
+ * @aka L.Bounds
+ *
+ * Represents a rectangular area in pixel coordinates.
+ *
+ * @example
+ *
+ * ```js
+ * var p1 = L.point(10, 10),
+ * p2 = L.point(40, 60),
+ * bounds = L.bounds(p1, p2);
+ * ```
+ *
+ * All Leaflet methods that accept `Bounds` objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:
+ *
+ * ```js
+ * otherBounds.intersects([[10, 10], [40, 60]]);
+ * ```
+ *
+ * Note that `Bounds` does not inherit from Leafet's `Class` object,
+ * which means new classes can't inherit from it, and new methods
+ * can't be added to it with the `include` function.
+ */
+
+function Bounds(a, b) {
+ if (!a) { return; }
+
+ var points = b ? [a, b] : a;
+
+ for (var i = 0, len = points.length; i < len; i++) {
+ this.extend(points[i]);
+ }
+}
+
+Bounds.prototype = {
+ // @method extend(point: Point): this
+ // Extends the bounds to contain the given point.
+ extend: function (point) { // (Point)
+ point = toPoint(point);
+
+ // @property min: Point
+ // The top left corner of the rectangle.
+ // @property max: Point
+ // The bottom right corner of the rectangle.
+ if (!this.min && !this.max) {
+ this.min = point.clone();
+ this.max = point.clone();
+ } else {
+ this.min.x = Math.min(point.x, this.min.x);
+ this.max.x = Math.max(point.x, this.max.x);
+ this.min.y = Math.min(point.y, this.min.y);
+ this.max.y = Math.max(point.y, this.max.y);
+ }
+ return this;
+ },
+
+ // @method getCenter(round?: Boolean): Point
+ // Returns the center point of the bounds.
+ getCenter: function (round) {
+ return new Point(
+ (this.min.x + this.max.x) / 2,
+ (this.min.y + this.max.y) / 2, round);
+ },
+
+ // @method getBottomLeft(): Point
+ // Returns the bottom-left point of the bounds.
+ getBottomLeft: function () {
+ return new Point(this.min.x, this.max.y);
+ },
+
+ // @method getTopRight(): Point
+ // Returns the top-right point of the bounds.
+ getTopRight: function () { // -> Point
+ return new Point(this.max.x, this.min.y);
+ },
+
+ // @method getTopLeft(): Point
+ // Returns the top-left point of the bounds (i.e. [`this.min`](#bounds-min)).
+ getTopLeft: function () {
+ return this.min; // left, top
+ },
+
+ // @method getBottomRight(): Point
+ // Returns the bottom-right point of the bounds (i.e. [`this.max`](#bounds-max)).
+ getBottomRight: function () {
+ return this.max; // right, bottom
+ },
+
+ // @method getSize(): Point
+ // Returns the size of the given bounds
+ getSize: function () {
+ return this.max.subtract(this.min);
+ },
+
+ // @method contains(otherBounds: Bounds): Boolean
+ // Returns `true` if the rectangle contains the given one.
+ // @alternative
+ // @method contains(point: Point): Boolean
+ // Returns `true` if the rectangle contains the given point.
+ contains: function (obj) {
+ var min, max;
+
+ if (typeof obj[0] === 'number' || obj instanceof Point) {
+ obj = toPoint(obj);
+ } else {
+ obj = toBounds(obj);
+ }
+
+ if (obj instanceof Bounds) {
+ min = obj.min;
+ max = obj.max;
+ } else {
+ min = max = obj;
+ }
+
+ return (min.x >= this.min.x) &&
+ (max.x <= this.max.x) &&
+ (min.y >= this.min.y) &&
+ (max.y <= this.max.y);
+ },
+
+ // @method intersects(otherBounds: Bounds): Boolean
+ // Returns `true` if the rectangle intersects the given bounds. Two bounds
+ // intersect if they have at least one point in common.
+ intersects: function (bounds) { // (Bounds) -> Boolean
+ bounds = toBounds(bounds);
+
+ var min = this.min,
+ max = this.max,
+ min2 = bounds.min,
+ max2 = bounds.max,
+ xIntersects = (max2.x >= min.x) && (min2.x <= max.x),
+ yIntersects = (max2.y >= min.y) && (min2.y <= max.y);
+
+ return xIntersects && yIntersects;
+ },
+
+ // @method overlaps(otherBounds: Bounds): Boolean
+ // Returns `true` if the rectangle overlaps the given bounds. Two bounds
+ // overlap if their intersection is an area.
+ overlaps: function (bounds) { // (Bounds) -> Boolean
+ bounds = toBounds(bounds);
+
+ var min = this.min,
+ max = this.max,
+ min2 = bounds.min,
+ max2 = bounds.max,
+ xOverlaps = (max2.x > min.x) && (min2.x < max.x),
+ yOverlaps = (max2.y > min.y) && (min2.y < max.y);
+
+ return xOverlaps && yOverlaps;
+ },
+
+ isValid: function () {
+ return !!(this.min && this.max);
+ }
+};
+
+
+// @factory L.bounds(corner1: Point, corner2: Point)
+// Creates a Bounds object from two corners coordinate pairs.
+// @alternative
+// @factory L.bounds(points: Point[])
+// Creates a Bounds object from the given array of points.
+function toBounds(a, b) {
+ if (!a || a instanceof Bounds) {
+ return a;
+ }
+ return new Bounds(a, b);
+}
+
+/*
+ * @class LatLngBounds
+ * @aka L.LatLngBounds
+ *
+ * Represents a rectangular geographical area on a map.
+ *
+ * @example
+ *
+ * ```js
+ * var corner1 = L.latLng(40.712, -74.227),
+ * corner2 = L.latLng(40.774, -74.125),
+ * bounds = L.latLngBounds(corner1, corner2);
+ * ```
+ *
+ * All Leaflet methods that accept LatLngBounds objects also accept them in a simple Array form (unless noted otherwise), so the bounds example above can be passed like this:
+ *
+ * ```js
+ * map.fitBounds([
+ * [40.712, -74.227],
+ * [40.774, -74.125]
+ * ]);
+ * ```
+ *
+ * Caution: if the area crosses the antimeridian (often confused with the International Date Line), you must specify corners _outside_ the [-180, 180] degrees longitude range.
+ *
+ * Note that `LatLngBounds` does not inherit from Leafet's `Class` object,
+ * which means new classes can't inherit from it, and new methods
+ * can't be added to it with the `include` function.
+ */
+
+function LatLngBounds(corner1, corner2) { // (LatLng, LatLng) or (LatLng[])
+ if (!corner1) { return; }
+
+ var latlngs = corner2 ? [corner1, corner2] : corner1;
+
+ for (var i = 0, len = latlngs.length; i < len; i++) {
+ this.extend(latlngs[i]);
+ }
+}
+
+LatLngBounds.prototype = {
+
+ // @method extend(latlng: LatLng): this
+ // Extend the bounds to contain the given point
+
+ // @alternative
+ // @method extend(otherBounds: LatLngBounds): this
+ // Extend the bounds to contain the given bounds
+ extend: function (obj) {
+ var sw = this._southWest,
+ ne = this._northEast,
+ sw2, ne2;
+
+ if (obj instanceof LatLng) {
+ sw2 = obj;
+ ne2 = obj;
+
+ } else if (obj instanceof LatLngBounds) {
+ sw2 = obj._southWest;
+ ne2 = obj._northEast;
+
+ if (!sw2 || !ne2) { return this; }
+
+ } else {
+ return obj ? this.extend(toLatLng(obj) || toLatLngBounds(obj)) : this;
+ }
+
+ if (!sw && !ne) {
+ this._southWest = new LatLng(sw2.lat, sw2.lng);
+ this._northEast = new LatLng(ne2.lat, ne2.lng);
+ } else {
+ sw.lat = Math.min(sw2.lat, sw.lat);
+ sw.lng = Math.min(sw2.lng, sw.lng);
+ ne.lat = Math.max(ne2.lat, ne.lat);
+ ne.lng = Math.max(ne2.lng, ne.lng);
+ }
+
+ return this;
+ },
+
+ // @method pad(bufferRatio: Number): LatLngBounds
+ // Returns bounds created by extending or retracting the current bounds by a given ratio in each direction.
+ // For example, a ratio of 0.5 extends the bounds by 50% in each direction.
+ // Negative values will retract the bounds.
+ pad: function (bufferRatio) {
+ var sw = this._southWest,
+ ne = this._northEast,
+ heightBuffer = Math.abs(sw.lat - ne.lat) * bufferRatio,
+ widthBuffer = Math.abs(sw.lng - ne.lng) * bufferRatio;
+
+ return new LatLngBounds(
+ new LatLng(sw.lat - heightBuffer, sw.lng - widthBuffer),
+ new LatLng(ne.lat + heightBuffer, ne.lng + widthBuffer));
+ },
+
+ // @method getCenter(): LatLng
+ // Returns the center point of the bounds.
+ getCenter: function () {
+ return new LatLng(
+ (this._southWest.lat + this._northEast.lat) / 2,
+ (this._southWest.lng + this._northEast.lng) / 2);
+ },
+
+ // @method getSouthWest(): LatLng
+ // Returns the south-west point of the bounds.
+ getSouthWest: function () {
+ return this._southWest;
+ },
+
+ // @method getNorthEast(): LatLng
+ // Returns the north-east point of the bounds.
+ getNorthEast: function () {
+ return this._northEast;
+ },
+
+ // @method getNorthWest(): LatLng
+ // Returns the north-west point of the bounds.
+ getNorthWest: function () {
+ return new LatLng(this.getNorth(), this.getWest());
+ },
+
+ // @method getSouthEast(): LatLng
+ // Returns the south-east point of the bounds.
+ getSouthEast: function () {
+ return new LatLng(this.getSouth(), this.getEast());
+ },
+
+ // @method getWest(): Number
+ // Returns the west longitude of the bounds
+ getWest: function () {
+ return this._southWest.lng;
+ },
+
+ // @method getSouth(): Number
+ // Returns the south latitude of the bounds
+ getSouth: function () {
+ return this._southWest.lat;
+ },
+
+ // @method getEast(): Number
+ // Returns the east longitude of the bounds
+ getEast: function () {
+ return this._northEast.lng;
+ },
+
+ // @method getNorth(): Number
+ // Returns the north latitude of the bounds
+ getNorth: function () {
+ return this._northEast.lat;
+ },
+
+ // @method contains(otherBounds: LatLngBounds): Boolean
+ // Returns `true` if the rectangle contains the given one.
+
+ // @alternative
+ // @method contains (latlng: LatLng): Boolean
+ // Returns `true` if the rectangle contains the given point.
+ contains: function (obj) { // (LatLngBounds) or (LatLng) -> Boolean
+ if (typeof obj[0] === 'number' || obj instanceof LatLng || 'lat' in obj) {
+ obj = toLatLng(obj);
+ } else {
+ obj = toLatLngBounds(obj);
+ }
+
+ var sw = this._southWest,
+ ne = this._northEast,
+ sw2, ne2;
+
+ if (obj instanceof LatLngBounds) {
+ sw2 = obj.getSouthWest();
+ ne2 = obj.getNorthEast();
+ } else {
+ sw2 = ne2 = obj;
+ }
+
+ return (sw2.lat >= sw.lat) && (ne2.lat <= ne.lat) &&
+ (sw2.lng >= sw.lng) && (ne2.lng <= ne.lng);
+ },
+
+ // @method intersects(otherBounds: LatLngBounds): Boolean
+ // Returns `true` if the rectangle intersects the given bounds. Two bounds intersect if they have at least one point in common.
+ intersects: function (bounds) {
+ bounds = toLatLngBounds(bounds);
+
+ var sw = this._southWest,
+ ne = this._northEast,
+ sw2 = bounds.getSouthWest(),
+ ne2 = bounds.getNorthEast(),
+
+ latIntersects = (ne2.lat >= sw.lat) && (sw2.lat <= ne.lat),
+ lngIntersects = (ne2.lng >= sw.lng) && (sw2.lng <= ne.lng);
+
+ return latIntersects && lngIntersects;
+ },
+
+ // @method overlaps(otherBounds: Bounds): Boolean
+ // Returns `true` if the rectangle overlaps the given bounds. Two bounds overlap if their intersection is an area.
+ overlaps: function (bounds) {
+ bounds = toLatLngBounds(bounds);
+
+ var sw = this._southWest,
+ ne = this._northEast,
+ sw2 = bounds.getSouthWest(),
+ ne2 = bounds.getNorthEast(),
+
+ latOverlaps = (ne2.lat > sw.lat) && (sw2.lat < ne.lat),
+ lngOverlaps = (ne2.lng > sw.lng) && (sw2.lng < ne.lng);
+
+ return latOverlaps && lngOverlaps;
+ },
+
+ // @method toBBoxString(): String
+ // Returns a string with bounding box coordinates in a 'southwest_lng,southwest_lat,northeast_lng,northeast_lat' format. Useful for sending requests to web services that return geo data.
+ toBBoxString: function () {
+ return [this.getWest(), this.getSouth(), this.getEast(), this.getNorth()].join(',');
+ },
+
+ // @method equals(otherBounds: LatLngBounds, maxMargin?: Number): Boolean
+ // Returns `true` if the rectangle is equivalent (within a small margin of error) to the given bounds. The margin of error can be overridden by setting `maxMargin` to a small number.
+ equals: function (bounds, maxMargin) {
+ if (!bounds) { return false; }
+
+ bounds = toLatLngBounds(bounds);
+
+ return this._southWest.equals(bounds.getSouthWest(), maxMargin) &&
+ this._northEast.equals(bounds.getNorthEast(), maxMargin);
+ },
+
+ // @method isValid(): Boolean
+ // Returns `true` if the bounds are properly initialized.
+ isValid: function () {
+ return !!(this._southWest && this._northEast);
+ }
+};
+
+// TODO International date line?
+
+// @factory L.latLngBounds(corner1: LatLng, corner2: LatLng)
+// Creates a `LatLngBounds` object by defining two diagonally opposite corners of the rectangle.
+
+// @alternative
+// @factory L.latLngBounds(latlngs: LatLng[])
+// Creates a `LatLngBounds` object defined by the geographical points it contains. Very useful for zooming the map to fit a particular set of locations with [`fitBounds`](#map-fitbounds).
+function toLatLngBounds(a, b) {
+ if (a instanceof LatLngBounds) {
+ return a;
+ }
+ return new LatLngBounds(a, b);
+}
+
+/* @class LatLng
+ * @aka L.LatLng
+ *
+ * Represents a geographical point with a certain latitude and longitude.
+ *
+ * @example
+ *
+ * ```
+ * var latlng = L.latLng(50.5, 30.5);
+ * ```
+ *
+ * All Leaflet methods that accept LatLng objects also accept them in a simple Array form and simple object form (unless noted otherwise), so these lines are equivalent:
+ *
+ * ```
+ * map.panTo([50, 30]);
+ * map.panTo({lon: 30, lat: 50});
+ * map.panTo({lat: 50, lng: 30});
+ * map.panTo(L.latLng(50, 30));
+ * ```
+ *
+ * Note that `LatLng` does not inherit from Leafet's `Class` object,
+ * which means new classes can't inherit from it, and new methods
+ * can't be added to it with the `include` function.
+ */
+
+function LatLng(lat, lng, alt) {
+ if (isNaN(lat) || isNaN(lng)) {
+ throw new Error('Invalid LatLng object: (' + lat + ', ' + lng + ')');
+ }
+
+ // @property lat: Number
+ // Latitude in degrees
+ this.lat = +lat;
+
+ // @property lng: Number
+ // Longitude in degrees
+ this.lng = +lng;
+
+ // @property alt: Number
+ // Altitude in meters (optional)
+ if (alt !== undefined) {
+ this.alt = +alt;
+ }
+}
+
+LatLng.prototype = {
+ // @method equals(otherLatLng: LatLng, maxMargin?: Number): Boolean
+ // Returns `true` if the given `LatLng` point is at the same position (within a small margin of error). The margin of error can be overridden by setting `maxMargin` to a small number.
+ equals: function (obj, maxMargin) {
+ if (!obj) { return false; }
+
+ obj = toLatLng(obj);
+
+ var margin = Math.max(
+ Math.abs(this.lat - obj.lat),
+ Math.abs(this.lng - obj.lng));
+
+ return margin <= (maxMargin === undefined ? 1.0E-9 : maxMargin);
+ },
+
+ // @method toString(): String
+ // Returns a string representation of the point (for debugging purposes).
+ toString: function (precision) {
+ return 'LatLng(' +
+ formatNum(this.lat, precision) + ', ' +
+ formatNum(this.lng, precision) + ')';
+ },
+
+ // @method distanceTo(otherLatLng: LatLng): Number
+ // Returns the distance (in meters) to the given `LatLng` calculated using the [Spherical Law of Cosines](https://en.wikipedia.org/wiki/Spherical_law_of_cosines).
+ distanceTo: function (other) {
+ return Earth.distance(this, toLatLng(other));
+ },
+
+ // @method wrap(): LatLng
+ // Returns a new `LatLng` object with the longitude wrapped so it's always between -180 and +180 degrees.
+ wrap: function () {
+ return Earth.wrapLatLng(this);
+ },
+
+ // @method toBounds(sizeInMeters: Number): LatLngBounds
+ // Returns a new `LatLngBounds` object in which each boundary is `sizeInMeters/2` meters apart from the `LatLng`.
+ toBounds: function (sizeInMeters) {
+ var latAccuracy = 180 * sizeInMeters / 40075017,
+ lngAccuracy = latAccuracy / Math.cos((Math.PI / 180) * this.lat);
+
+ return toLatLngBounds(
+ [this.lat - latAccuracy, this.lng - lngAccuracy],
+ [this.lat + latAccuracy, this.lng + lngAccuracy]);
+ },
+
+ clone: function () {
+ return new LatLng(this.lat, this.lng, this.alt);
+ }
+};
+
+
+
+// @factory L.latLng(latitude: Number, longitude: Number, altitude?: Number): LatLng
+// Creates an object representing a geographical point with the given latitude and longitude (and optionally altitude).
+
+// @alternative
+// @factory L.latLng(coords: Array): LatLng
+// Expects an array of the form `[Number, Number]` or `[Number, Number, Number]` instead.
+
+// @alternative
+// @factory L.latLng(coords: Object): LatLng
+// Expects an plain object of the form `{lat: Number, lng: Number}` or `{lat: Number, lng: Number, alt: Number}` instead.
+
+function toLatLng(a, b, c) {
+ if (a instanceof LatLng) {
+ return a;
+ }
+ if (isArray(a) && typeof a[0] !== 'object') {
+ if (a.length === 3) {
+ return new LatLng(a[0], a[1], a[2]);
+ }
+ if (a.length === 2) {
+ return new LatLng(a[0], a[1]);
+ }
+ return null;
+ }
+ if (a === undefined || a === null) {
+ return a;
+ }
+ if (typeof a === 'object' && 'lat' in a) {
+ return new LatLng(a.lat, 'lng' in a ? a.lng : a.lon, a.alt);
+ }
+ if (b === undefined) {
+ return null;
+ }
+ return new LatLng(a, b, c);
+}
+
+/*
+ * @namespace CRS
+ * @crs L.CRS.Base
+ * Object that defines coordinate reference systems for projecting
+ * geographical points into pixel (screen) coordinates and back (and to
+ * coordinates in other units for [WMS](https://en.wikipedia.org/wiki/Web_Map_Service) services). See
+ * [spatial reference system](http://en.wikipedia.org/wiki/Coordinate_reference_system).
+ *
+ * Leaflet defines the most usual CRSs by default. If you want to use a
+ * CRS not defined by default, take a look at the
+ * [Proj4Leaflet](https://github.com/kartena/Proj4Leaflet) plugin.
+ *
+ * Note that the CRS instances do not inherit from Leafet's `Class` object,
+ * and can't be instantiated. Also, new classes can't inherit from them,
+ * and methods can't be added to them with the `include` function.
+ */
+
+var CRS = {
+ // @method latLngToPoint(latlng: LatLng, zoom: Number): Point
+ // Projects geographical coordinates into pixel coordinates for a given zoom.
+ latLngToPoint: function (latlng, zoom) {
+ var projectedPoint = this.projection.project(latlng),
+ scale = this.scale(zoom);
+
+ return this.transformation._transform(projectedPoint, scale);
+ },
+
+ // @method pointToLatLng(point: Point, zoom: Number): LatLng
+ // The inverse of `latLngToPoint`. Projects pixel coordinates on a given
+ // zoom into geographical coordinates.
+ pointToLatLng: function (point, zoom) {
+ var scale = this.scale(zoom),
+ untransformedPoint = this.transformation.untransform(point, scale);
+
+ return this.projection.unproject(untransformedPoint);
+ },
+
+ // @method project(latlng: LatLng): Point
+ // Projects geographical coordinates into coordinates in units accepted for
+ // this CRS (e.g. meters for EPSG:3857, for passing it to WMS services).
+ project: function (latlng) {
+ return this.projection.project(latlng);
+ },
+
+ // @method unproject(point: Point): LatLng
+ // Given a projected coordinate returns the corresponding LatLng.
+ // The inverse of `project`.
+ unproject: function (point) {
+ return this.projection.unproject(point);
+ },
+
+ // @method scale(zoom: Number): Number
+ // Returns the scale used when transforming projected coordinates into
+ // pixel coordinates for a particular zoom. For example, it returns
+ // `256 * 2^zoom` for Mercator-based CRS.
+ scale: function (zoom) {
+ return 256 * Math.pow(2, zoom);
+ },
+
+ // @method zoom(scale: Number): Number
+ // Inverse of `scale()`, returns the zoom level corresponding to a scale
+ // factor of `scale`.
+ zoom: function (scale) {
+ return Math.log(scale / 256) / Math.LN2;
+ },
+
+ // @method getProjectedBounds(zoom: Number): Bounds
+ // Returns the projection's bounds scaled and transformed for the provided `zoom`.
+ getProjectedBounds: function (zoom) {
+ if (this.infinite) { return null; }
+
+ var b = this.projection.bounds,
+ s = this.scale(zoom),
+ min = this.transformation.transform(b.min, s),
+ max = this.transformation.transform(b.max, s);
+
+ return new Bounds(min, max);
+ },
+
+ // @method distance(latlng1: LatLng, latlng2: LatLng): Number
+ // Returns the distance between two geographical coordinates.
+
+ // @property code: String
+ // Standard code name of the CRS passed into WMS services (e.g. `'EPSG:3857'`)
+ //
+ // @property wrapLng: Number[]
+ // An array of two numbers defining whether the longitude (horizontal) coordinate
+ // axis wraps around a given range and how. Defaults to `[-180, 180]` in most
+ // geographical CRSs. If `undefined`, the longitude axis does not wrap around.
+ //
+ // @property wrapLat: Number[]
+ // Like `wrapLng`, but for the latitude (vertical) axis.
+
+ // wrapLng: [min, max],
+ // wrapLat: [min, max],
+
+ // @property infinite: Boolean
+ // If true, the coordinate space will be unbounded (infinite in both axes)
+ infinite: false,
+
+ // @method wrapLatLng(latlng: LatLng): LatLng
+ // Returns a `LatLng` where lat and lng has been wrapped according to the
+ // CRS's `wrapLat` and `wrapLng` properties, if they are outside the CRS's bounds.
+ wrapLatLng: function (latlng) {
+ var lng = this.wrapLng ? wrapNum(latlng.lng, this.wrapLng, true) : latlng.lng,
+ lat = this.wrapLat ? wrapNum(latlng.lat, this.wrapLat, true) : latlng.lat,
+ alt = latlng.alt;
+
+ return new LatLng(lat, lng, alt);
+ },
+
+ // @method wrapLatLngBounds(bounds: LatLngBounds): LatLngBounds
+ // Returns a `LatLngBounds` with the same size as the given one, ensuring
+ // that its center is within the CRS's bounds.
+ // Only accepts actual `L.LatLngBounds` instances, not arrays.
+ wrapLatLngBounds: function (bounds) {
+ var center = bounds.getCenter(),
+ newCenter = this.wrapLatLng(center),
+ latShift = center.lat - newCenter.lat,
+ lngShift = center.lng - newCenter.lng;
+
+ if (latShift === 0 && lngShift === 0) {
+ return bounds;
+ }
+
+ var sw = bounds.getSouthWest(),
+ ne = bounds.getNorthEast(),
+ newSw = new LatLng(sw.lat - latShift, sw.lng - lngShift),
+ newNe = new LatLng(ne.lat - latShift, ne.lng - lngShift);
+
+ return new LatLngBounds(newSw, newNe);
+ }
+};
+
+/*
+ * @namespace CRS
+ * @crs L.CRS.Earth
+ *
+ * Serves as the base for CRS that are global such that they cover the earth.
+ * Can only be used as the base for other CRS and cannot be used directly,
+ * since it does not have a `code`, `projection` or `transformation`. `distance()` returns
+ * meters.
+ */
+
+var Earth = extend({}, CRS, {
+ wrapLng: [-180, 180],
+
+ // Mean Earth Radius, as recommended for use by
+ // the International Union of Geodesy and Geophysics,
+ // see http://rosettacode.org/wiki/Haversine_formula
+ R: 6371000,
+
+ // distance between two geographical points using spherical law of cosines approximation
+ distance: function (latlng1, latlng2) {
+ var rad = Math.PI / 180,
+ lat1 = latlng1.lat * rad,
+ lat2 = latlng2.lat * rad,
+ sinDLat = Math.sin((latlng2.lat - latlng1.lat) * rad / 2),
+ sinDLon = Math.sin((latlng2.lng - latlng1.lng) * rad / 2),
+ a = sinDLat * sinDLat + Math.cos(lat1) * Math.cos(lat2) * sinDLon * sinDLon,
+ c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
+ return this.R * c;
+ }
+});
+
+/*
+ * @namespace Projection
+ * @projection L.Projection.SphericalMercator
+ *
+ * Spherical Mercator projection — the most common projection for online maps,
+ * used by almost all free and commercial tile providers. Assumes that Earth is
+ * a sphere. Used by the `EPSG:3857` CRS.
+ */
+
+var SphericalMercator = {
+
+ R: 6378137,
+ MAX_LATITUDE: 85.0511287798,
+
+ project: function (latlng) {
+ var d = Math.PI / 180,
+ max = this.MAX_LATITUDE,
+ lat = Math.max(Math.min(max, latlng.lat), -max),
+ sin = Math.sin(lat * d);
+
+ return new Point(
+ this.R * latlng.lng * d,
+ this.R * Math.log((1 + sin) / (1 - sin)) / 2);
+ },
+
+ unproject: function (point) {
+ var d = 180 / Math.PI;
+
+ return new LatLng(
+ (2 * Math.atan(Math.exp(point.y / this.R)) - (Math.PI / 2)) * d,
+ point.x * d / this.R);
+ },
+
+ bounds: (function () {
+ var d = 6378137 * Math.PI;
+ return new Bounds([-d, -d], [d, d]);
+ })()
+};
+
+/*
+ * @class Transformation
+ * @aka L.Transformation
+ *
+ * Represents an affine transformation: a set of coefficients `a`, `b`, `c`, `d`
+ * for transforming a point of a form `(x, y)` into `(a*x + b, c*y + d)` and doing
+ * the reverse. Used by Leaflet in its projections code.
+ *
+ * @example
+ *
+ * ```js
+ * var transformation = L.transformation(2, 5, -1, 10),
+ * p = L.point(1, 2),
+ * p2 = transformation.transform(p), // L.point(7, 8)
+ * p3 = transformation.untransform(p2); // L.point(1, 2)
+ * ```
+ */
+
+
+// factory new L.Transformation(a: Number, b: Number, c: Number, d: Number)
+// Creates a `Transformation` object with the given coefficients.
+function Transformation(a, b, c, d) {
+ if (isArray(a)) {
+ // use array properties
+ this._a = a[0];
+ this._b = a[1];
+ this._c = a[2];
+ this._d = a[3];
+ return;
+ }
+ this._a = a;
+ this._b = b;
+ this._c = c;
+ this._d = d;
+}
+
+Transformation.prototype = {
+ // @method transform(point: Point, scale?: Number): Point
+ // Returns a transformed point, optionally multiplied by the given scale.
+ // Only accepts actual `L.Point` instances, not arrays.
+ transform: function (point, scale) { // (Point, Number) -> Point
+ return this._transform(point.clone(), scale);
+ },
+
+ // destructive transform (faster)
+ _transform: function (point, scale) {
+ scale = scale || 1;
+ point.x = scale * (this._a * point.x + this._b);
+ point.y = scale * (this._c * point.y + this._d);
+ return point;
+ },
+
+ // @method untransform(point: Point, scale?: Number): Point
+ // Returns the reverse transformation of the given point, optionally divided
+ // by the given scale. Only accepts actual `L.Point` instances, not arrays.
+ untransform: function (point, scale) {
+ scale = scale || 1;
+ return new Point(
+ (point.x / scale - this._b) / this._a,
+ (point.y / scale - this._d) / this._c);
+ }
+};
+
+// factory L.transformation(a: Number, b: Number, c: Number, d: Number)
+
+// @factory L.transformation(a: Number, b: Number, c: Number, d: Number)
+// Instantiates a Transformation object with the given coefficients.
+
+// @alternative
+// @factory L.transformation(coefficients: Array): Transformation
+// Expects an coefficients array of the form
+// `[a: Number, b: Number, c: Number, d: Number]`.
+
+function toTransformation(a, b, c, d) {
+ return new Transformation(a, b, c, d);
+}
+
+/*
+ * @namespace CRS
+ * @crs L.CRS.EPSG3857
+ *
+ * The most common CRS for online maps, used by almost all free and commercial
+ * tile providers. Uses Spherical Mercator projection. Set in by default in
+ * Map's `crs` option.
+ */
+
+var EPSG3857 = extend({}, Earth, {
+ code: 'EPSG:3857',
+ projection: SphericalMercator,
+
+ transformation: (function () {
+ var scale = 0.5 / (Math.PI * SphericalMercator.R);
+ return toTransformation(scale, 0.5, -scale, 0.5);
+ }())
+});
+
+var EPSG900913 = extend({}, EPSG3857, {
+ code: 'EPSG:900913'
+});
+
+// @namespace SVG; @section
+// There are several static functions which can be called without instantiating L.SVG:
+
+// @function create(name: String): SVGElement
+// Returns a instance of [SVGElement](https://developer.mozilla.org/docs/Web/API/SVGElement),
+// corresponding to the class name passed. For example, using 'line' will return
+// an instance of [SVGLineElement](https://developer.mozilla.org/docs/Web/API/SVGLineElement).
+function svgCreate(name) {
+ return document.createElementNS('http://www.w3.org/2000/svg', name);
+}
+
+// @function pointsToPath(rings: Point[], closed: Boolean): String
+// Generates a SVG path string for multiple rings, with each ring turning
+// into "M..L..L.." instructions
+function pointsToPath(rings, closed) {
+ var str = '',
+ i, j, len, len2, points, p;
+
+ for (i = 0, len = rings.length; i < len; i++) {
+ points = rings[i];
+
+ for (j = 0, len2 = points.length; j < len2; j++) {
+ p = points[j];
+ str += (j ? 'L' : 'M') + p.x + ' ' + p.y;
+ }
+
+ // closes the ring for polygons; "x" is VML syntax
+ str += closed ? (svg ? 'z' : 'x') : '';
+ }
+
+ // SVG complains about empty path strings
+ return str || 'M0 0';
+}
+
+/*
+ * @namespace Browser
+ * @aka L.Browser
+ *
+ * A namespace with static properties for browser/feature detection used by Leaflet internally.
+ *
+ * @example
+ *
+ * ```js
+ * if (L.Browser.ielt9) {
+ * alert('Upgrade your browser, dude!');
+ * }
+ * ```
+ */
+
+var style$1 = document.documentElement.style;
+
+// @property ie: Boolean; `true` for all Internet Explorer versions (not Edge).
+var ie = 'ActiveXObject' in window;
+
+// @property ielt9: Boolean; `true` for Internet Explorer versions less than 9.
+var ielt9 = ie && !document.addEventListener;
+
+// @property edge: Boolean; `true` for the Edge web browser.
+var edge = 'msLaunchUri' in navigator && !('documentMode' in document);
+
+// @property webkit: Boolean;
+// `true` for webkit-based browsers like Chrome and Safari (including mobile versions).
+var webkit = userAgentContains('webkit');
+
+// @property android: Boolean
+// `true` for any browser running on an Android platform.
+var android = userAgentContains('android');
+
+// @property android23: Boolean; `true` for browsers running on Android 2 or Android 3.
+var android23 = userAgentContains('android 2') || userAgentContains('android 3');
+
+/* See https://stackoverflow.com/a/17961266 for details on detecting stock Android */
+var webkitVer = parseInt(/WebKit\/([0-9]+)|$/.exec(navigator.userAgent)[1], 10); // also matches AppleWebKit
+// @property androidStock: Boolean; `true` for the Android stock browser (i.e. not Chrome)
+var androidStock = android && userAgentContains('Google') && webkitVer < 537 && !('AudioNode' in window);
+
+// @property opera: Boolean; `true` for the Opera browser
+var opera = !!window.opera;
+
+// @property chrome: Boolean; `true` for the Chrome browser.
+var chrome = userAgentContains('chrome');
+
+// @property gecko: Boolean; `true` for gecko-based browsers like Firefox.
+var gecko = userAgentContains('gecko') && !webkit && !opera && !ie;
+
+// @property safari: Boolean; `true` for the Safari browser.
+var safari = !chrome && userAgentContains('safari');
+
+var phantom = userAgentContains('phantom');
+
+// @property opera12: Boolean
+// `true` for the Opera browser supporting CSS transforms (version 12 or later).
+var opera12 = 'OTransition' in style$1;
+
+// @property win: Boolean; `true` when the browser is running in a Windows platform
+var win = navigator.platform.indexOf('Win') === 0;
+
+// @property ie3d: Boolean; `true` for all Internet Explorer versions supporting CSS transforms.
+var ie3d = ie && ('transition' in style$1);
+
+// @property webkit3d: Boolean; `true` for webkit-based browsers supporting CSS transforms.
+var webkit3d = ('WebKitCSSMatrix' in window) && ('m11' in new window.WebKitCSSMatrix()) && !android23;
+
+// @property gecko3d: Boolean; `true` for gecko-based browsers supporting CSS transforms.
+var gecko3d = 'MozPerspective' in style$1;
+
+// @property any3d: Boolean
+// `true` for all browsers supporting CSS transforms.
+var any3d = !window.L_DISABLE_3D && (ie3d || webkit3d || gecko3d) && !opera12 && !phantom;
+
+// @property mobile: Boolean; `true` for all browsers running in a mobile device.
+var mobile = typeof orientation !== 'undefined' || userAgentContains('mobile');
+
+// @property mobileWebkit: Boolean; `true` for all webkit-based browsers in a mobile device.
+var mobileWebkit = mobile && webkit;
+
+// @property mobileWebkit3d: Boolean
+// `true` for all webkit-based browsers in a mobile device supporting CSS transforms.
+var mobileWebkit3d = mobile && webkit3d;
+
+// @property msPointer: Boolean
+// `true` for browsers implementing the Microsoft touch events model (notably IE10).
+var msPointer = !window.PointerEvent && window.MSPointerEvent;
+
+// @property pointer: Boolean
+// `true` for all browsers supporting [pointer events](https://msdn.microsoft.com/en-us/library/dn433244%28v=vs.85%29.aspx).
+var pointer = !!(window.PointerEvent || msPointer);
+
+// @property touch: Boolean
+// `true` for all browsers supporting [touch events](https://developer.mozilla.org/docs/Web/API/Touch_events).
+// This does not necessarily mean that the browser is running in a computer with
+// a touchscreen, it only means that the browser is capable of understanding
+// touch events.
+var touch = !window.L_NO_TOUCH && (pointer || 'ontouchstart' in window ||
+ (window.DocumentTouch && document instanceof window.DocumentTouch));
+
+// @property mobileOpera: Boolean; `true` for the Opera browser in a mobile device.
+var mobileOpera = mobile && opera;
+
+// @property mobileGecko: Boolean
+// `true` for gecko-based browsers running in a mobile device.
+var mobileGecko = mobile && gecko;
+
+// @property retina: Boolean
+// `true` for browsers on a high-resolution "retina" screen.
+var retina = (window.devicePixelRatio || (window.screen.deviceXDPI / window.screen.logicalXDPI)) > 1;
+
+
+// @property canvas: Boolean
+// `true` when the browser supports [``](https://developer.mozilla.org/docs/Web/API/Canvas_API).
+var canvas = (function () {
+ return !!document.createElement('canvas').getContext;
+}());
+
+// @property svg: Boolean
+// `true` when the browser supports [SVG](https://developer.mozilla.org/docs/Web/SVG).
+var svg = !!(document.createElementNS && svgCreate('svg').createSVGRect);
+
+// @property vml: Boolean
+// `true` if the browser supports [VML](https://en.wikipedia.org/wiki/Vector_Markup_Language).
+var vml = !svg && (function () {
+ try {
+ var div = document.createElement('div');
+ div.innerHTML = ' ';
+
+ var shape = div.firstChild;
+ shape.style.behavior = 'url(#default#VML)';
+
+ return shape && (typeof shape.adj === 'object');
+
+ } catch (e) {
+ return false;
+ }
+}());
+
+
+function userAgentContains(str) {
+ return navigator.userAgent.toLowerCase().indexOf(str) >= 0;
+}
+
+
+var Browser = (Object.freeze || Object)({
+ ie: ie,
+ ielt9: ielt9,
+ edge: edge,
+ webkit: webkit,
+ android: android,
+ android23: android23,
+ androidStock: androidStock,
+ opera: opera,
+ chrome: chrome,
+ gecko: gecko,
+ safari: safari,
+ phantom: phantom,
+ opera12: opera12,
+ win: win,
+ ie3d: ie3d,
+ webkit3d: webkit3d,
+ gecko3d: gecko3d,
+ any3d: any3d,
+ mobile: mobile,
+ mobileWebkit: mobileWebkit,
+ mobileWebkit3d: mobileWebkit3d,
+ msPointer: msPointer,
+ pointer: pointer,
+ touch: touch,
+ mobileOpera: mobileOpera,
+ mobileGecko: mobileGecko,
+ retina: retina,
+ canvas: canvas,
+ svg: svg,
+ vml: vml
+});
+
+/*
+ * Extends L.DomEvent to provide touch support for Internet Explorer and Windows-based devices.
+ */
+
+
+var POINTER_DOWN = msPointer ? 'MSPointerDown' : 'pointerdown';
+var POINTER_MOVE = msPointer ? 'MSPointerMove' : 'pointermove';
+var POINTER_UP = msPointer ? 'MSPointerUp' : 'pointerup';
+var POINTER_CANCEL = msPointer ? 'MSPointerCancel' : 'pointercancel';
+var TAG_WHITE_LIST = ['INPUT', 'SELECT', 'OPTION'];
+
+var _pointers = {};
+var _pointerDocListener = false;
+
+// DomEvent.DoubleTap needs to know about this
+var _pointersCount = 0;
+
+// Provides a touch events wrapper for (ms)pointer events.
+// ref http://www.w3.org/TR/pointerevents/ https://www.w3.org/Bugs/Public/show_bug.cgi?id=22890
+
+function addPointerListener(obj, type, handler, id) {
+ if (type === 'touchstart') {
+ _addPointerStart(obj, handler, id);
+
+ } else if (type === 'touchmove') {
+ _addPointerMove(obj, handler, id);
+
+ } else if (type === 'touchend') {
+ _addPointerEnd(obj, handler, id);
+ }
+
+ return this;
+}
+
+function removePointerListener(obj, type, id) {
+ var handler = obj['_leaflet_' + type + id];
+
+ if (type === 'touchstart') {
+ obj.removeEventListener(POINTER_DOWN, handler, false);
+
+ } else if (type === 'touchmove') {
+ obj.removeEventListener(POINTER_MOVE, handler, false);
+
+ } else if (type === 'touchend') {
+ obj.removeEventListener(POINTER_UP, handler, false);
+ obj.removeEventListener(POINTER_CANCEL, handler, false);
+ }
+
+ return this;
+}
+
+function _addPointerStart(obj, handler, id) {
+ var onDown = bind(function (e) {
+ if (e.pointerType !== 'mouse' && e.MSPOINTER_TYPE_MOUSE && e.pointerType !== e.MSPOINTER_TYPE_MOUSE) {
+ // In IE11, some touch events needs to fire for form controls, or
+ // the controls will stop working. We keep a whitelist of tag names that
+ // need these events. For other target tags, we prevent default on the event.
+ if (TAG_WHITE_LIST.indexOf(e.target.tagName) < 0) {
+ preventDefault(e);
+ } else {
+ return;
+ }
+ }
+
+ _handlePointer(e, handler);
+ });
+
+ obj['_leaflet_touchstart' + id] = onDown;
+ obj.addEventListener(POINTER_DOWN, onDown, false);
+
+ // need to keep track of what pointers and how many are active to provide e.touches emulation
+ if (!_pointerDocListener) {
+ // we listen documentElement as any drags that end by moving the touch off the screen get fired there
+ document.documentElement.addEventListener(POINTER_DOWN, _globalPointerDown, true);
+ document.documentElement.addEventListener(POINTER_MOVE, _globalPointerMove, true);
+ document.documentElement.addEventListener(POINTER_UP, _globalPointerUp, true);
+ document.documentElement.addEventListener(POINTER_CANCEL, _globalPointerUp, true);
+
+ _pointerDocListener = true;
+ }
+}
+
+function _globalPointerDown(e) {
+ _pointers[e.pointerId] = e;
+ _pointersCount++;
+}
+
+function _globalPointerMove(e) {
+ if (_pointers[e.pointerId]) {
+ _pointers[e.pointerId] = e;
+ }
+}
+
+function _globalPointerUp(e) {
+ delete _pointers[e.pointerId];
+ _pointersCount--;
+}
+
+function _handlePointer(e, handler) {
+ e.touches = [];
+ for (var i in _pointers) {
+ e.touches.push(_pointers[i]);
+ }
+ e.changedTouches = [e];
+
+ handler(e);
+}
+
+function _addPointerMove(obj, handler, id) {
+ var onMove = function (e) {
+ // don't fire touch moves when mouse isn't down
+ if ((e.pointerType === e.MSPOINTER_TYPE_MOUSE || e.pointerType === 'mouse') && e.buttons === 0) { return; }
+
+ _handlePointer(e, handler);
+ };
+
+ obj['_leaflet_touchmove' + id] = onMove;
+ obj.addEventListener(POINTER_MOVE, onMove, false);
+}
+
+function _addPointerEnd(obj, handler, id) {
+ var onUp = function (e) {
+ _handlePointer(e, handler);
+ };
+
+ obj['_leaflet_touchend' + id] = onUp;
+ obj.addEventListener(POINTER_UP, onUp, false);
+ obj.addEventListener(POINTER_CANCEL, onUp, false);
+}
+
+/*
+ * Extends the event handling code with double tap support for mobile browsers.
+ */
+
+var _touchstart = msPointer ? 'MSPointerDown' : pointer ? 'pointerdown' : 'touchstart';
+var _touchend = msPointer ? 'MSPointerUp' : pointer ? 'pointerup' : 'touchend';
+var _pre = '_leaflet_';
+
+// inspired by Zepto touch code by Thomas Fuchs
+function addDoubleTapListener(obj, handler, id) {
+ var last, touch$$1,
+ doubleTap = false,
+ delay = 250;
+
+ function onTouchStart(e) {
+ var count;
+
+ if (pointer) {
+ if ((!edge) || e.pointerType === 'mouse') { return; }
+ count = _pointersCount;
+ } else {
+ count = e.touches.length;
+ }
+
+ if (count > 1) { return; }
+
+ var now = Date.now(),
+ delta = now - (last || now);
+
+ touch$$1 = e.touches ? e.touches[0] : e;
+ doubleTap = (delta > 0 && delta <= delay);
+ last = now;
+ }
+
+ function onTouchEnd(e) {
+ if (doubleTap && !touch$$1.cancelBubble) {
+ if (pointer) {
+ if ((!edge) || e.pointerType === 'mouse') { return; }
+ // work around .type being readonly with MSPointer* events
+ var newTouch = {},
+ prop, i;
+
+ for (i in touch$$1) {
+ prop = touch$$1[i];
+ newTouch[i] = prop && prop.bind ? prop.bind(touch$$1) : prop;
+ }
+ touch$$1 = newTouch;
+ }
+ touch$$1.type = 'dblclick';
+ handler(touch$$1);
+ last = null;
+ }
+ }
+
+ obj[_pre + _touchstart + id] = onTouchStart;
+ obj[_pre + _touchend + id] = onTouchEnd;
+ obj[_pre + 'dblclick' + id] = handler;
+
+ obj.addEventListener(_touchstart, onTouchStart, false);
+ obj.addEventListener(_touchend, onTouchEnd, false);
+
+ // On some platforms (notably, chrome<55 on win10 + touchscreen + mouse),
+ // the browser doesn't fire touchend/pointerup events but does fire
+ // native dblclicks. See #4127.
+ // Edge 14 also fires native dblclicks, but only for pointerType mouse, see #5180.
+ obj.addEventListener('dblclick', handler, false);
+
+ return this;
+}
+
+function removeDoubleTapListener(obj, id) {
+ var touchstart = obj[_pre + _touchstart + id],
+ touchend = obj[_pre + _touchend + id],
+ dblclick = obj[_pre + 'dblclick' + id];
+
+ obj.removeEventListener(_touchstart, touchstart, false);
+ obj.removeEventListener(_touchend, touchend, false);
+ if (!edge) {
+ obj.removeEventListener('dblclick', dblclick, false);
+ }
+
+ return this;
+}
+
+/*
+ * @namespace DomEvent
+ * Utility functions to work with the [DOM events](https://developer.mozilla.org/docs/Web/API/Event), used by Leaflet internally.
+ */
+
+// Inspired by John Resig, Dean Edwards and YUI addEvent implementations.
+
+// @function on(el: HTMLElement, types: String, fn: Function, context?: Object): this
+// Adds a listener function (`fn`) to a particular DOM event type of the
+// element `el`. You can optionally specify the context of the listener
+// (object the `this` keyword will point to). You can also pass several
+// space-separated types (e.g. `'click dblclick'`).
+
+// @alternative
+// @function on(el: HTMLElement, eventMap: Object, context?: Object): this
+// Adds a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}`
+function on(obj, types, fn, context) {
+
+ if (typeof types === 'object') {
+ for (var type in types) {
+ addOne(obj, type, types[type], fn);
+ }
+ } else {
+ types = splitWords(types);
+
+ for (var i = 0, len = types.length; i < len; i++) {
+ addOne(obj, types[i], fn, context);
+ }
+ }
+
+ return this;
+}
+
+var eventsKey = '_leaflet_events';
+
+// @function off(el: HTMLElement, types: String, fn: Function, context?: Object): this
+// Removes a previously added listener function.
+// Note that if you passed a custom context to on, you must pass the same
+// context to `off` in order to remove the listener.
+
+// @alternative
+// @function off(el: HTMLElement, eventMap: Object, context?: Object): this
+// Removes a set of type/listener pairs, e.g. `{click: onClick, mousemove: onMouseMove}`
+function off(obj, types, fn, context) {
+
+ if (typeof types === 'object') {
+ for (var type in types) {
+ removeOne(obj, type, types[type], fn);
+ }
+ } else if (types) {
+ types = splitWords(types);
+
+ for (var i = 0, len = types.length; i < len; i++) {
+ removeOne(obj, types[i], fn, context);
+ }
+ } else {
+ for (var j in obj[eventsKey]) {
+ removeOne(obj, j, obj[eventsKey][j]);
+ }
+ delete obj[eventsKey];
+ }
+
+ return this;
+}
+
+function addOne(obj, type, fn, context) {
+ var id = type + stamp(fn) + (context ? '_' + stamp(context) : '');
+
+ if (obj[eventsKey] && obj[eventsKey][id]) { return this; }
+
+ var handler = function (e) {
+ return fn.call(context || obj, e || window.event);
+ };
+
+ var originalHandler = handler;
+
+ if (pointer && type.indexOf('touch') === 0) {
+ // Needs DomEvent.Pointer.js
+ addPointerListener(obj, type, handler, id);
+
+ } else if (touch && (type === 'dblclick') && addDoubleTapListener &&
+ !(pointer && chrome)) {
+ // Chrome >55 does not need the synthetic dblclicks from addDoubleTapListener
+ // See #5180
+ addDoubleTapListener(obj, handler, id);
+
+ } else if ('addEventListener' in obj) {
+
+ if (type === 'mousewheel') {
+ obj.addEventListener('onwheel' in obj ? 'wheel' : 'mousewheel', handler, false);
+
+ } else if ((type === 'mouseenter') || (type === 'mouseleave')) {
+ handler = function (e) {
+ e = e || window.event;
+ if (isExternalTarget(obj, e)) {
+ originalHandler(e);
+ }
+ };
+ obj.addEventListener(type === 'mouseenter' ? 'mouseover' : 'mouseout', handler, false);
+
+ } else {
+ if (type === 'click' && android) {
+ handler = function (e) {
+ filterClick(e, originalHandler);
+ };
+ }
+ obj.addEventListener(type, handler, false);
+ }
+
+ } else if ('attachEvent' in obj) {
+ obj.attachEvent('on' + type, handler);
+ }
+
+ obj[eventsKey] = obj[eventsKey] || {};
+ obj[eventsKey][id] = handler;
+}
+
+function removeOne(obj, type, fn, context) {
+
+ var id = type + stamp(fn) + (context ? '_' + stamp(context) : ''),
+ handler = obj[eventsKey] && obj[eventsKey][id];
+
+ if (!handler) { return this; }
+
+ if (pointer && type.indexOf('touch') === 0) {
+ removePointerListener(obj, type, id);
+
+ } else if (touch && (type === 'dblclick') && removeDoubleTapListener &&
+ !(pointer && chrome)) {
+ removeDoubleTapListener(obj, id);
+
+ } else if ('removeEventListener' in obj) {
+
+ if (type === 'mousewheel') {
+ obj.removeEventListener('onwheel' in obj ? 'wheel' : 'mousewheel', handler, false);
+
+ } else {
+ obj.removeEventListener(
+ type === 'mouseenter' ? 'mouseover' :
+ type === 'mouseleave' ? 'mouseout' : type, handler, false);
+ }
+
+ } else if ('detachEvent' in obj) {
+ obj.detachEvent('on' + type, handler);
+ }
+
+ obj[eventsKey][id] = null;
+}
+
+// @function stopPropagation(ev: DOMEvent): this
+// Stop the given event from propagation to parent elements. Used inside the listener functions:
+// ```js
+// L.DomEvent.on(div, 'click', function (ev) {
+// L.DomEvent.stopPropagation(ev);
+// });
+// ```
+function stopPropagation(e) {
+
+ if (e.stopPropagation) {
+ e.stopPropagation();
+ } else if (e.originalEvent) { // In case of Leaflet event.
+ e.originalEvent._stopped = true;
+ } else {
+ e.cancelBubble = true;
+ }
+ skipped(e);
+
+ return this;
+}
+
+// @function disableScrollPropagation(el: HTMLElement): this
+// Adds `stopPropagation` to the element's `'mousewheel'` events (plus browser variants).
+function disableScrollPropagation(el) {
+ addOne(el, 'mousewheel', stopPropagation);
+ return this;
+}
+
+// @function disableClickPropagation(el: HTMLElement): this
+// Adds `stopPropagation` to the element's `'click'`, `'doubleclick'`,
+// `'mousedown'` and `'touchstart'` events (plus browser variants).
+function disableClickPropagation(el) {
+ on(el, 'mousedown touchstart dblclick', stopPropagation);
+ addOne(el, 'click', fakeStop);
+ return this;
+}
+
+// @function preventDefault(ev: DOMEvent): this
+// Prevents the default action of the DOM Event `ev` from happening (such as
+// following a link in the href of the a element, or doing a POST request
+// with page reload when a `