0)&&f?g[n.valueKey]=w:!p&&0===m&&f&&(g=w),i&&(p||m>0)&&Object.freeze(g),o.length=d,g}this.config=function(e){for(var o in e)n[o]=e[o];n.parserErrorHandler&&(i=new t.DOMParser({errorHandler:n.parserErrorHandler,locator:{}}))},l.prototype.toString=function(){return"null"},l.prototype.valueOf=function(){return null},this.xmlToJs=this.build=function(t,e,i,n){var o=arguments.length>1&&"number"==typeof e?3&e:1;return h(t,o,i||!1,arguments.length>3?n:3===o)},this.jsToXml=this.unbuild=function(i,o,a,r){var s=(t.document&&t.document.implementation||new t.DOMImplementation).createDocument(o||null,a||"",r||null);return function t(i,o,a){var r,s,l;if(a.constructor===String||a.constructor===Number||a.constructor===Boolean){if(o.appendChild(i.createTextNode(a.toString())),a===a.valueOf())return}else a.constructor===Date&&o.appendChild(i.createTextNode(a.toISOString()));for(var h in a)if(void 0!==(r=a[h])&&(null===r&&(r={}),!(isFinite(h)||r instanceof Function)))if(h===n.valueKey)null!==r&&!0!==r&&o.appendChild(i.createTextNode(r.constructor===Date?r.toISOString():String(r)));else if(h===n.attrKey)for(var u in r)o.setAttribute(u,r[u]);else if(h===n.attrPrefix+"xmlns")e&&o.setAttribute(h.slice(1),r);else if(h.charAt(0)===n.attrPrefix)o.setAttribute(h.slice(1),r);else if(r.constructor===Array)for(var d in r)r.hasOwnProperty(d)&&(s=(l=r[d]&&r[d][n.attrPrefix+"xmlns"]||o.namespaceURI)?i.createElementNS(l,h):i.createElement(h),t(i,s,r[d]||{}),o.appendChild(s));else s=(l=(r||{})[n.attrPrefix+"xmlns"]||o.namespaceURI)?i.createElementNS(l,h):i.createElement(h),r instanceof Object?t(i,s,r):null===r||!0===r&&n.trueIsEmpty||s.appendChild(i.createTextNode(r.toString())),o.appendChild(s)}(s,s.documentElement||s,i),s},this.stringToXml=function(e){return i||(i=new t.DOMParser),i.parseFromString(e,"application/xml")},this.xmlToString=function(e){return void 0!==e.xml?e.xml:(new t.XMLSerializer).serializeToString(e)},this.stringToJs=function(t){var e=this.stringToXml(t);return this.xmlToJs(e)},this.jsToString=this.stringify=function(t,e,i,n){return this.xmlToString(this.jsToXml(t,e,i,n))},this.each=function(t,e,i){t instanceof Array?t.forEach(e,i):[t].forEach(e,i)}}},"object"==typeof i?"object"==typeof window&&window.DOMImplementation&&window.XMLSerializer&&window.DOMParser?e.exports=o(window):e.exports=o(t("xmldom"),!0):n.JXON=o(window)},{xmldom:3}],3:[function(t,e,i){},{}]},{},[1])(1)})),function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).tokml=t()}}((function(){return function t(e,i,n){function o(r,s){if(!i[r]){if(!e[r]){var l="function"==typeof require&&require;if(!s&&l)return l(r,!0);if(a)return a(r,!0);var h=new Error("Cannot find module '"+r+"'");throw h.code="MODULE_NOT_FOUND",h}var u=i[r]={exports:{}};e[r][0].call(u.exports,(function(t){return o(e[r][1][t]||t)}),u,u.exports,t,e,i,n)}return i[r].exports}for(var a="function"==typeof require&&require,r=0;r'+o("kml",{xmlns:"http://www.opengis.net/kml/2.2"},o("Document",function(t){return void 0!==t.documentName?o("name",t.documentName):""}(e=e||{documentName:void 0,documentDescription:void 0,name:"name",description:"description",simplestyle:!1,timestamp:"timestamp"})+function(t){return void 0!==t.documentDescription?o("description",t.documentDescription):""}(e)+function(t,e){if(!t.type)return"";var i=[];switch(t.type){case"FeatureCollection":return t.features?t.features.map(a(e,i)).join(""):"";case"Feature":return a(e,i)(t);default:return a(e,i)({type:"Feature",geometry:t,properties:{}})}}(t,e)))};var r={Point:function(t){return o("Point",o("coordinates",t.coordinates.join(",")))},LineString:function(t){return o("LineString",o("coordinates",s(t.coordinates)))},Polygon:function(t){if(!t.coordinates.length)return"";var e=t.coordinates[0],i=t.coordinates.slice(1),n=o("outerBoundaryIs",o("LinearRing",o("coordinates",s(e)))),a=i.map((function(t){return o("innerBoundaryIs",o("LinearRing",o("coordinates",s(t))))})).join("");return o("Polygon",n+a)},MultiPoint:function(t){return t.coordinates.length?o("MultiGeometry",t.coordinates.map((function(t){return r.Point({coordinates:t})})).join("")):""},MultiPolygon:function(t){return t.coordinates.length?o("MultiGeometry",t.coordinates.map((function(t){return r.Polygon({coordinates:t})})).join("")):""},MultiLineString:function(t){return t.coordinates.length?o("MultiGeometry",t.coordinates.map((function(t){return r.LineString({coordinates:t})})).join("")):""},GeometryCollection:function(t){return o("MultiGeometry",t.geometries.map(r.any).join(""))},valid:function(t){return t&&t.type&&(t.coordinates||"GeometryCollection"===t.type&&t.geometries&&t.geometries.every(r.valid))},any:function(t){return r[t.type]?r[t.type](t):""},isPoint:function(t){return"Point"===t.type||"MultiPoint"===t.type},isPolygon:function(t){return"Polygon"===t.type||"MultiPolygon"===t.type},isLine:function(t){return"LineString"===t.type||"MultiLineString"===t.type}};function s(t){return t.map((function(t){return t.join(",")})).join(" ")}function l(t){return o("Data",{name:t[0]},o("value",{},n(t[1]?t[1].toString():"")))}function h(t,e){if("string"!=typeof t)return"";if(3===(t=t.replace("#","").toLowerCase()).length)t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2];else if(6!==t.length)return"";var i=t[0]+t[1],n=t[2]+t[3],o=t[4]+t[5],a="ff";return"number"==typeof e&&e>=0&&e<=1&&((a=(255*e).toString(16)).indexOf(".")>-1&&(a=a.substr(0,a.indexOf("."))),a.length<2&&(a="0"+a)),a+o+n+i}},{strxml:2,"xml-escape":3}],2:[function(t,e,i){var n=t("xml-escape");function o(t){return Object.keys(t).length?" "+Object.keys(t).map((function(e){return e+'="'+n(t[e])+'"'})).join(" "):""}e.exports.attr=o,e.exports.tagClose=function(t,e){return"<"+t+o(e)+"/>"},e.exports.tag=function(t,e,i){(Array.isArray(e)||"string"==typeof e)&&(i=e,e={});Array.isArray(i)&&(i="\n"+i.map((function(t){return" "+t})).join("\n")+"\n");return"<"+t+o(e)+">"+i+""+t+">"}},{"xml-escape":3}],3:[function(t,e,i){(e.exports=function t(e,i){var n;if(null!=e)return e=e.toString(),i=(i||"").replace(/[^&"<>\']/g,""),n="([&\"<>'])".replace(new RegExp("["+i+"]","g"),""),e.replace(new RegExp(n,"g"),(function(e,i){return t.map[i]}))}).map={">":">","<":"<","'":"'",'"':""","&":"&"}},{}]},{},[1])(1)}));var waymark_js_localize={action_fullscreen_activate:"View Fullscreen",action_fullscreen_deactivate:"Exit Fullscreen",action_locate_activate:"Show me where I am",action_zoom_in:"Zoom in",action_zoom_out:"Zoom out",label_total_length:"Total Length: ",label_max_elevation:"Max. Elevation: ",label_min_elevation:"Min. Elevation: ",add_line_title:"Draw a Line",add_photo_title:"Upload an Image",add_marker_title:"Place a Marker",add_rectangle_title:"Draw a Rectangle",add_polygon_title:"Draw a Polygon",add_circle_title:"Draw a Circle",upload_file_title:"Read Lines and Markers from file (GPX/KML/GeoJSON supported, which most apps should Export to)",action_duplicate:"Duplicate",action_delete:"Delete",action_edit:"Edit",action_edit_done:"Finish editing",action_upload_image:"Upload Image",object_title_placeholder:"Title",object_image_placeholder:"Image URL",object_description_placeholder:"Description",object_type_label:"Type",marker_latlng_label:"Lat,Lng",action_delete_confirm:"Are you sure you want to delete this",action_search_placeholder:"Search...",object_label_marker:"Marker",object_label_line:"Line",object_label_shape:"Shape",object_label_marker_plural:"Markers",object_label_line_plural:"Lines",object_label_shape_plural:"Shapes",error_message_prefix:"Waymark Error",info_message_prefix:"Waymark Info",error_file_type:"This file type is not supported.",error_file_conversion:"Could not convert this file to GeoJSON.",error_file_upload:"File upload error.",error_photo_meta:"Could not retrieve Image metadata.",info_exif_yes:"Image location metadata (EXIF) detected!",info_exif_no:"Image location metadata (EXIF) NOT detected.",error_no_wpmedia:"WordPress Media Library not found",no_direction:"No Direction",show_direction:"Show Direction",reverse_direction:"Reverse Direction"};if(void 0===waymark_js)var waymark_js={lang:{}};for(key in waymark_js_localize)void 0===waymark_js.lang[key]&&(waymark_js.lang[key]=waymark_js_localize[key]);function Waymark_Map(){this.fallback_latlng=[51.38436,-68.74923],this.fallback_zoom=9,this.init=function(t){for(config_key in Waymark=this,Waymark.jq_map_container=null,Waymark.config={map_div_id:"waymark-map",map_options:{show_type_labels:1,button_position:"bottomright",max_zoom:0},map_height:400,map_width:null,map_init_zoom:void 0,map_init_latlng:void 0,map_init_basemap:void 0,show_gallery:0,show_filter:0,show_elevation:0,show_cluster:1,elevation_div_id:"waymark-elevation",elevation_units:"metric",elevation_initial:1,tile_layers:{},line_types:{},shape_types:{},marker_types:{},marker_data_defaults:{title:void 0,type:void 0,image_thumbnail_url:void 0,image_medium_url:void 0,image_large_url:void 0,description:void 0},line_data_defaults:{type:void 0,title:void 0,image_thumbnail_url:void 0,image_medium_url:void 0,image_large_url:void 0,description:void 0,direction:void 0},shape_data_defaults:{type:void 0,title:void 0,image_thumbnail_url:void 0,image_medium_url:void 0,image_large_url:void 0,description:void 0},editor_options:{confirm_delete:1},handle_content_callback:void 0,handle_delete_callback:void 0,handle_edit_callback:void 0,handle_custom_type_callback:void 0,media_library_sizes:["thumbnail","medium","large","full"]},Waymark.config)void 0!==t[config_key]&&(Waymark.config[config_key]=t[config_key]);var e=Waymark.get_type("line"),i=Waymark.make_key(e.line_title);Waymark.config.line_data_defaults.type=i;var n=Waymark.get_type("shape"),o=Waymark.make_key(n.shape_title);Waymark.config.shape_data_defaults.type=o;var a=Waymark.get_type("marker"),r=Waymark.make_key(a.marker_title);Waymark.config.marker_data_defaults.type=r,Waymark.marker_parent_group=Waymark_L.layerGroup(),Waymark.marker_sub_groups={},Waymark.line_parent_group=Waymark_L.layerGroup(),Waymark.line_sub_groups={},Waymark.shape_parent_group=Waymark_L.layerGroup(),Waymark.shape_sub_groups={},Waymark.pre_map_setup(),Waymark.setup_map(),Waymark.handle_resize(),Waymark.init_done()},this.get_property=function(t,...e){return e.reduce((t,e)=>t&&t[e],t)},this.debug=function(t){1==this.get_property(waymark_settings,"misc","advanced","debug_mode")&&("string"==typeof t?console.log("["+waymark_js.lang.info_message_prefix+"] "+t):(console.log("["+waymark_js.lang.info_message_prefix+"] ..."),console.log(t)))},this.message=function(t=null,e="info",i="console"){if(t){var n="";switch(e){case"error":n=waymark_js.lang.error_message_prefix;break;default:case"info":n=waymark_js.lang.info_message_prefix}n&&(n="["+n+"] "),"console"==i?console.log(n+t):alert(n+t)}},this.title_case=function(t){return t.replace(/(?:^|\s)\w/g,(function(t){return t.toUpperCase()}))},this.transliterate=function(t){var e={"Ё":"YO","Й":"I","Ц":"TS","У":"U","К":"K","Е":"E","Н":"N","Г":"G","Ш":"SH","Щ":"SCH","З":"Z","Х":"H","Ъ":"'","ё":"yo","й":"i","ц":"ts","у":"u","к":"k","е":"e","н":"n","г":"g","ш":"sh","щ":"sch","з":"z","х":"h","ъ":"'","Ф":"F","Ы":"I","В":"V","А":"a","П":"P","Р":"R","О":"O","Л":"L","Д":"D","Ж":"ZH","Э":"E","ф":"f","ы":"i","в":"v","а":"a","п":"p","р":"r","о":"o","л":"l","д":"d","ж":"zh","э":"e","Я":"Ya","Ч":"CH","С":"S","М":"M","И":"I","Т":"T","Ь":"'","Б":"B","Ю":"YU","я":"ya","ч":"ch","с":"s","м":"m","и":"i","т":"t","ь":"'","б":"b","ю":"yu"};return t.split("").map((function(t){return e[t]||t})).join("")},this.make_key=function(t){return t?t=(t=(t=this.transliterate(t)).replace(/[^a-z0-9+]+/gi,"")).toLowerCase():t},this.get_feature_overlay_type=function(t){if(void 0===t.geometry.type)return!1;switch(t.geometry.type){case"Point":return t.properties.radius?"shape":"marker";case"LineString":case"MultiLineString":return"line";case"Polygon":return"shape"}return!1},this.setup_map=function(){Waymark=this,Waymark.jq_map_container=jQuery("#"+Waymark.config.map_div_id),Waymark.jq_map_container.addClass("waymark-map-container"),Waymark.jq_map_container.css("height",Waymark.config.map_height+"px");var t={fullscreenControl:!1,attributionControl:!1,editable:!0,zoomControl:!1,sleep:!1};"view"==Waymark.mode?(t.dragging=!1,t.sleep=!0,t.wakeTime=1e3*this.get_property(waymark_settings,"misc","interaction_options","delay_seconds"),"1"===this.get_property(waymark_settings,"misc","interaction_options","do_message")?(t.sleepNote=!0,t.wakeMessage=this.get_property(waymark_settings,"misc","interaction_options","wake_message")):(t.sleepNote=!1,t.wakeMessage=!1),t.sleepOpacity=1,(max_zoom=Waymark.config.map_options.max_zoom)&&(t.maxZoom=max_zoom)):t.dragging=!0;Waymark.map=Waymark_L.map(Waymark.config.map_div_id,t),Waymark_L.control.attribution({prefix:'Waymark | Leaflet'}).addTo(Waymark.map),1==this.get_property(waymark_settings,"misc","map_options","show_scale")&&Waymark_L.control.scale().addTo(Waymark.map),Waymark.jq_map_container.data("Waymark",Waymark),void 0!==Waymark.config.map_init_latlng?Waymark.map.setView(Waymark.config.map_init_latlng):Waymark.map.setView(Waymark.fallback_latlng),void 0!==Waymark.config.map_init_zoom?Waymark.map.setZoom(Waymark.config.map_init_zoom):Waymark.map.setZoom(Waymark.fallback_zoom),Waymark_L.Path.mergeOptions({color:"#b42714"}),Waymark_L.control.zoom({position:Waymark.config.map_options.button_position,zoomInTitle:waymark_js.lang.action_zoom_in,zoomOutTitle:waymark_js.lang.action_zoom_out}).addTo(Waymark.map),Waymark_L.control.locate({position:"bottomright",icon:"ion ion-android-locate",drawCircle:!1,strings:{title:waymark_js.lang.action_locate_activate},locateOptions:{enableHighAccuracy:!0}}).addTo(Waymark.map),Waymark_L.control.fullscreen({position:Waymark.config.map_options.button_position,title:{false:waymark_js.lang.action_fullscreen_activate,true:waymark_js.lang.action_fullscreen_deactivate}}).addTo(Waymark.map),Waymark.marker_parent_group.addTo(Waymark.map),Waymark.line_parent_group.addTo(Waymark.map),Waymark.shape_parent_group.addTo(Waymark.map),Waymark.setup_layers(),Waymark.create_data_layer(),Waymark.create_buttons()},this.create_data_layer=function(){Waymark=this,Waymark.map_data=Waymark_L.geoJSON(null,{pointToLayer:function(t,e){return void 0!==t.properties&&t.properties.radius?new Waymark_L.Circle(e,parseFloat(t.properties.radius)):Waymark.create_marker(e)},onEachFeature:function(t,e){switch(t.geometry.type){case"Point":if(t.properties.radius){t.properties=Waymark.parse_layer_data("shape",t.properties);var i=Waymark.get_type("shape",t.properties.type);e.setStyle({color:i.shape_colour,fillOpacity:i.fill_opacity}),Waymark.info_window("shape",t,e),Waymark.tooltip("shape",t,e),Waymark.add_to_group("shape",e)}else{t.properties=Waymark.parse_layer_data("marker",t.properties);i=Waymark.get_type("marker",t.properties.type);e.setIcon(Waymark_L.divIcon(Waymark.build_icon_data(i))),void 0!==Waymark.gallery_images&&Waymark.add_to_gallery(e),Waymark.info_window("marker",t,e),Waymark.tooltip("marker",t,e),Waymark.add_to_group("marker",e)}break;case"LineString":case"MultiLineString":t.properties=Waymark.parse_layer_data("line",t.properties);i=Waymark.get_type("line",t.properties.type);e.setStyle({color:i.line_colour,weight:i.line_weight,opacity:i.line_opacity}),Waymark.info_window("line",t,e),Waymark.tooltip("line",t,e);var n=parseInt(i.line_display);Waymark.draw_line_direction(e,n),Waymark.add_to_group("line",e);break;case"Polygon":t.properties=Waymark.parse_layer_data("shape",t.properties),t.properties.rectangle;i=Waymark.get_type("shape",t.properties.type);e.setStyle({color:i.shape_colour,fillOpacity:i.fill_opacity}),Waymark.info_window("shape",t,e),Waymark.tooltip("shape",t,e),Waymark.add_to_group("shape",e)}}})},this.draw_line_direction=function(t,e=!0){var i=t.feature,n=i.properties.direction,o=Waymark.get_type("line",i.properties.type);if("object"==typeof t.direction_layer&&Waymark.map.removeLayer(t.direction_layer),"string"==typeof n&&("default"==n||"reverse"==n)){var a=45;"reverse"==n&&(a=360-a);var r=Waymark_L.polylineDecorator(t,{patterns:[{repeat:100,symbol:L.Symbol.arrowHead({pixelSize:15,headAngle:a,polygon:!0,pathOptions:{color:"#fff",fillColor:o.line_colour,opacity:"0.7",stroke:!0,fillOpacity:.7,weight:2}})}]});e&&r.addTo(Waymark.map),t.direction_layer=r}},this.setup_layers=function(){Waymark=this,Waymark.layer_control=Waymark_L.control.layers();var t=[],e=0;if(void 0!==Waymark.config.map_init_basemap)for(var i in Waymark.config.tile_layers){Waymark.config.map_init_basemap.toUpperCase()===Waymark.config.tile_layers[i].layer_name.toUpperCase()&&(e=i)}for(var i in Waymark.config.tile_layers){void 0!==Waymark.config.tile_layers[i].append&&(Waymark.config.tile_layers[i].layer_url+=Waymark.config.tile_layers[i].append);var n={id:Waymark.config.tile_layers[i].layer_name.replace(/ /g,""),attribution:Waymark.config.tile_layers[i].layer_attribution},o=parseInt(Waymark.config.tile_layers[i].layer_max_zoom);o&&(n.maxZoom=o);var a=Waymark_L.tileLayer(Waymark.config.tile_layers[i].layer_url,n);t[Waymark.config.tile_layers[i].layer_name]=a,i==e&&a.addTo(Waymark.map)}if(i>=1)for(basemap_name in Waymark.layer_control.addTo(Waymark.map),t)Waymark.layer_control.addBaseLayer(t[basemap_name],basemap_name)},this.get_type=function(t,e){Waymark=this;var i=null;for(var n in Waymark.config[t+"_types"]){0==n&&(i=Waymark.config[t+"_types"][n]);var o=Waymark.config[t+"_types"][n][t+"_title"];o&&Waymark.make_key(e)==Waymark.make_key(o)&&(i=Waymark.config[t+"_types"][n])}return i=Waymark.parse_type(i,t)},this.parse_type=function(t,e){if(Waymark=this,"object"!=typeof t)return t;switch(e){case"line":var i=[{key:"line_colour",default:"#b42714"},{key:"line_weight",default:"3"},{key:"line_opacity",default:"0.7"}];for(var n in i)"string"!=typeof t[i[n].key]&&(t[i[n].key]=i[n].default)}return t.type_key=Waymark.make_key(t[e+"_title"]),t},this.handle_resize=function(){Waymark=this,jQuery(window).on("resize",(function(){Waymark.config.map_height=Waymark.jq_map_container.height(),Waymark.config.map_width=Waymark.jq_map_container.width(),"function"==typeof Waymark.size_gallery&&Waymark.size_gallery()}))},this.tooltip=function(t,e,i){Waymark=this;var n="";if("1"==Waymark.config.map_options.show_type_labels){var o=Waymark.get_type(t,e.properties.type);if(o){var a=o[t+"_title"];a&&(n="["+a+"] ")}}e.properties.title&&(n+=e.properties.title),n&&(i.bindTooltip(n),i.on("mouseover",(function(t){var e=t.target.getTooltip();e.setLatLng(t.latlng),e.openTooltip()})),i.on("mousemove",(function(t){t.target.getTooltip().setLatLng(t.latlng)})))},this.get_data_defaults=function(t){return Object.assign({},Waymark.config[t+"_data_defaults"])},this.parse_layer_data=function(t,e){Waymark=this;var n=Waymark.get_data_defaults(t);if("object"==typeof e)for(r in n)void 0!==e[r]&&e[r]&&(n[r]=e[r]);for(r in e)if(e[r])switch(r){case"name":n.title=e[r];break;case"desc":case"notes":n.description=e[r];break;case"radius":n[r]=parseFloat(e[r])}var o=this.get_property(waymark_settings,"overlay","properties");if(Object.keys(o).length){var a="";for(i in o){var r=o[i].property_key,s=o[i].property_title,l=e[r];void 0!==l&&(a+=''+s+"
"+l+"
",Waymark.debug("Importing "+s+" ("+r+") ==> "+l))}a&&(void 0===n.description&&(n.description=""),n.description+=a)}return n},this.add_to_group=function(t,e){var i=e.feature;if(void 0!==i.properties.type){var n=i.properties.type,o=Waymark.get_type(t,n);if(void 0===Waymark[t+"_sub_groups"][o.type_key]){var a=Waymark_L.featureGroup.subGroup(Waymark[t+"_parent_group"]);Waymark[t+"_sub_groups"][o.type_key]=a,"view"==Waymark.mode&&void 0!==o[t+"_display"]?"1"==o[t+"_display"]&&a.addTo(Waymark.map):a.addTo(Waymark.map)}if(e.addTo(Waymark[t+"_sub_groups"][o.type_key]),"line"==t&&"object"==typeof e.direction_layer&&e.direction_layer.addTo(Waymark[t+"_sub_groups"][o.type_key]),Waymark.config.show_filter&&"view"==Waymark.mode)for(key in Waymark.layer_control.addTo(Waymark.map),Waymark.layer_control.removeLayer(Waymark[t+"_parent_group"]),Waymark.layer_control.addOverlay(Waymark[t+"_parent_group"],""+waymark_js_localize["object_label_"+t+"_plural"]+""),Waymark_L.stamp(Waymark[t+"_parent_group"]),Waymark[t+"_sub_groups"]){var r=Waymark.get_type(t,key);a=Waymark[t+"_sub_groups"][key];Waymark.layer_control.removeLayer(a),Waymark.layer_control.addOverlay(a,Waymark.type_to_text(t,r))}}else e.addTo(Waymark[t+"_parent_group"])},this.type_to_text=function(t,e,i="span"){var n="waymark-type-text waymark-"+t+"-type",o="";switch(t){case"marker":o+="color:"+e.icon_colour+";",o+="background:"+Waymark.get_marker_background(e.marker_colour);break;case"line":o+="color:"+e.line_colour+";box-shadow:inset 0 0 0 1px "+e.line_colour;break;case"shape":o+="background:"+e.shape_colour}return"<"+i+' class="'+n+'" style="'+o+'">'+e[t+"_title"]+""+i+">"},this.create_marker=function(t){return Waymark_L.marker(t)},this.build_icon_data=function(t){var e={className:"waymark-marker waymark-marker-"+t.type_key};if(void 0!==t.marker_shape&&void 0!==t.marker_size){switch(e.className+=" waymark-marker-"+t.marker_shape,e.className+=" waymark-marker-"+t.marker_size,t.marker_shape){case"rectangle":case"circle":case"marker":switch(t.marker_size){case"small":e.iconSize=[16,16];break;case"medium":e.iconSize=[25,25];break;default:case"large":e.iconSize=[32,32]}}"marker"==t.marker_shape&&(e.iconAnchor=[e.iconSize[0]/2,1.25*e.iconSize[1]])}var i="background:"+Waymark.get_marker_background(t.marker_colour)+";",n="color:"+t.icon_colour+";";e.html='';var o="waymark-marker-icon";switch(t.icon_type){case"text":o+=" waymark-icon-text",e.html+=''+t.marker_icon+"
";break;case"html":o+=" waymark-icon-html";var a=jQuery("").html(t.marker_icon).text();e.html+=''+a+"
";break;case"icon":default:o+=" waymark-icon-icon",0===t.marker_icon.indexOf("ion-")?(o+=" ion ",o+=" "+t.marker_icon):0===t.marker_icon.indexOf("fa-")?(o+=" fa",o+=" "+t.marker_icon):(o+=" ion",o+=" ion-"+t.marker_icon),e.html+=''}return e},this.get_marker_background=function(t){if(["red","darkred","orange","green","darkgreen","blue","purple","darkpurple","cadetblue","white","black"].includes(t))switch(t){case"red":return"#da3d20";case"darkred":return"#a43233";case"orange":return"#f9960a";case"green":return"#70af00";case"darkgreen":return"#72820d";case"blue":return"#2aabe1";case"purple":return"#d553bd";case"darkpurple":return"#5c3a6e";case"cadetblue":return"#416979";case"white":return"#fbfbfb";case"black":return"#303030"}return t},this.create_marker_json=function(t,e={}){Waymark.debug(Waymark.config.marker_data_defaults);var i=Object.assign({},Waymark.config.marker_data_defaults,e),n={geometry:{type:"Point",coordinates:[t.lng,t.lat]},type:"Feature",properties:i};return Waymark.debug(n),n},this.get_exif_latlng=function(t){return t.GPSLatitudeNum&&!isNaN(t.GPSLatitudeNum)&&t.GPSLongitudeNum&&!isNaN(t.GPSLongitudeNum)?(Waymark.debug(waymark_js.lang.info_exif_yes),L.latLng(t.GPSLatitudeNum,t.GPSLongitudeNum)):(Waymark.debug(waymark_js.lang.info_exif_no),!1)},this.get_image_sizes=function(t,e){Waymark=this;var i={};for(var n in Waymark.config.media_library_sizes)i["image_"+Waymark.config.media_library_sizes[n]+"_url"]=e,void 0!==t[Waymark.config.media_library_sizes[n]]&&void 0!==t[Waymark.config.media_library_sizes[n]].url&&(i["image_"+Waymark.config.media_library_sizes[n]+"_url"]=t[Waymark.config.media_library_sizes[n]].url);return i},this.pre_map_setup=function(){},this.init_done=function(){},this.info_window=function(t,e,i){},this.build_content=function(t,e){}}function Waymark_Map_Viewer(){this.gallery_images=[],this.pre_map_setup=function(){Waymark=this,Waymark.mode="view"},this.init_done=function(){Waymark=this,Waymark.jq_map_container.show(),Waymark.map.invalidateSize(),Waymark.config.map_width=Waymark.jq_map_container.width(),Waymark.setup_gallery(),Waymark.setup_elevation(),Waymark.setupCluster(),jQuery(Waymark.map.getContainer()).addClass("waymark-is-viewer"),Waymark.setup_hidden_checker()},this.setupCluster=()=>{Waymark.config.show_cluster&&(Waymark.jq_map_container.addClass("waymark-has-cluster"),Waymark.map._layersMaxZoom=18,Waymark.marker_cluster=L.markerClusterGroup({animate:!1,showCoverageOnHover:!1,removeOutsideVisibleBounds:!0,iconCreateFunction:this.clusterIconFunction,spiderfyOnMaxZoom:!1,disableClusteringAtZoom:Waymark.get_property(waymark_settings,"misc","cluster_options","cluster_threshold"),maxClusterRadius:Waymark.get_property(waymark_settings,"misc","cluster_options","cluster_radius")}),Waymark.marker_parent_group=Waymark.marker_cluster,Waymark.map.addLayer(Waymark.marker_cluster))},this.clusterIconFunction=t=>{const e=new Map([]);t.getAllChildMarkers().forEach(t=>{const i=t.feature.properties.type,n=Waymark.get_type("marker",i);n.iconData=Waymark.build_icon_data(n),e.has(i)?n.typeCount++:n.typeCount=1,e.set(i,n)});let i="",n=0,o=0,a=0;return[...e.entries()].sort((t,e)=>e[1].typeCount-t[1].typeCount).forEach(([t,r])=>{const s=r.typeCount,l=r.iconData,h=e.size-n;o=l.iconSize[0]>o?l.iconSize[0]:o,a=l.iconSize[0]>a?l.iconSize[0]:a,s>1&&(l.html+=`${s}
`);const u=8*n;i+=`\n\t\t\t\t\n\t\t\t\t\t${l.html}\t\t\t\t\t\n\t\t\t\t
\n\t\t\t`,n++}),L.divIcon({className:"waymark-cluster",html:i,iconSize:[o,a]})},this.setup_hidden_checker=function(){let t=setInterval((function(){is_hidden=Waymark.jq_map_container.is(":hidden"),is_hidden||(Waymark.reset_map_view(),clearInterval(t))}),100)},this.create_buttons=function(){},this.load_json=function(t){Waymark=this,"object"==typeof t&&void 0!==t.features&&(Waymark.map_data.addData(t),Waymark.reset_map_view())},this.reset_map_view=function(){if(Waymark=this,void 0===Waymark.config.map_init_latlng&&void 0===Waymark.config.map_init_zoom){var t=Waymark.map_data.getBounds();"object"==typeof t&&t.isValid()&&(Waymark.map.invalidateSize(),Waymark.map.fitBounds(t))}else void 0!==Waymark.config.map_init_latlng&&void 0!==Waymark.config.map_init_zoom?Waymark.map.setView(Waymark.config.map_init_latlng,Waymark.config.map_init_zoom):(void 0!==Waymark.config.map_init_latlng&&(Waymark.map.setView(Waymark.config.map_init_latlng),Waymark.map.setZoom(Waymark.map.getBoundsZoom(Waymark.map_data.getBounds()))),void 0!==Waymark.config.map_init_zoom&&(Waymark.map.setZoom(Waymark.config.map_init_zoom),Waymark.map.setView(Waymark.map_data.getBounds().getCenter())))},this.build_content=function(t,e){Waymark=this;var i=jQuery(""),n=jQuery("").addClass("waymark-info waymark-"+t+"-info");for(key in Waymark.config[t+"_data_defaults"]){var o=null;switch(key){case"title":e.properties.title?o=jQuery("").html(e.properties.title):(o=jQuery("").html(" "),n.addClass("waymark-no-title"));break;case"type":if("1"!=Waymark.config.map_options.show_type_labels)break;var a=Waymark.get_type(t,e.properties.type);a&&(o=Waymark.type_to_text(t,a,"small"));break;case"description":var r=e.properties.description;r?o=0===r.indexOf("<")?r:jQuery("").html(r):n.addClass("waymark-no-description");break;case"image_large_url":if(void 0!==e.properties.image_large_url){var s=e.properties.image_large_url;if(void 0!==e.properties.image_medium_url)s=e.properties.image_medium_url;o=jQuery("").attr({href:e.properties.image_large_url,target:"_blank",style:"background-image:url("+s+")"})}else n.addClass("waymark-no-image")}o&&n.append(jQuery("").addClass("waymark-info-"+key+" waymark-"+t+"-info-"+key).append(o))}return n.children().length&&i.append(n),i},this.info_window=function(t,e,i){if(Waymark=this,Waymark.config.show_elevation&&"line"==t&&(Waymark.config.elevation_initial&&Waymark.line_has_elevation_data(e)&&!Waymark.elevation_container.is(":visible")&&(Waymark.elevation_container.show(),Waymark.elevation_control.loadData(e)),i.on("click",(function(t){var e=t.target.feature;Waymark.elevation_control.clear(),void 0!==Waymark.elevation_control.layer&&Waymark.elevation_control.layer.removeFrom(Waymark.map),Waymark.elevation_container.hide(),Waymark.line_has_elevation_data(e)&&(Waymark.elevation_container.show(),Waymark.elevation_control.loadData(e))}))),void 0!==e.properties.description||void 0!==e.properties.image_large_url){var n=Waymark.build_content(t,e,i),o=e.properties.title;"function"==typeof Waymark.config.handle_content_callback?i.on("click",(function(){Waymark.config.handle_content_callback(n.get(0),o,Waymark.mode)})):i.bindPopup(n.get(0)).openPopup()}},this.line_has_elevation_data=function(t){if("MultiLineString"==t.geometry.type){for(var e in t.geometry.coordinates)for(var i in t.geometry.coordinates[e])if(3==t.geometry.coordinates[e][i].length)return!0}else for(var i in t.geometry.coordinates)if(3==t.geometry.coordinates[i].length)return!0;return!1},this.setup_elevation=function(){if(Waymark=this,Waymark.config.show_elevation){Waymark_L.registerLocale("waymark",{"Total Length: ":waymark_js.lang.label_total_length,"Max Elevation: ":waymark_js.lang.label_max_elevation,"Min Elevation: ":waymark_js.lang.label_min_elevation}),Waymark_L.setLocale("waymark");var t={theme:"magenta-theme",detached:!0,followMarker:!1,width:Waymark.config.map_width};if(void 0!==Waymark.config.elevation_div_id){t.elevationDiv="#"+Waymark.config.elevation_div_id,Waymark.elevation_container=jQuery(t.elevationDiv),Waymark.elevation_container.hide();var e=jQuery("").addClass("waymark-elevation-close").text("x").on("click",{W:Waymark},(function(t){var e=t.data.W;e.elevation_control.clear(),e.elevation_control.layer.removeFrom(e.map),e.elevation_container.hide()}));Waymark.elevation_container.append(e)}void 0!==Waymark.config.elevation_units&&"imperial"==Waymark.config.elevation_units&&(t.imperial=!0),Waymark.elevation_control=Waymark_L.control.elevation(t).addTo(Waymark.map),Waymark.map.on("overlayremove",(function(t){if(void 0!==Waymark.elevation_control.layer){var e=null;Waymark.elevation_control.layer.eachLayer((function(t){e=JSON.stringify(t.getLatLngs())})),e&&t.layer.eachLayer((function(t){void 0!==t.getLatLngs&&e==JSON.stringify(t.getLatLngs())&&(Waymark.elevation_control.clear(),Waymark.elevation_control.layer.removeFrom(Waymark.map),Waymark.elevation_container.hide())}))}}))}},this.setup_gallery=function(){if(Waymark=this,Waymark.config.show_gallery){Waymark.gallery=jQuery("").attr("id",Waymark.config.gallery_div_id).css("width",Waymark.config.map_width).addClass("waymark-gallery-container").html(""),Waymark_L.DomEvent.disableClickPropagation(Waymark.gallery.get(0)),jQuery(Waymark.map.getContainer()).append(Waymark.gallery),Waymark.size_gallery();var t=Waymark;Waymark.map.on("moveend",(function(){t.render_gallery()}),{W:t}),Waymark.map.on("layerremove layeradd",(function(){t.render_gallery()}),{W:t})}},this.size_gallery=function(){if(Waymark=this,void 0!==Waymark.gallery&&Waymark.gallery.length){gallery_padding=Waymark.gallery.css("paddingRight"),gallery_padding=gallery_padding.replace("px",""),gallery_padding=parseInt(gallery_padding);var t=Waymark.config.map_width-2*gallery_padding;Waymark.gallery.css("width",t)}},this.add_to_gallery=function(t){if(Waymark=this,void 0===t.feature.properties.image_thumbnail_url||void 0===t.feature.properties.image_large_url)return!1;var e=Object.assign({},t.feature.properties);e.latlng=t.feature.geometry.coordinates,e.marker=t,Waymark.gallery_images.push(e)},this.render_gallery=function(){Waymark=this;var t=0;if(void 0!==Waymark.gallery&&Waymark.gallery.length&&(Waymark.gallery.html(""),Waymark.gallery.hide(),jQuery(Waymark.map.getContainer()).removeClass("waymark-has-gallery"),Waymark.gallery_images.length)){for(i=0;i").addClass("waymark-image").on("click",{marker:e.marker},(function(t){t.data.marker.openPopup()})),o=jQuery("
").attr({src:e.image_thumbnail_url});n.append(o),Waymark.gallery.append(n)}}t&&(Waymark.gallery.show(),jQuery(Waymark.map.getContainer()).addClass("waymark-has-gallery"))}}}function Waymark_Map_Editor(){this.pre_map_setup=function(){Waymark=this,Waymark.mode="edit"},this.init_done=function(){Waymark=this,jQuery(Waymark.map.getContainer()).addClass("waymark-is-editor"),Waymark.jq_map_container.append(jQuery("").attr({id:"waymark-loading"}).html('')),Waymark.map.on("editable:drawing:commit",(function(t){switch(layer=t.layer,void 0===layer.feature&&(layer.feature={type:"Feature",properties:{}}),!0){case layer instanceof Waymark_L.Circle:layer.feature.properties=Waymark.config.shape_data_defaults,layer.feature.properties.radius=layer.getRadius();break;case layer instanceof Waymark_L.Rectangle:layer.feature.properties=Waymark.config.shape_data_defaults,layer.feature.properties.rectangle=!0;break;case layer instanceof Waymark_L.Polygon:layer.feature.properties=Waymark.config.shape_data_defaults;break;case layer instanceof Waymark_L.Polyline:layer.feature.properties=Waymark.config.line_data_defaults}Waymark.map_data.addData(layer.toGeoJSON()),Waymark.map.removeLayer(layer),Waymark.save_data_layer(),Waymark.map_was_edited()})),Waymark.map.on("editable:editing",(function(t){layer=t.layer,void 0!==layer.feature&&layer.feature.properties.radius&&(layer.feature.properties.radius=layer.getRadius()),Waymark.save_data_layer(),Waymark.map_was_edited()})),Waymark.map.on("popupopen",(function(t){var e=t.popup._source.feature;setTimeout((function(){wp.editor.initialize("waymark-info-description",{tinymce:{toolbar1:"styleselect | bullist numlist | link image",setup:function(t){t.on("change",(function(t){e.properties.description=wp.editor.getContent("waymark-info-description"),Waymark.save_data_layer(),Waymark.map_was_edited()}))}}})}),250)})),Waymark.map.on("popupclose",(function(t){wp.editor.remove("waymark-info-description"),jQuery("#waymark-info-description").show()}))},this.create_marker=function(t){Waymark=this;var e=Waymark_L.marker(t,{draggable:!0});return e.on("moveend",(function(t){var e=t.target,i=e.feature;i.geometry.coordinates=[e._latlng.lng.toFixed(6),e._latlng.lat.toFixed(6)],Waymark.info_window("marker",i,e),Waymark.save_data_layer(),Waymark.map_was_edited()})),e},this.save_data_layer=function(){Waymark=this;var t=jQuery(".waymark-input-map_data").first(),e=JSON.stringify(Waymark.map_data.toGeoJSON());t.html(e)},this.map_was_edited=function(){},this.loading_start=function(){Waymark=this,Waymark.jq_map_container.addClass("waymark-loading")},this.loading_stop=function(){Waymark=this,Waymark.jq_map_container.removeClass("waymark-loading")},this.create_buttons=function(){Waymark=this;var t=Waymark_L.Control.geocoder({position:"bottomright",defaultMarkGeocode:!1,placeholder:waymark_js.lang.action_search_placeholder});t.on("markgeocode",(function(t){Waymark.map.fitBounds(t.geocode.bbox)})),t.addTo(Waymark.map);var e=Waymark_L.Control.extend({options:{position:"bottomleft"},onAdd:function(t){var e=Waymark_L.DomUtil.create("div","leaflet-bar leaflet-control waymark-leaflet-control waymark-edit-toolbar");if((n=Waymark_L.DomUtil.create("a","waymark-icon waymark-edit-button waymark-edit-line",e)).setAttribute("title",waymark_js.lang.add_line_title),n.onclick=function(){Waymark.map.editTools.startPolyline()},(n=Waymark_L.DomUtil.create("a","waymark-edit-button waymark-edit-image",e)).innerHTML='',n.setAttribute("title",waymark_js.lang.add_photo_title),n.onclick=function(){if(void 0!==wp.media)return wp.media.editor.send.attachment=function(t,e){if(Waymark.debug(e),void 0===e.url)return!1;var i=new FormData;i.append("waymark_security",waymark_security),i.append("action","waymark_get_attatchment_meta"),i.append("attachment_id",e.id),jQuery.ajax({type:"POST",url:waymark_js.ajaxurl,data:i,dataType:"json",processData:!1,contentType:!1,success:function(t){if(Waymark.debug(t),null!==t){var i=Waymark.map.getCenter();(latlng=Waymark.get_exif_latlng(t))&&(i=latlng,Waymark.map.setView(i));var n=Waymark.get_image_sizes(e.sizes,e.url),o=Waymark.create_marker_json(i,n);Waymark.map_data.addData(o),Waymark.save_data_layer(),Waymark.map_was_edited()}else Waymark.message(waymark_js.lang.error_photo_meta,"error")}})},wp.media.editor.open(),!1;var t=jQuery("").attr({type:"file",name:"add_photo"}).css("display","none").change((function(){Waymark.handle_file_upload(jQuery(this))}));jQuery("#waymark-edit-toolbar").append(t),t.trigger("click")},(n=Waymark_L.DomUtil.create("a","waymark-edit-button waymark-edit-marker",e)).innerHTML='',n.setAttribute("title",waymark_js.lang.add_marker_title),n.onclick=function(){var t=Waymark.create_marker_json(Waymark.map.getCenter());Waymark.map_data.addData(t),Waymark.save_data_layer(),Waymark.map_was_edited()},(n=Waymark_L.DomUtil.create("a","waymark-edit-button waymark-edit-rectangle",e)).innerHTML='',n.setAttribute("title",waymark_js.lang.add_rectangle_title),n.onclick=function(){Waymark.map.editTools.startRectangle()},(n=Waymark_L.DomUtil.create("a","waymark-edit-button waymark-edit-polygon",e)).innerHTML='',n.setAttribute("title",waymark_js.lang.add_polygon_title),n.onclick=function(){Waymark.map.editTools.startPolygon()},(n=Waymark_L.DomUtil.create("a","waymark-edit-button waymark-edit-circle",e)).innerHTML='',n.setAttribute("title",waymark_js.lang.add_circle_title),n.onclick=function(){Waymark.map.editTools.startCircle()},void 0!==wp.media&&1==Waymark.get_property(waymark_settings,"misc","editor_options","media_library_uploads")){(n=Waymark_L.DomUtil.create("a","waymark-edit-button waymark-edit-upload",e)).innerHTML='',n.setAttribute("title",waymark_js.lang.upload_file_title),n.onclick=function(){return wp.media.editor.send.attachment=function(t,e){Waymark.debug(e),jQuery.ajax({type:"GET",url:e.url,dataType:"text",success:function(t){switch(e.mime){case"application/gpx+xml":Waymark.load_file_contents(t,"gpx");break;case"application/vnd.google-earth.kml+xml":Waymark.load_file_contents(t,"kml");break;case"application/geo+json":Waymark.load_file_contents(t,"geojson");break;default:Waymark.message(waymark_js.lang.error_file_upload)}}})},wp.media.editor.open(),!1}}else{var i=jQuery("").attr({type:"file",name:"add_file"}).css("display","none").change((function(){Waymark.handle_file_upload(jQuery(this))})),n=Waymark_L.DomUtil.create("a","waymark-edit-button waymark-edit-upload",e);jQuery("#waymark-edit-toolbar").append(i),n.innerHTML='',n.setAttribute("title",waymark_js.lang.upload_file_title),n.onclick=function(){i.trigger("click"),Waymark.map.editTools.stopDrawing()}}return e}});Waymark.map.addControl(new e)},this.handle_file_upload=function(t,e={}){Waymark=this,Waymark.loading_start();var i=new FormData;i.append("waymark_security",waymark_security),i.append("action","waymark_read_file"),i.append(t.attr("name"),t[0].files[0]),jQuery.ajax({type:"POST",url:waymark_js.ajaxurl,data:i,dataType:"json",processData:!1,contentType:!1,success:function(i){if(Waymark.debug(i),null===i)return Waymark.message(waymark_js.lang.error_file_upload,"error"),Waymark.loading_stop(),!1;if(i.error)return Waymark.message(i.error,"error"),Waymark.loading_stop(),!1;switch(t.attr("name")){case"add_file":Waymark.load_file_contents(i.file_contents,i.file_type);break;case"add_photo":if(void 0===i.url)return!1;var n=Waymark.map.getCenter();(latlng=Waymark.get_exif_latlng(i))&&(n=latlng,Waymark.map.setView(n));var o=Waymark.get_image_sizes(i.sizes,i.url),a=Waymark.create_marker_json(n,o);Waymark.map_data.addData(a),
-//!!! To-do - move this into Waymark.map_was_edited()
-Waymark.save_data_layer();break;case"marker_photo":if(void 0===i.url)return!1;o=Waymark.get_image_sizes(i.sizes,i.url);e.feature.properties=Object.assign({},e.feature.properties,o),e.img_view.attr("href",e.feature.properties.image_large_url),jQuery("img",e.img_view).attr("src",e.feature.properties.image_thumbnail_url),e.img_input.val(e.feature.properties.image_large_url),
-//!!! To-do - move this into Waymark.map_was_edited()
-Waymark.save_data_layer()}Waymark.map_was_edited(),Waymark.loading_stop()}})},this.build_content=function(t,e,i){Waymark=this;var n=jQuery(""),o=jQuery("").addClass("waymark-info");if("line"==t||"shape"==t){var a=jQuery("").html('').addClass("button").attr("title",waymark_js.lang.action_edit+" "+Waymark.title_case(waymark_js.lang["object_label_"+t])).on("click",(function(e){e.preventDefault();var n=jQuery(this),o=jQuery("i",n);return i.editEnabled()?(i.disableEdit(),n.attr("title",waymark_js.lang.action_edit+" "+Waymark.title_case(waymark_js.lang["object_label_"+t])),o.attr("class","ion-edit"),"function"==typeof Waymark.config.handle_edit_callback&&Waymark.config.handle_edit_callback(!1)):(i.enableEdit(),i.closePopup(),n.attr("title",waymark_js.lang.action_edit_done),o.attr("class","ion-android-done"),"function"==typeof Waymark.config.handle_edit_callback&&Waymark.config.handle_edit_callback(!0)),!1}));o.append(jQuery("").addClass("waymark-info-button waymark-info-edit waymark-"+t+"-edit").append(a))}a=jQuery("").html('').addClass("button").attr("title",waymark_js.lang.action_duplicate+" "+Waymark.title_case(waymark_js.lang["object_label_"+t])).on("click",(function(t){return t.preventDefault(),Waymark.load_json(Object.assign({},i.feature)),Waymark.map_was_edited(),!1}));o.append(jQuery("").addClass("waymark-info-button waymark-info-duplicate waymark-"+t+"-duplicate").append(a));a=jQuery("").html('').addClass("button").attr("title",waymark_js.lang.action_delete+" "+Waymark.title_case(waymark_js.lang["object_label_"+t])).on("click",(function(n){return n.preventDefault(),!("1"==Waymark.config.editor_options.confirm_delete&&!confirm(waymark_js.lang.action_delete_confirm+" "+Waymark.title_case(waymark_js.lang["object_label_"+t])+"?"))&&(Waymark.map.removeLayer(i),Waymark.map_data.removeLayer(i),Waymark.save_data_layer(),Waymark.map_was_edited(),"function"==typeof Waymark.config.handle_delete_callback&&Waymark.config.handle_delete_callback(e),!1)}));o.append(jQuery("").addClass("waymark-info-button waymark-info-delete waymark-"+t+"-delete").append(a));var r=Waymark.config[t+"_types"];if("line"==t){var s=jQuery("");s.append(jQuery("").val("").text(Waymark.title_case(waymark_js.lang.no_direction)),jQuery("").val("default").text(Waymark.title_case(waymark_js.lang.show_direction)),jQuery("").val("reverse").text(Waymark.title_case(waymark_js.lang.reverse_direction))),s.change((function(){jQuery("option:selected",jQuery(this));var t=jQuery(this).val();e.properties.direction=t,Waymark.draw_line_direction(i),Waymark.save_data_layer(),Waymark.map_was_edited()})),o.append(jQuery("").addClass("waymark-info-direction waymark-line-direction").append(s)),"string"==typeof e.properties.direction&&jQuery("option",s).filter((function(){return jQuery(this).val()==Waymark.make_key(e.properties.direction)})).attr("selected","selected")}var l=jQuery("");for(var h in l.append(jQuery("").attr({disabled:"disabled"}).text(Waymark.title_case(waymark_js.lang["object_label_"+t])+" "+waymark_js.lang.object_type_label+":")),r){var u=Waymark.make_key(r[h][t+"_title"]);l.append(jQuery("").val(u).text(r[h][t+"_title"]))}l.change((function(){jQuery("option:selected",jQuery(this));var n=jQuery(this).val();if(e.properties.type=n,"object"!=typeof n)var o=Waymark.get_type(t,e.properties.type);switch(t){case"line":i.setStyle({color:o.line_colour,weight:o.line_weight,opacity:o.line_opacity});break;case"shape":i.setStyle({color:o.shape_colour,fillOpacity:o.fill_opacity});break;case"marker":i.setIcon(Waymark_L.divIcon(Waymark.build_icon_data(o)))}Waymark.save_data_layer(),Waymark.map_was_edited()})),o.append(jQuery("").addClass("waymark-info-type waymark-"+t+"-type").append(l)),jQuery("option",l).filter((function(){return jQuery(this).val()==Waymark.make_key(e.properties.type)})).attr("selected","selected");var d=jQuery("").addClass("waymark-overlay-preview waymark-"+t+"-preview");for(var h in r){var c=r[h][t+"_title"],_=(u=Waymark.make_key(c),Waymark.get_type(t,u)),p=jQuery("").addClass("waymark-type").data("type_key",u).attr("title",c);switch(t){case"marker":var m=Waymark.build_icon_data(_);p.addClass(m.className).html(m.html).css({width:m.iconSize[0],height:m.iconSize[1]});break;case"line":p.addClass("waymark-line").append(jQuery("").css({margin:"15px 0",height:"1px",borderTop:_.line_weight+"px solid "+_.line_colour}));break;case"shape":p.addClass("waymark-shape").css({border:"3px solid "+_.shape_colour}).append(jQuery("").css({height:"20px",background:_.shape_colour,opacity:_.fill_opacity}))}var f=jQuery("").addClass("waymark-overlay-wrap waymark-"+t+"-wrap");"1"==Waymark.config.map_options.show_type_labels&&f.append(jQuery("").addClass("waymark-type-title").text(c)),f.append(p),f.on("click",(function(){var e=(p=jQuery(".waymark-type",jQuery(this))).data("type_key");jQuery("option",l).each((function(){p.val()==e?p.attr("selected","selected"):p.removeAttr("selected")})),l.val(e),l.trigger("change"),jQuery(".waymark-"+t+"-wrap",d).each((function(){p.removeClass("waymark-active")})),p.parent(".waymark-"+t+"-wrap").addClass("waymark-active")})),u==Waymark.make_key(e.properties.type)?(f.addClass("waymark-active"),d.prepend(f)):d.append(f)}for(key in o.append(d),Waymark.config[t+"_data_defaults"]){a=null;switch(key){case"title":a=jQuery("").attr({type:"text",value:e.properties.title,placeholder:Waymark.title_case(waymark_js.lang["object_label_"+t])+" "+waymark_js.lang.object_title_placeholder}).on("change",(function(){e.properties.title=jQuery(this).val(),Waymark.save_data_layer(),Waymark.map_was_edited()}));break;case"description":a=jQuery("").attr({id:"waymark-info-description",class:"wp-editor",placeholder:Waymark.title_case(waymark_js.lang["object_label_"+t])+" "+waymark_js.lang.object_description_placeholder}).val(e.properties.description).on("change",(function(){e.properties.description=jQuery(this).val(),Waymark.save_data_layer(),Waymark.map_was_edited()}));break;case"image_large_url":var g=jQuery("").attr({value:e.properties.image_large_url,placeholder:waymark_js.lang.object_image_placeholder}).on("change",(function(){e.properties.image_large_url=jQuery(this).val(),Waymark.save_data_layer(),Waymark.map_was_edited()}));if(void 0!==e.properties.image_thumbnail_url)var y=e.properties.image_thumbnail_url;else y=e.properties.image_large_url;var v=jQuery("
").attr({src:y,width:160});g.on("change",(function(){v.attr("src",jQuery(this).val())}));var k=jQuery("").attr({href:e.properties.image_large_url,target:"_blank"}).append(v).hover((function(){jQuery(this).addClass("waymark-hover")}),(function(){jQuery(this).removeClass("waymark-hover")})),L=jQuery("").text(waymark_js.lang.action_upload_image).attr({type:"submit",name:"add_photo",class:"waymark-input button button-small",id:"add_photo"}).on("click",(function(t){if(t.preventDefault(),void 0!==wp.media)return wp.media.editor.send.attachment=function(t,i){if(Waymark.debug(i),void 0===i.url)return!1;var n=Waymark.get_image_sizes(i.sizes,i.url);e.properties=Object.assign({},e.properties,n),k.attr("href",e.properties.image_large_url),jQuery("img",k).attr("src",e.properties.image_thumbnail_url),g.val(e.properties.image_large_url),Waymark.save_data_layer(),Waymark.map_was_edited()},wp.media.editor.open(),!1;var i=jQuery("").attr({type:"file",name:"marker_photo"}).css("display","none").change((function(){Waymark.handle_file_upload(jQuery(this),{feature:e,img_view:k,img_input:g})}));jQuery("#waymark-edit-toolbar").append(i),i.trigger("click")}));a=jQuery("").append(k,g,L)}a&&o.append(jQuery("").addClass("waymark-info-"+key+" waymark-"+t+"-info-"+key).append(a))}if("marker"==t&&void 0!==i.feature.geometry.coordinates){i.feature.geometry.coordinates;var w=i.feature.geometry.coordinates[1],b=i.feature.geometry.coordinates[0];"number"==typeof w&&(b=b.toFixed(6),w=w.toFixed(6)),a=jQuery("").html(""+waymark_js.lang.marker_latlng_label+": "+w+","+b),o.append(jQuery("").addClass("waymark-info-latlng waymark-marker-info-latlng").append(a))}return o.children().length&&n.append(o),n},this.info_window=function(t,e,i){Waymark=this;var n=Waymark.title_case(waymark_js.lang.action_edit+" "+t);if("function"==typeof Waymark.config.handle_content_callback)i.on("click",(function(){var o=Waymark.build_content(t,e,i);Waymark.config.handle_content_callback(o.get(0),n,Waymark.mode)}));else{var o=Waymark.build_content(t,e,i).get(0);i.bindPopup(o,{}).openPopup().on("click",(function(){}))}},this.load_file_contents=function(t,e){switch(Waymark=this,t=t.trim(),e=e.toLowerCase()){case"gpx":var i=(new DOMParser).parseFromString(t,"text/xml"),n=toGeoJSON.gpx(i);break;case"kml":var o=(new DOMParser).parseFromString(t,"text/xml");n=toGeoJSON.kml(o);break;case"json":case"geojson":n=JSON.parse(t);break;default:Waymark.message(waymark_js.lang.error_file_type,"error")}void 0!==n?this.load_json(n):Waymark.message(waymark_js.lang.error_file_conversion,"error")},this.load_json=function(t){if(Waymark=this,"object"==typeof t){Waymark.map_data.addData(t),Waymark.save_data_layer();var e=Waymark.map_data.getBounds();e.isValid()&&Waymark.map.fitBounds(e)}}}function Waymark_Map_Factory(){this.instances=[],this.viewer=function(){var t=Object.assign(new Waymark_Map,new Waymark_Map_Viewer);return this.instances.push(t),t},this.editor=function(){var t=Object.assign(new Waymark_Map,new Waymark_Map_Editor);return this.instances.push(t),t}}window.Waymark_Map_Factory=new Waymark_Map_Factory;
\ No newline at end of file
+!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.L={})}(this,function(t){var e=Object.freeze;function n(t){var e,n,a,s;for(n=1,a=arguments.length;n=this.min.x&&n.x<=this.max.x&&e.y>=this.min.y&&n.y<=this.max.y},intersects:function(t){t=Z(t);var e=this.min,n=this.max,a=t.min,s=t.max,r=s.x>=e.x&&a.x<=n.x,l=s.y>=e.y&&a.y<=n.y;return r&&l},overlaps:function(t){t=Z(t);var e=this.min,n=this.max,a=t.min,s=t.max,r=s.x>e.x&&a.xe.y&&a.y=a.lat&&n.lat<=s.lat&&e.lng>=a.lng&&n.lng<=s.lng},intersects:function(t){t=j(t);var e=this._southWest,n=this._northEast,a=t.getSouthWest(),s=t.getNorthEast(),r=s.lat>=e.lat&&a.lat<=n.lat,l=s.lng>=e.lng&&a.lng<=n.lng;return r&&l},overlaps:function(t){t=j(t);var e=this._southWest,n=this._northEast,a=t.getSouthWest(),s=t.getNorthEast(),r=s.lat>e.lat&&a.late.lng&&a.lng';var e=t.firstChild;return e.style.behavior="url(#default#VML)",e&&"object"==typeof e.adj}catch(n){return!1}}();function tE(t){return 0<=navigator.userAgent.toLowerCase().indexOf(t)}var tM=(Object.freeze||Object)({ie:ti,ielt9:tn,edge:to,webkit:ta,android:ts,android23:tr,androidStock:th,opera:tc,chrome:td,gecko:tu,safari:t8,phantom:tp,opera12:tm,win:tf,ie3d:tg,webkit3d:ty,gecko3d:tv,any3d:tL,mobile:tk,mobileWebkit:tk&&ta,mobileWebkit3d:tk&&ty,msPointer:tw,pointer:tx,touch:t$,mobileOpera:tb,mobileGecko:tk&&tu,retina:tC,canvas:tP,svg:t_,vml:tT}),tS=tw?"MSPointerDown":"pointerdown",tz=tw?"MSPointerMove":"pointermove",tD=tw?"MSPointerUp":"pointerup",tW=tw?"MSPointerCancel":"pointercancel",tA=["INPUT","SELECT","OPTION"],tO={},tB=!1,tI=0;function tZ(t){tO[t.pointerId]=t,tI++}function tF(t){tO[t.pointerId]&&(tO[t.pointerId]=t)}function tj(t){delete tO[t.pointerId],tI--}function tR(t,e){for(var n in t.touches=[],tO)t.touches.push(tO[n]);t.changedTouches=[t],e(t)}var tN,tG,t0,tU,tH,tV=tw?"MSPointerDown":tx?"pointerdown":"touchstart",t1=tw?"MSPointerUp":tx?"pointerup":"touchend",t3="_leaflet_",tq=eo(["transform","webkitTransform","OTransform","MozTransform","msTransform"]),t4=eo(["webkitTransition","transition","OTransition","MozTransition","msTransition"]),t2="webkitTransition"===t4||"OTransition"===t4?t4+"End":"transitionend";function t6(t){return"string"==typeof t?document.getElementById(t):t}function tX(t,e){var n=t.style[e]||t.currentStyle&&t.currentStyle[e];if((!n||"auto"===n)&&document.defaultView){var a=document.defaultView.getComputedStyle(t,null);n=a?a[e]:null}return"auto"===n?null:n}function tK(t,e,n){var a=document.createElement(t);return a.className=e||"",n&&n.appendChild(a),a}function t5(t){var e=t.parentNode;e&&e.removeChild(t)}function tJ(t){for(;t.firstChild;)t.removeChild(t.firstChild)}function tY(t){var e=t.parentNode;e&&e.lastChild!==t&&e.appendChild(t)}function t7(t){var e=t.parentNode;e&&e.firstChild!==t&&e.insertBefore(t,e.firstChild)}function tQ(t,e){if(void 0!==t.classList)return t.classList.contains(e);var n=ei(t);return 0tA.indexOf(t.target.tagName)))return;e$(t)}tR(t,h)}),l["_leaflet_touchstart"+c]=d,l.addEventListener(tS,d,!1),tB||(document.documentElement.addEventListener(tS,tZ,!0),document.documentElement.addEventListener(tz,tF,!0),document.documentElement.addEventListener(tD,tj,!0),document.documentElement.addEventListener(tW,tj,!0),tB=!0)):"touchmove"===n?(u=e,p=a,m=s,f=function(t){(t.pointerType!==t.MSPOINTER_TYPE_MOUSE&&"mouse"!==t.pointerType||0!==t.buttons)&&tR(t,p)},u["_leaflet_touchmove"+m]=f,u.addEventListener(tz,f,!1)):"touchend"===n&&(g=e,y=a,v=s,k=function(t){tR(t,y)},g["_leaflet_touchend"+v]=k,g.addEventListener(tD,k,!1),g.addEventListener(tW,k,!1)),this}(t,e,l,s):!t$||"dblclick"!==e||tx&&td?"addEventListener"in t?"mousewheel"===e?t.addEventListener("onwheel"in t?"wheel":"mousewheel",l,!1):"mouseenter"===e||"mouseleave"===e?(l=function(e){ez(t,e=e||window.event)&&c(e)},t.addEventListener("mouseenter"===e?"mouseover":"mouseout",l,!1)):("click"===e&&ts&&(l=function(t){!function(t,e){var n=t.timeStamp||t.originalEvent&&t.originalEvent.timeStamp,a=eT&&n-eT;if(a&&100Math.abs(t.detail)?-(20*t.detail):t.detail?-(60*(t.detail/32765)):0}var eT,eE={};function eM(t){eE[t.type]=!0}function eS(t){var e=eE[t.type];return eE[t.type]=!1,e}function ez(t,e){var n=e.relatedTarget;if(!n)return!0;try{for(;n&&n!==t;)n=n.parentNode}catch(a){return!1}return n!==t}var eD=(Object.freeze||Object)({on:ef,off:ey,stopPropagation:ek,disableScrollPropagation:ew,disableClickPropagation:ex,preventDefault:e$,stop:eb,getMousePosition:eC,getWheelDelta:e_,fakeStop:eM,skipped:eS,isExternalTarget:ez,addListener:ef,removeListener:ey}),eW=W.extend({run:function(t,e,n,a){this.stop(),this._el=t,this._inProgress=!0,this._duration=n||.25,this._easeOutPower=1/Math.max(a||.5,.2),this._startPos=er(t),this._offset=e.subtract(this._startPos),this._startTime=+new Date,this.fire("start"),this._animate()},stop:function(){this._inProgress&&(this._step(!0),this._complete())},_animate:function(){this._animId=E(this._animate,this),this._step()},_step:function(t){var e=+new Date-this._startTime,n=1e3*this._duration;ethis.options.maxZoom)?this.setZoom(t):this},panInsideBounds:function(t,e){this._enforcingBounds=!0;var n=this.getCenter(),a=this._limitCenter(n,this._zoom,j(t));return n.equals(a)||this.panTo(a,e),this._enforcingBounds=!1,this},panInside:function(t,e){var n=B((e=e||{}).paddingTopLeft||e.padding||[0,0]),a=B(e.paddingBottomRight||e.padding||[0,0]),s=this.getCenter(),r=this.project(s),l=this.project(t),h=this.getPixelBounds(),c=h.getSize().divideBy(2),d=Z([h.min.add(n),h.max.subtract(a)]);if(!d.contains(l)){this._enforcingBounds=!0;var u=r.subtract(l),p=B(l.x+u.x,l.y+u.y);(l.xd.max.x)&&(p.x=r.x-u.x,0d.max.y)&&(p.y=r.y-u.y,0=this.options.transform3DLimit&&this._resetView(this.getCenter(),this.getZoom())},_findEventTargets:function(t,e){for(var n,a=[],s="mouseout"===e||"mouseover"===e,r=t.target||t.srcElement,l=!1;r;){if((n=this._targets[h(r)])&&("click"===e||"preclick"===e)&&!t._simulated&&this._draggableMoved(n)){l=!0;break}if(n&&n.listens(e,!0)&&(s&&!ez(r,t)||(a.push(n),s))||r===this._container)break;r=r.parentNode}return a.length||l||s||!ez(r,t)||(a=[this]),a},_handleDOMEvent:function(t){if(this._loaded&&!eS(t)){var e=t.type;"mousedown"!==e&&"keypress"!==e&&"keyup"!==e&&"keydown"!==e||ed(t.target||t.srcElement),this._fireDOMEvent(t,e)}},_mouseEvents:["click","dblclick","mouseover","mouseout","contextmenu"],_fireDOMEvent:function(t,e,a){if("click"===t.type){var s=n({},t);s.type="preclick",this._fireDOMEvent(s,s.type,a)}if(!t._stopped&&(a=(a||[]).concat(this._findEventTargets(t,e))).length){var r=a[0];"contextmenu"===e&&r.listens(e,!0)&&e$(t);var l={originalEvent:t};if("keypress"!==t.type&&"keydown"!==t.type&&"keyup"!==t.type){var h=r.getLatLng&&(!r._radius||r._radius<=10);l.containerPoint=h?this.latLngToContainerPoint(r.getLatLng()):this.mouseEventToContainerPoint(t),l.layerPoint=this.containerPointToLayerPoint(l.containerPoint),l.latlng=h?r.getLatLng():this.layerPointToLatLng(l.layerPoint)}for(var c=0;cthis.options.zoomAnimationThreshold)return!1;var a=this.getZoomScale(e),s=this._getCenterOffset(t)._divideBy(1-1/a);return!(!0!==n.animate&&!this.getSize().contains(s))&&(E(function(){this._moveStart(!0,!1)._animateZoom(t,e,!0)},this),!0)},_animateZoom:function(t,e,n,a){this._mapPane&&(n&&(this._animatingZoom=!0,this._animateToCenter=t,this._animateToZoom=e,t9(this._mapPane,"leaflet-zoom-anim")),this.fire("zoomanim",{center:t,zoom:e,noUpdate:a}),setTimeout(r(this._onZoomTransitionEnd,this),250))},_onZoomTransitionEnd:function(){this._animatingZoom&&(this._mapPane&&et(this._mapPane,"leaflet-zoom-anim"),this._animatingZoom=!1,this._move(this._animateToCenter,this._animateToZoom),E(function(){this._moveEnd(!0)},this))}});function eO(t){return new eB(t)}var eB=z.extend({options:{position:"topright"},initialize:function(t){g(this,t)},getPosition:function(){return this.options.position},setPosition:function(t){var e=this._map;return e&&e.removeControl(this),this.options.position=t,e&&e.addControl(this),this},getContainer:function(){return this._container},addTo:function(t){this.remove(),this._map=t;var e=this._container=this.onAdd(t),n=this.getPosition(),a=t._controlCorners[n];return t9(e,"leaflet-control"),-1!==n.indexOf("bottom")?a.insertBefore(e,a.firstChild):a.appendChild(e),this._map.on("unload",this.remove,this),this},remove:function(){return this._map&&(t5(this._container),this.onRemove&&this.onRemove(this._map),this._map.off("unload",this.remove,this),this._map=null),this},_refocusOnMap:function(t){this._map&&t&&0",n.firstChild},_addItem:function(t){var e,n=document.createElement("label"),a=this._map.hasLayer(t.layer);t.overlay?((e=document.createElement("input")).type="checkbox",e.className="leaflet-control-layers-selector",e.defaultChecked=a):e=this._createRadioElement("leaflet-base-layers_"+h(this),a),this._layerControlInputs.push(e),e.layerId=h(t.layer),ef(e,"click",this._onInputClick,this);var s=document.createElement("span");s.innerHTML=" "+t.name;var r=document.createElement("div");return n.appendChild(r),r.appendChild(e),r.appendChild(s),(t.overlay?this._overlaysList:this._baseLayersList).appendChild(n),this._checkDisabledLayers(),n},_onInputClick:function(){var t,e,n=this._layerControlInputs,a=[],s=[];this._handlingClick=!0;for(var r=n.length-1;0<=r;r--)t=n[r],e=this._getLayer(t.layerId).layer,t.checked?a.push(e):t.checked||s.push(e);for(r=0;re.options.maxZoom},_expandIfNotCollapsed:function(){return this._map&&!this.options.collapsed&&this.expand(),this},_expand:function(){return this.expand()},_collapse:function(){return this.collapse()}}),eZ=eB.extend({options:{position:"topleft",zoomInText:"+",zoomInTitle:"Zoom in",zoomOutText:"−",zoomOutTitle:"Zoom out"},onAdd:function(t){var e="leaflet-control-zoom",n=tK("div",e+" leaflet-bar"),a=this.options;return this._zoomInButton=this._createButton(a.zoomInText,a.zoomInTitle,e+"-in",n,this._zoomIn),this._zoomOutButton=this._createButton(a.zoomOutText,a.zoomOutTitle,e+"-out",n,this._zoomOut),this._updateDisabled(),t.on("zoomend zoomlevelschange",this._updateDisabled,this),n},onRemove:function(t){t.off("zoomend zoomlevelschange",this._updateDisabled,this)},disable:function(){return this._disabled=!0,this._updateDisabled(),this},enable:function(){return this._disabled=!1,this._updateDisabled(),this},_zoomIn:function(t){!this._disabled&&this._map._zoomthis._map.getMinZoom()&&this._map.zoomOut(this._map.options.zoomDelta*(t.shiftKey?3:1))},_createButton:function(t,e,n,a,s){var r=tK("a",n,a);return r.innerHTML=t,r.href="#",r.title=e,r.setAttribute("role","button"),r.setAttribute("aria-label",e),ex(r),ef(r,"click",eb),ef(r,"click",s,this),ef(r,"click",this._refocusOnMap,this),r},_updateDisabled:function(){var t=this._map,e="leaflet-disabled";et(this._zoomInButton,e),et(this._zoomOutButton,e),(this._disabled||t._zoom===t.getMinZoom())&&t9(this._zoomOutButton,e),(this._disabled||t._zoom===t.getMaxZoom())&&t9(this._zoomInButton,e)}});eA.mergeOptions({zoomControl:!0}),eA.addInitHook(function(){this.options.zoomControl&&(this.zoomControl=new eZ,this.addControl(this.zoomControl))});var eF=eB.extend({options:{position:"bottomleft",maxWidth:100,metric:!0,imperial:!0},onAdd:function(t){var e="leaflet-control-scale",n=tK("div",e),a=this.options;return this._addScales(a,e+"-line",n),t.on(a.updateWhenIdle?"moveend":"move",this._update,this),t.whenReady(this._update,this),n},onRemove:function(t){t.off(this.options.updateWhenIdle?"moveend":"move",this._update,this)},_addScales:function(t,e,n){t.metric&&(this._mScale=tK("div",e,n)),t.imperial&&(this._iScale=tK("div",e,n))},_update:function(){var t=this._map,e=t.getSize().y/2,n=t.distance(t.containerPointToLatLng([0,e]),t.containerPointToLatLng([this.options.maxWidth,e]));this._updateScales(n)},_updateScales:function(t){this.options.metric&&t&&this._updateMetric(t),this.options.imperial&&t&&this._updateImperial(t)},_updateMetric:function(t){var e=this._getRoundNum(t);this._updateScale(this._mScale,e<1e3?e+" m":e/1e3+" km",e/t)},_updateImperial:function(t){var e,n,a,s=3.2808399*t;5280Leaflet'},initialize:function(t){g(this,t),this._attributions={}},onAdd:function(t){for(var e in(t.attributionControl=this)._container=tK("div","leaflet-control-attribution"),ex(this._container),t._layers)t._layers[e].getAttribution&&this.addAttribution(t._layers[e].getAttribution());return this._update(),this._container},setPrefix:function(t){return this.options.prefix=t,this._update(),this},addAttribution:function(t){return t&&(this._attributions[t]||(this._attributions[t]=0),this._attributions[t]++,this._update()),this},removeAttribution:function(t){return t&&this._attributions[t]&&(this._attributions[t]--,this._update()),this},_update:function(){if(this._map){var t=[];for(var e in this._attributions)this._attributions[e]&&t.push(e);var n=[];this.options.prefix&&n.push(this.options.prefix),t.length&&n.push(t.join(", ")),this._container.innerHTML=n.join(" | ")}}});eA.mergeOptions({attributionControl:!0}),eA.addInitHook(function(){this.options.attributionControl&&(new ej).addTo(this)}),eB.Layers=eI,eB.Zoom=eZ,eB.Scale=eF,eB.Attribution=ej,eO.layers=function(t,e,n){return new eI(t,e,n)},eO.zoom=function(t){return new eZ(t)},eO.scale=function(t){return new eF(t)},eO.attribution=function(t){return new ej(t)};var eR=z.extend({initialize:function(t){this._map=t},enable:function(){return this._enabled||(this._enabled=!0,this.addHooks()),this},disable:function(){return this._enabled&&(this._enabled=!1,this.removeHooks()),this},enabled:function(){return!!this._enabled}});eR.addTo=function(t,e){return t.addHandler(e,this),this};var eN,eG=t$?"touchstart mousedown":"mousedown",e0={mousedown:"mouseup",touchstart:"touchend",pointerdown:"touchend",MSPointerDown:"touchend"},eU={mousedown:"mousemove",touchstart:"touchmove",pointerdown:"touchmove",MSPointerDown:"touchmove"},eH=W.extend({options:{clickTolerance:3},initialize:function(t,e,n,a){g(this,a),this._element=t,this._dragStartTarget=e||t,this._preventOutline=n},enable:function(){this._enabled||(ef(this._dragStartTarget,eG,this._onDown,this),this._enabled=!0)},disable:function(){this._enabled&&(eH._dragging===this&&this.finishDrag(),ey(this._dragStartTarget,eG,this._onDown,this),this._enabled=!1,this._moved=!1)},_onDown:function(t){if(!t._simulated&&this._enabled&&(this._moved=!1,!tQ(this._element,"leaflet-zoom-anim")&&!(eH._dragging||t.shiftKey||1!==t.which&&1!==t.button&&!t.touches||((eH._dragging=this)._preventOutline&&ed(this._element),eh(),tN(),this._moving)))){this.fire("down");var e=t.touches?t.touches[0]:t,n=e8(this._element);this._startPoint=new A(e.clientX,e.clientY),this._parentScale=ep(n),ef(document,eU[t.type],this._onMove,this),ef(document,e0[t.type],this._onUp,this)}},_onMove:function(t){if(!t._simulated&&this._enabled){if(t.touches&&1e.max.x&&(n|=2),t.ye.max.y&&(n|=8),n}function e2(t,e,n,a){var s,r=e.x,l=e.y,h=n.x-r,c=n.y-l,d=h*h+c*c;return 0this._layersMaxZoom&&this.setZoom(this._layersMaxZoom),void 0===this.options.minZoom&&this._layersMinZoom&&this.getZoom()t.y!=a.y>t.y&&t.x<(a.x-n.x)*(t.y-n.y)/(a.y-n.y)+n.x&&(d=!d);return d||ip.prototype._containsPoint.call(this,t,!0)}}),ig=is.extend({initialize:function(t,e){g(this,e),this._layers={},t&&this.addData(t)},addData:function(t){var e,n,a,s=w(t)?t:t.features;if(s){for(e=0,n=s.length;ed.x&&(u=r.x+a-d.x+c.x),r.x-u-h.x<0&&(u=r.x-h.x),r.y+n+c.y>d.y&&(p=r.y+n-d.y+c.y),r.y-p-h.y<0&&(p=r.y-h.y),(u||p)&&t.fire("autopanstart").panBy([u,p])}},_onCloseButtonClick:function(t){this._close(),eb(t)},_getAnchor:function(){return B(this._source&&this._source._getPopupAnchor?this._source._getPopupAnchor():[0,0])}});eA.mergeOptions({closePopupOnClick:!0}),eA.include({openPopup:function(t,e,n){return t instanceof iM||(t=new iM(n).setContent(t)),e&&t.setLatLng(e),this.hasLayer(t)?this:(this._popup&&this._popup.options.autoClose&&this.closePopup(),this._popup=t,this.addLayer(t))},closePopup:function(t){return t&&t!==this._popup||(t=this._popup,this._popup=null),t&&this.removeLayer(t),this}}),io.include({bindPopup:function(t,e){return t instanceof iM?(g(t,e),(this._popup=t)._source=this):(this._popup&&!e||(this._popup=new iM(e,this)),this._popup.setContent(t)),this._popupHandlersAdded||(this.on({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!0),this},unbindPopup:function(){return this._popup&&(this.off({click:this._openPopup,keypress:this._onKeyPress,remove:this.closePopup,move:this._movePopup}),this._popupHandlersAdded=!1,this._popup=null),this},openPopup:function(t,e){return this._popup&&this._map&&(e=this._popup._prepareOpen(this,t,e),this._map.openPopup(this._popup,e)),this},closePopup:function(){return this._popup&&this._popup._close(),this},togglePopup:function(t){return this._popup&&(this._popup._map?this.closePopup():this.openPopup(t)),this},isPopupOpen:function(){return!!this._popup&&this._popup.isOpen()},setPopupContent:function(t){return this._popup&&this._popup.setContent(t),this},getPopup:function(){return this._popup},_openPopup:function(t){var e=t.layer||t.target;this._popup&&this._map&&(eb(t),e instanceof id?this.openPopup(t.layer||t.target,t.latlng):this._map.hasLayer(this._popup)&&this._popup._source===e?this.closePopup():this.openPopup(e,t.latlng))},_movePopup:function(t){this._popup.setLatLng(t.latlng)},_onKeyPress:function(t){13===t.originalEvent.keyCode&&this._openPopup(t)}});var iS=iE.extend({options:{pane:"tooltipPane",offset:[0,0],direction:"auto",permanent:!1,sticky:!1,interactive:!1,opacity:.9},onAdd:function(t){iE.prototype.onAdd.call(this,t),this.setOpacity(this.options.opacity),t.fire("tooltipopen",{tooltip:this}),this._source&&this._source.fire("tooltipopen",{tooltip:this},!0)},onRemove:function(t){iE.prototype.onRemove.call(this,t),t.fire("tooltipclose",{tooltip:this}),this._source&&this._source.fire("tooltipclose",{tooltip:this},!0)},getEvents:function(){var t=iE.prototype.getEvents.call(this);return t$&&!this.options.permanent&&(t.preclick=this._close),t},_close:function(){this._map&&this._map.closeTooltip(this)},_initLayout:function(){var t="leaflet-tooltip "+(this.options.className||"")+" leaflet-zoom-"+(this._zoomAnimated?"animated":"hide");this._contentNode=this._container=tK("div",t)},_updateLayout:function(){},_adjustPan:function(){},_setPosition:function(t){var e=this._map,n=this._container,a=e.latLngToContainerPoint(e.getCenter()),s=e.layerPointToContainerPoint(t),r=this.options.direction,l=n.offsetWidth,h=n.offsetHeight,c=B(this.options.offset),d=this._getAnchor();t="top"===r?t.add(B(-l/2+c.x,-h+c.y+d.y,!0)):"bottom"===r?t.subtract(B(l/2-c.x,-c.y,!0)):"center"===r?t.subtract(B(l/2+c.x,h/2-d.y+c.y,!0)):"right"===r||"auto"===r&&s.xthis.options.maxZoom||nthis.options.maxZoom||void 0!==this.options.minZoom&&sn.max.x)||!e.wrapLat&&(t.yn.max.y))return!1}if(!this.options.bounds)return!0;var a=this._tileCoordsToBounds(t);return j(this.options.bounds).overlaps(a)},_keyToBounds:function(t){return this._tileCoordsToBounds(this._keyToTileCoords(t))},_tileCoordsToNwSe:function(t){var e=this._map,n=this.getTileSize(),a=t.scaleBy(n),s=a.add(n);return[e.unproject(a,t.z),e.unproject(s,t.z)]},_tileCoordsToBounds:function(t){var e=this._tileCoordsToNwSe(t),n=new F(e[0],e[1]);return this.options.noWrap||(n=this._map.wrapLatLngBounds(n)),n},_tileCoordsToKey:function(t){return t.x+":"+t.y+":"+t.z},_keyToTileCoords:function(t){var e=t.split(":"),n=new A(+e[0],+e[1]);return n.z=+e[2],n},_removeTile:function(t){var e=this._tiles[t];e&&(t5(e.el),delete this._tiles[t],this.fire("tileunload",{tile:e.el,coords:this._keyToTileCoords(t)}))},_initTile:function(t){t9(t,"leaflet-tile");var e=this.getTileSize();t.style.width=e.x+"px",t.style.height=e.y+"px",t.onselectstart=u,t.onmousemove=u,tn&&this.options.opacity<1&&en(t,this.options.opacity),ts&&!tr&&(t.style.WebkitBackfaceVisibility="hidden")},_addTile:function(t,e){var n=this._getTilePos(t),a=this._tileCoordsToKey(t),s=this.createTile(this._wrapCoords(t),r(this._tileReady,this,t));this._initTile(s),this.createTile.length<2&&E(r(this._tileReady,this,t,null,s)),es(s,n),this._tiles[a]={el:s,coords:t,current:!0},e.appendChild(s),this.fire("tileloadstart",{tile:s,coords:t})},_tileReady:function(t,e,n){e&&this.fire("tileerror",{error:e,tile:n,coords:t});var a=this._tileCoordsToKey(t);(n=this._tiles[a])&&(n.loaded=+new Date,this._map._fadeAnimated?(en(n.el,0),M(this._fadeFrame),this._fadeFrame=E(this._updateOpacity,this)):(n.active=!0,this._pruneTiles()),e||(t9(n.el,"leaflet-tile-loaded"),this.fire("tileload",{tile:n.el,coords:t})),this._noTilesToLoad()&&(this._loading=!1,this.fire("load"),tn||!this._map._fadeAnimated?E(this._pruneTiles,this):setTimeout(r(this._pruneTiles,this),250)))},_getTilePos:function(t){return t.scaleBy(this.getTileSize()).subtract(this._level.origin)},_wrapCoords:function(t){var e=new A(this._wrapX?d(t.x,this._wrapX):t.x,this._wrapY?d(t.y,this._wrapY):t.y);return e.z=t.z,e},_pxBoundsToTileRange:function(t){var e=this.getTileSize();return new I(t.min.unscaleBy(e).floor(),t.max.unscaleBy(e).ceil().subtract([1,1]))},_noTilesToLoad:function(){for(var t in this._tiles)if(!this._tiles[t].loaded)return!1;return!0}}),iW=iD.extend({options:{minZoom:0,maxZoom:18,subdomains:"abc",errorTileUrl:"",zoomOffset:0,tms:!1,zoomReverse:!1,detectRetina:!1,crossOrigin:!1},initialize:function(t,e){this._url=t,(e=g(this,e)).detectRetina&&tC&&0')}}catch(t){return function(t){return document.createElement("<"+t+' xmlns="urn:schemas-microsoft.com:vml" class="lvml">')}}}(),ij=tT?iF:Q,iR=iB.extend({getEvents:function(){var t=iB.prototype.getEvents.call(this);return t.zoomstart=this._onZoomStart,t},_initContainer:function(){this._container=ij("svg"),this._container.setAttribute("pointer-events","none"),this._rootGroup=ij("g"),this._container.appendChild(this._rootGroup)},_destroyContainer:function(){t5(this._container),ey(this._container),delete this._container,delete this._rootGroup,delete this._svgSize},_onZoomStart:function(){this._update()},_update:function(){if(!this._map._animatingZoom||!this._bounds){iB.prototype._update.call(this);var t=this._bounds,e=t.getSize(),n=this._container;this._svgSize&&this._svgSize.equals(e)||(this._svgSize=e,n.setAttribute("width",e.x),n.setAttribute("height",e.y)),es(n,t.min),n.setAttribute("viewBox",[t.min.x,t.min.y,e.x,e.y].join(" ")),this.fire("update")}},_initPath:function(t){var e=t._path=ij("path");t.options.className&&t9(e,t.options.className),t.options.interactive&&t9(e,"leaflet-interactive"),this._updateStyle(t),this._layers[h(t)]=t},_addPath:function(t){this._rootGroup||this._initContainer(),this._rootGroup.appendChild(t._path),t.addInteractiveTarget(t._path)},_removePath:function(t){t5(t._path),t.removeInteractiveTarget(t._path),delete this._layers[h(t)]},_updatePath:function(t){t._project(),t._update()},_updateStyle:function(t){var e=t._path,n=t.options;e&&(n.stroke?(e.setAttribute("stroke",n.color),e.setAttribute("stroke-opacity",n.opacity),e.setAttribute("stroke-width",n.weight),e.setAttribute("stroke-linecap",n.lineCap),e.setAttribute("stroke-linejoin",n.lineJoin),n.dashArray?e.setAttribute("stroke-dasharray",n.dashArray):e.removeAttribute("stroke-dasharray"),n.dashOffset?e.setAttribute("stroke-dashoffset",n.dashOffset):e.removeAttribute("stroke-dashoffset")):e.setAttribute("stroke","none"),n.fill?(e.setAttribute("fill",n.fillColor||n.color),e.setAttribute("fill-opacity",n.fillOpacity),e.setAttribute("fill-rule",n.fillRule||"evenodd")):e.setAttribute("fill","none"))},_updatePoly:function(t,e){this._setPath(t,tt(t._parts,e))},_updateCircle:function(t){var e=t._point,n=Math.max(Math.round(t._radius),1),a="a"+n+","+(Math.max(Math.round(t._radiusY),1)||n)+" 0 1,0 ",s=t._empty()?"M0 0":"M"+(e.x-n)+","+e.y+a+2*n+",0 "+a+-(2*n)+",0 ";this._setPath(t,s)},_setPath:function(t,e){t._path.setAttribute("d",e)},_bringToFront:function(t){tY(t._path)},_bringToBack:function(t){t7(t._path)}});function iN(t){return t_||tT?new iR(t):null}tT&&iR.include({_initContainer:function(){this._container=tK("div","leaflet-vml-container")},_update:function(){this._map._animatingZoom||(iB.prototype._update.call(this),this.fire("update"))},_initPath:function(t){var e=t._container=iF("shape");t9(e,"leaflet-vml-shape "+(this.options.className||"")),e.coordsize="1 1",t._path=iF("path"),e.appendChild(t._path),this._updateStyle(t),this._layers[h(t)]=t},_addPath:function(t){var e=t._container;this._container.appendChild(e),t.options.interactive&&t.addInteractiveTarget(e)},_removePath:function(t){var e=t._container;t5(e),t.removeInteractiveTarget(e),delete this._layers[h(t)]},_updateStyle:function(t){var e=t._stroke,n=t._fill,a=t.options,s=t._container;s.stroked=!!a.stroke,s.filled=!!a.fill,a.stroke?(e||(e=t._stroke=iF("stroke")),s.appendChild(e),e.weight=a.weight+"px",e.color=a.color,e.opacity=a.opacity,a.dashArray?e.dashStyle=w(a.dashArray)?a.dashArray.join(" "):a.dashArray.replace(/( *, *)/g," "):e.dashStyle="",e.endcap=a.lineCap.replace("butt","flat"),e.joinstyle=a.lineJoin):e&&(s.removeChild(e),t._stroke=null),a.fill?(n||(n=t._fill=iF("fill")),s.appendChild(n),n.color=a.fillColor||a.color,n.opacity=a.fillOpacity):n&&(s.removeChild(n),t._fill=null)},_updateCircle:function(t){var e=t._point.round(),n=Math.round(t._radius),a=Math.round(t._radiusY||n);this._setPath(t,t._empty()?"M0 0":"AL "+e.x+","+e.y+" "+n+","+a+" 0,23592600")},_setPath:function(t,e){t._path.v=e},_bringToFront:function(t){tY(t._container)},_bringToBack:function(t){t7(t._container)}}),eA.include({getRenderer:function(t){var e=t.options.renderer||this._getPaneRenderer(t.options.pane)||this.options.renderer||this._renderer;return e||(e=this._renderer=this._createRenderer()),this.hasLayer(e)||this.addLayer(e),e},_getPaneRenderer:function(t){if("overlayPane"===t||void 0===t)return!1;var e=this._paneRenderers[t];return void 0===e&&(e=this._createRenderer({pane:t}),this._paneRenderers[t]=e),e},_createRenderer:function(t){return this.options.preferCanvas&&iZ(t)||iN(t)}});var iG=im.extend({initialize:function(t,e){im.prototype.initialize.call(this,this._boundsToLatLngs(t),e)},setBounds:function(t){return this.setLatLngs(this._boundsToLatLngs(t))},_boundsToLatLngs:function(t){return[(t=j(t)).getSouthWest(),t.getNorthWest(),t.getNorthEast(),t.getSouthEast()]}});iR.create=ij,iR.pointsToPath=tt,ig.geometryToLayer=iy,ig.coordsToLatLng=iv,ig.coordsToLatLngs=iL,ig.latLngToCoords=ik,ig.latLngsToCoords=iw,ig.getFeature=ix,ig.asFeature=i$,eA.mergeOptions({boxZoom:!0});var i0=eR.extend({initialize:function(t){this._map=t,this._container=t._container,this._pane=t._panes.overlayPane,this._resetStateTimeout=0,t.on("unload",this._destroy,this)},addHooks:function(){ef(this._container,"mousedown",this._onMouseDown,this)},removeHooks:function(){ey(this._container,"mousedown",this._onMouseDown,this)},moved:function(){return this._moved},_destroy:function(){t5(this._pane),delete this._pane},_resetState:function(){this._resetStateTimeout=0,this._moved=!1},_clearDeferredResetState:function(){0!==this._resetStateTimeout&&(clearTimeout(this._resetStateTimeout),this._resetStateTimeout=0)},_onMouseDown:function(t){if(!t.shiftKey||1!==t.which&&1!==t.button)return!1;this._clearDeferredResetState(),this._resetState(),tN(),eh(),this._startPoint=this._map.mouseEventToContainerPoint(t),ef(document,{contextmenu:eb,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseMove:function(t){this._moved||(this._moved=!0,this._box=tK("div","leaflet-zoom-box",this._container),t9(this._container,"leaflet-crosshair"),this._map.fire("boxzoomstart")),this._point=this._map.mouseEventToContainerPoint(t);var e=new I(this._point,this._startPoint),n=e.getSize();es(this._box,e.min),this._box.style.width=n.x+"px",this._box.style.height=n.y+"px"},_finish:function(){this._moved&&(t5(this._box),et(this._container,"leaflet-crosshair")),tG(),ec(),ey(document,{contextmenu:eb,mousemove:this._onMouseMove,mouseup:this._onMouseUp,keydown:this._onKeyDown},this)},_onMouseUp:function(t){if((1===t.which||1===t.button)&&(this._finish(),this._moved)){this._clearDeferredResetState(),this._resetStateTimeout=setTimeout(r(this._resetState,this),0);var e=new F(this._map.containerPointToLatLng(this._startPoint),this._map.containerPointToLatLng(this._point));this._map.fitBounds(e).fire("boxzoomend",{boxZoomBounds:e})}},_onKeyDown:function(t){27===t.keyCode&&this._finish()}});eA.addInitHook("addHandler","boxZoom",i0),eA.mergeOptions({doubleClickZoom:!0});var iU=eR.extend({addHooks:function(){this._map.on("dblclick",this._onDoubleClick,this)},removeHooks:function(){this._map.off("dblclick",this._onDoubleClick,this)},_onDoubleClick:function(t){var e=this._map,n=e.getZoom(),a=e.options.zoomDelta,s=t.originalEvent.shiftKey?n-a:n+a;"center"===e.options.doubleClickZoom?e.setZoom(s):e.setZoomAround(t.containerPoint,s)}});eA.addInitHook("addHandler","doubleClickZoom",iU),eA.mergeOptions({dragging:!0,inertia:!tr,inertiaDeceleration:3400,inertiaMaxSpeed:1/0,easeLinearity:.2,worldCopyJump:!1,maxBoundsViscosity:0});var iH=eR.extend({addHooks:function(){if(!this._draggable){var t=this._map;this._draggable=new eH(t._mapPane,t._container),this._draggable.on({dragstart:this._onDragStart,drag:this._onDrag,dragend:this._onDragEnd},this),this._draggable.on("predrag",this._onPreDragLimit,this),t.options.worldCopyJump&&(this._draggable.on("predrag",this._onPreDragWrap,this),t.on("zoomend",this._onZoomEnd,this),t.whenReady(this._onZoomEnd,this))}t9(this._map._container,"leaflet-grab leaflet-touch-drag"),this._draggable.enable(),this._positions=[],this._times=[]},removeHooks:function(){et(this._map._container,"leaflet-grab"),et(this._map._container,"leaflet-touch-drag"),this._draggable.disable()},moved:function(){return this._draggable&&this._draggable._moved},moving:function(){return this._draggable&&this._draggable._moving},_onDragStart:function(){var t=this._map;if(t._stop(),this._map.options.maxBounds&&this._map.options.maxBoundsViscosity){var e=j(this._map.options.maxBounds);this._offsetLimit=Z(this._map.latLngToContainerPoint(e.getNorthWest()).multiplyBy(-1),this._map.latLngToContainerPoint(e.getSouthEast()).multiplyBy(-1).add(this._map.getSize())),this._viscosity=Math.min(1,Math.max(0,this._map.options.maxBoundsViscosity))}else this._offsetLimit=null;t.fire("movestart").fire("dragstart"),t.options.inertia&&(this._positions=[],this._times=[])},_onDrag:function(t){if(this._map.options.inertia){var e=this._lastTime=+new Date,n=this._lastPos=this._draggable._absPos||this._draggable._newPos;this._positions.push(n),this._times.push(e),this._prunePositions(e)}this._map.fire("move",t).fire("drag",t)},_prunePositions:function(t){for(;1e.max.x&&(t.x=this._viscousLimit(t.x,e.max.x)),t.y>e.max.y&&(t.y=this._viscousLimit(t.y,e.max.y)),this._draggable._newPos=this._draggable._startPos.add(t)}},_onPreDragWrap:function(){var t=this._worldWidth,e=Math.round(t/2),n=this._initialWorldOffset,a=this._draggable._newPos.x,s=(a-e+n)%t+e-n,r=(a+e+n)%t-e-n;this._draggable._absPos=this._draggable._newPos.clone(),this._draggable._newPos.x=Math.abs(s+n)e.getMaxZoom()&&1"'`]/g,a=/[&<>"'`]/,s={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"};function r(t){return s[t]}function l(t,n,a,s,r){var l="_l_geocoder_"+e++;n[r||"callback"]=l,window[l]=Waymark_L.Util.bind(a,s);var h=document.createElement("script");h.type="text/javascript",h.src=t+c(n),h.id=l,document.getElementsByTagName("head")[0].appendChild(h)}function h(t,e,n){var a=new XMLHttpRequest;a.onreadystatechange=function(){var t;if(4===a.readyState){if(200!==a.status&&304!==a.status)t="";else if("string"==typeof a.response)try{t=JSON.parse(a.response)}catch(e){t=a.response}else t=a.response;n(t)}},a.open("GET",t+c(e),!0),a.responseType="json",a.setRequestHeader("Accept","application/json"),a.send(null)}function c(t,e,n){var a=[];for(var s in t){var r=encodeURIComponent(n?s.toUpperCase():s),l=t[s];if(Waymark_L.Util.isArray(l))for(var h=0;h0)for(var s=t.resourceSets[0].resources.length-1;s>=0;s--){var r=t.resourceSets[0].resources[s],l=r.bbox;a[s]={name:r.name,bbox:Waymark_L.latLngBounds([l[0],l[1]],[l[2],l[3]]),center:Waymark_L.latLng(r.point.coordinates)}}e.call(n,a)},this,"jsonp")},reverse:function(t,e,n,a){l("//dev.virtualearth.net/REST/v1/Locations/"+t.lat+","+t.lng,{key:this.key},function(t){for(var e=[],s=t.resourceSets[0].resources.length-1;s>=0;s--){var r=t.resourceSets[0].resources[s],l=r.bbox;e[s]={name:r.name,bbox:Waymark_L.latLngBounds([l[0],l[1]],[l[2],l[3]]),center:Waymark_L.latLng(r.point.coordinates)}}n.call(a,e)},this,"jsonp")}}),p=Waymark_L.Class.extend({options:{serviceUrl:"https://maps.googleapis.com/maps/api/geocode/json",geocodingQueryParams:{},reverseQueryParams:{}},initialize:function(t,e){this._key=t,Waymark_L.setOptions(this,e),this.options.serviceUrl=this.options.service_url||this.options.serviceUrl},geocode:function(t,e,n){var a={address:t};this._key&&this._key.length&&(a.key=this._key),a=Waymark_L.Util.extend(a,this.options.geocodingQueryParams),h(this.options.serviceUrl,a,function(t){var a,s,r,l=[];if(t.results&&t.results.length)for(var h=0;h<=t.results.length-1;h++)a=t.results[h],s=Waymark_L.latLng(a.geometry.location),r=Waymark_L.latLngBounds(Waymark_L.latLng(a.geometry.viewport.northeast),Waymark_L.latLng(a.geometry.viewport.southwest)),l[h]={name:a.formatted_address,bbox:r,center:s,properties:a.address_components};e.call(n,l)})},reverse:function(t,e,n,a){var s={latlng:encodeURIComponent(t.lat)+","+encodeURIComponent(t.lng)};s=Waymark_L.Util.extend(s,this.options.reverseQueryParams),this._key&&this._key.length&&(s.key=this._key),h(this.options.serviceUrl,s,function(t){var e,s,r,l=[];if(t.results&&t.results.length)for(var h=0;h<=t.results.length-1;h++)e=t.results[h],s=Waymark_L.latLng(e.geometry.location),r=Waymark_L.latLngBounds(Waymark_L.latLng(e.geometry.viewport.northeast),Waymark_L.latLng(e.geometry.viewport.southwest)),l[h]={name:e.formatted_address,bbox:r,center:s,properties:e.address_components};n.call(a,l)})}}),m=Waymark_L.Class.extend({options:{geocodeUrl:"https://geocoder.api.here.com/6.2/geocode.json",reverseGeocodeUrl:"https://reverse.geocoder.api.here.com/6.2/reversegeocode.json",app_id:"",app_code:"",geocodingQueryParams:{},reverseQueryParams:{},reverseGeocodeProxRadius:null},initialize:function(t){Waymark_L.setOptions(this,t)},geocode:function(t,e,n){var a={searchtext:t,gen:9,app_id:this.options.app_id,app_code:this.options.app_code,jsonattributes:1};a=Waymark_L.Util.extend(a,this.options.geocodingQueryParams),this.getJSON(this.options.geocodeUrl,a,e,n)},reverse:function(t,e,n,a){var s=this.options.reverseGeocodeProxRadius?this.options.reverseGeocodeProxRadius:null,r=s?","+encodeURIComponent(s):"",l={prox:encodeURIComponent(t.lat)+","+encodeURIComponent(t.lng)+r,mode:"retrieveAddresses",app_id:this.options.app_id,app_code:this.options.app_code,gen:9,jsonattributes:1};l=Waymark_L.Util.extend(l,this.options.reverseQueryParams),this.getJSON(this.options.reverseGeocodeUrl,l,n,a)},getJSON:function(t,e,n,a){h(t,e,function(t){var e,s,r,l=[];if(t.response.view&&t.response.view.length)for(var h=0;h<=t.response.view[0].result.length-1;h++)e=t.response.view[0].result[h].location,s=Waymark_L.latLng(e.displayPosition.latitude,e.displayPosition.longitude),r=Waymark_L.latLngBounds(Waymark_L.latLng(e.mapView.topLeft.latitude,e.mapView.topLeft.longitude),Waymark_L.latLng(e.mapView.bottomRight.latitude,e.mapView.bottomRight.longitude)),l[h]={name:e.address.label,bbox:r,center:s};n.call(a,l)})}}),f=Waymark_L.Class.extend({options:{next:void 0,sizeInMeters:1e4},initialize:function(t){Waymark_L.Util.setOptions(this,t)},geocode:function(t,e,n){if((a=t.match(/^([NS])\s*(\d{1,3}(?:\.\d*)?)\W*([EW])\s*(\d{1,3}(?:\.\d*)?)$/))?s=Waymark_L.latLng((/N/i.test(a[1])?1:-1)*parseFloat(a[2]),(/E/i.test(a[3])?1:-1)*parseFloat(a[4])):(a=t.match(/^(\d{1,3}(?:\.\d*)?)\s*([NS])\W*(\d{1,3}(?:\.\d*)?)\s*([EW])$/))?s=Waymark_L.latLng((/N/i.test(a[2])?1:-1)*parseFloat(a[1]),(/E/i.test(a[4])?1:-1)*parseFloat(a[3])):(a=t.match(/^([NS])\s*(\d{1,3})°?\s*(\d{1,3}(?:\.\d*)?)?['′]?\W*([EW])\s*(\d{1,3})°?\s*(\d{1,3}(?:\.\d*)?)?['′]?$/))?s=Waymark_L.latLng((/N/i.test(a[1])?1:-1)*(parseFloat(a[2])+parseFloat(a[3]/60)),(/E/i.test(a[4])?1:-1)*(parseFloat(a[5])+parseFloat(a[6]/60))):(a=t.match(/^(\d{1,3})°?\s*(\d{1,3}(?:\.\d*)?)?['′]?\s*([NS])\W*(\d{1,3})°?\s*(\d{1,3}(?:\.\d*)?)?['′]?\s*([EW])$/))?s=Waymark_L.latLng((/N/i.test(a[3])?1:-1)*(parseFloat(a[1])+parseFloat(a[2]/60)),(/E/i.test(a[6])?1:-1)*(parseFloat(a[4])+parseFloat(a[5]/60))):(a=t.match(/^([NS])\s*(\d{1,3})°?\s*(\d{1,2})['′]?\s*(\d{1,3}(?:\.\d*)?)?["″]?\W*([EW])\s*(\d{1,3})°?\s*(\d{1,2})['′]?\s*(\d{1,3}(?:\.\d*)?)?["″]?$/))?s=Waymark_L.latLng((/N/i.test(a[1])?1:-1)*(parseFloat(a[2])+parseFloat(a[3]/60+parseFloat(a[4]/3600))),(/E/i.test(a[5])?1:-1)*(parseFloat(a[6])+parseFloat(a[7]/60)+parseFloat(a[8]/3600))):(a=t.match(/^(\d{1,3})°?\s*(\d{1,2})['′]?\s*(\d{1,3}(?:\.\d*)?)?["″]\s*([NS])\W*(\d{1,3})°?\s*(\d{1,2})['′]?\s*(\d{1,3}(?:\.\d*)?)?["″]?\s*([EW])$/))?s=Waymark_L.latLng((/N/i.test(a[4])?1:-1)*(parseFloat(a[1])+parseFloat(a[2]/60+parseFloat(a[3]/3600))),(/E/i.test(a[8])?1:-1)*(parseFloat(a[5])+parseFloat(a[6]/60)+parseFloat(a[7]/3600))):(a=t.match(/^\s*([+-]?\d+(?:\.\d*)?)\s*[\s,]\s*([+-]?\d+(?:\.\d*)?)\s*$/))&&(s=Waymark_L.latLng(parseFloat(a[1]),parseFloat(a[2]))),s){var a,s,r=[{name:t,center:s,bbox:s.toBounds(this.options.sizeInMeters)}];e.call(n,r)}else this.options.next&&this.options.next.geocode(t,e,n)}}),g=Waymark_L.Class.extend({options:{serviceUrl:"https://api.mapbox.com/geocoding/v5/mapbox.places/",geocodingQueryParams:{},reverseQueryParams:{}},initialize:function(t,e){Waymark_L.setOptions(this,e),this.options.geocodingQueryParams.access_token=t,this.options.reverseQueryParams.access_token=t},geocode:function(t,e,n){var a=this.options.geocodingQueryParams;void 0!==a.proximity&&void 0!==a.proximity.lat&&void 0!==a.proximity.lng&&(a.proximity=a.proximity.lng+","+a.proximity.lat),h(this.options.serviceUrl+encodeURIComponent(t)+".json",a,function(t){var a,s,r,l=[];if(t.features&&t.features.length)for(var h=0;h<=t.features.length-1;h++){a=t.features[h],s=Waymark_L.latLng(a.center.reverse()),r=a.bbox?Waymark_L.latLngBounds(Waymark_L.latLng(a.bbox.slice(0,2).reverse()),Waymark_L.latLng(a.bbox.slice(2,4).reverse())):Waymark_L.latLngBounds(s,s);for(var c={text:a.text,address:a.address},d=0;d<(a.context||[]).length;d++)c[a.context[d].id.split(".")[0]]=a.context[d].text;l[h]={name:a.place_name,bbox:r,center:s,properties:c}}e.call(n,l)})},suggest:function(t,e,n){return this.geocode(t,e,n)},reverse:function(t,e,n,a){h(this.options.serviceUrl+encodeURIComponent(t.lng)+","+encodeURIComponent(t.lat)+".json",this.options.reverseQueryParams,function(t){var e,s,r,l=[];if(t.features&&t.features.length)for(var h=0;h<=t.features.length-1;h++)e=t.features[h],s=Waymark_L.latLng(e.center.reverse()),r=e.bbox?Waymark_L.latLngBounds(Waymark_L.latLng(e.bbox.slice(0,2).reverse()),Waymark_L.latLng(e.bbox.slice(2,4).reverse())):Waymark_L.latLngBounds(s,s),l[h]={name:e.place_name,bbox:r,center:s};n.call(a,l)})}}),y=Waymark_L.Class.extend({options:{serviceUrl:"https://www.mapquestapi.com/geocoding/v1"},initialize:function(t,e){this._key=decodeURIComponent(t),Waymark_L.Util.setOptions(this,e)},_formatName:function(){var t,e=[];for(t=0;t=0;l--)a=t.results[0].locations[l],s=Waymark_L.latLng(a.latLng),r[l]={name:this._formatName(a.street,a.adminArea4,a.adminArea3,a.adminArea1),bbox:Waymark_L.latLngBounds(s,s),center:s};e.call(n,r)},this))},reverse:function(t,e,n,a){h(this.options.serviceUrl+"/reverse",{key:this._key,location:t.lat+","+t.lng,outputFormat:"json"},Waymark_L.bind(function(t){var e,s,r=[];if(t.results&&t.results[0].locations)for(var l=t.results[0].locations.length-1;l>=0;l--)e=t.results[0].locations[l],s=Waymark_L.latLng(e.latLng),r[l]={name:this._formatName(e.street,e.adminArea4,e.adminArea3,e.adminArea1),bbox:Waymark_L.latLngBounds(s,s),center:s};n.call(a,r)},this))}}),v=Waymark_L.Class.extend({options:{userId:"",apiKey:"",serviceUrl:"https://neutrinoapi.com/"},initialize:function(t){Waymark_L.Util.setOptions(this,t)},geocode:function(t,e,n){h(this.options.serviceUrl+"geocode-address",{apiKey:this.options.apiKey,userId:this.options.userId,address:t.split(/\s+/).join(".")},function(t){var a,s,r=[];t.locations&&(t.geometry=t.locations[0],a=Waymark_L.latLng(t.geometry.latitude,t.geometry.longitude),s=Waymark_L.latLngBounds(a,a),r[0]={name:t.geometry.address,bbox:s,center:a}),e.call(n,r)})},suggest:function(t,e,n){return this.geocode(t,e,n)},reverse:function(t,e,n,a){h(this.options.serviceUrl+"geocode-reverse",{apiKey:this.options.apiKey,userId:this.options.userId,latitude:t.lat,longitude:t.lng},function(e){var s,r,l=[];200==e.status.status&&e.found&&(s=Waymark_L.latLng(t.lat,t.lng),r=Waymark_L.latLngBounds(s,s),l[0]={name:e.address,bbox:r,center:s}),n.call(a,l)})}}),k=Waymark_L.Class.extend({options:{serviceUrl:"https://nominatim.openstreetmap.org/",geocodingQueryParams:{},reverseQueryParams:{},htmlTemplate:function(t){var e,s,l=t.address,h=[];return(l.road||l.building)&&h.push("{building} {road} {house_number}"),(l.city||l.town||l.village||l.hamlet)&&h.push('{postcode} {city} {town} {village} {hamlet}'),(l.state||l.country)&&h.push('{state} {country}'),e=h.join("
"),s=l,e.replace(/\{ *([\w_]+) *\}/g,function(t,e){var l,h=s[e];return void 0===h?h="":"function"==typeof h&&(h=h(s)),null==(l=h)?"":l?(l=""+l,a.test(l))?l.replace(n,r):l:l+""})}},initialize:function(t){Waymark_L.Util.setOptions(this,t)},geocode:function(t,e,n){h(this.options.serviceUrl+"search",Waymark_L.extend({q:t,limit:5,format:"json",addressdetails:1},this.options.geocodingQueryParams),Waymark_L.bind(function(t){for(var a=[],s=t.length-1;s>=0;s--){for(var r=t[s].boundingbox,l=0;l<4;l++)r[l]=parseFloat(r[l]);a[s]={icon:t[s].icon,name:t[s].display_name,html:this.options.htmlTemplate?this.options.htmlTemplate(t[s]):void 0,bbox:Waymark_L.latLngBounds([r[0],r[2]],[r[1],r[3]]),center:Waymark_L.latLng(t[s].lat,t[s].lon),properties:t[s]}}e.call(n,a)},this))},reverse:function(t,e,n,a){h(this.options.serviceUrl+"reverse",Waymark_L.extend({lat:t.lat,lon:t.lng,zoom:Math.round(Math.log(e/256)/Math.log(2)),addressdetails:1,format:"json"},this.options.reverseQueryParams),Waymark_L.bind(function(t){var e,s=[];t&&t.lat&&t.lon&&(e=Waymark_L.latLng(t.lat,t.lon),s.push({name:t.display_name,html:this.options.htmlTemplate?this.options.htmlTemplate(t):void 0,center:e,bounds:Waymark_L.latLngBounds(e,e),properties:t})),n.call(a,s)},this))}}),w=Waymark_L.Class.extend({options:{OpenLocationCode:void 0,codeLength:void 0},initialize:function(t){Waymark_L.setOptions(this,t)},geocode:function(t,e,n){try{var a=this.options.OpenLocationCode.decode(t),s={name:t,center:Waymark_L.latLng(a.latitudeCenter,a.longitudeCenter),bbox:Waymark_L.latLngBounds(Waymark_L.latLng(a.latitudeLo,a.longitudeLo),Waymark_L.latLng(a.latitudeHi,a.longitudeHi))};e.call(n,[s])}catch(r){console.warn(r),e.call(n,[])}},reverse:function(t,e,n,a){try{var s={name:this.options.OpenLocationCode.encode(t.lat,t.lng,this.options.codeLength),center:Waymark_L.latLng(t.lat,t.lng),bbox:Waymark_L.latLngBounds(Waymark_L.latLng(t.lat,t.lng),Waymark_L.latLng(t.lat,t.lng))};n.call(a,[s])}catch(r){console.warn(r),n.call(a,[])}}}),x=Waymark_L.Class.extend({options:{serviceUrl:"https://api.opencagedata.com/geocode/v1/json"},initialize:function(t){this._accessToken=t},geocode:function(t,e,n){h(this.options.serviceUrl,{key:this._accessToken,q:t},function(t){var a,s,r,l=[];if(t.results&&t.results.length)for(var h=0;hthis._lastSuggest&&(this._lastSuggest=t.geocoding.timestamp,e.call(n,a._parseResults(t,"bbox")))},this))},reverse:function(t,e,n,a){var s=this;h(this.options.serviceUrl+"/reverse",Waymark_L.extend({api_key:this._apiKey,"point.lat":t.lat,"point.lon":t.lng},this.options.reverseQueryParams),function(t){n.call(a,s._parseResults(t,"bounds"))})},_parseResults:function(t,e){var n=[];return Waymark_L.geoJson(t,{pointToLayer:function(t,e){return Waymark_L.circleMarker(e)},onEachFeature:function(t,a){var s,r,l={};a.getBounds?r=(s=a.getBounds()).getCenter():a.feature.bbox?(r=a.getLatLng(),s=Waymark_L.latLngBounds(Waymark_L.GeoJSON.coordsToLatLng(a.feature.bbox.slice(0,2)),Waymark_L.GeoJSON.coordsToLatLng(a.feature.bbox.slice(2,4)))):(r=a.getLatLng(),s=Waymark_L.latLngBounds(r,r)),l.name=a.feature.properties.label,l.center=r,l[e]=s,l.properties=a.feature.properties,n.push(l)}}),n}});function b(t,e){return new $(t,e)}var C=$,P=C.extend({options:{serviceUrl:"https://api.openrouteservice.org/geocode"}}),_=Waymark_L.Class.extend({options:{serviceUrl:"https://photon.komoot.de/api/",reverseUrl:"https://photon.komoot.de/reverse/",nameProperties:["name","street","suburb","hamlet","town","city","state","country"]},initialize:function(t){Waymark_L.setOptions(this,t)},geocode:function(t,e,n){var a=Waymark_L.extend({q:t},this.options.geocodingQueryParams);h(this.options.serviceUrl,a,Waymark_L.bind(function(t){e.call(n,this._decodeFeatures(t))},this))},suggest:function(t,e,n){return this.geocode(t,e,n)},reverse:function(t,e,n,a){var s=Waymark_L.extend({lat:t.lat,lon:t.lng},this.options.reverseQueryParams);h(this.options.reverseUrl,s,Waymark_L.bind(function(t){n.call(a,this._decodeFeatures(t))},this))},_decodeFeatures:function(t){var e,n,a,s,r,l,h=[];if(t&&t.features)for(e=0;e0){this._alts.innerHTML="",this._results=t,Waymark_L.DomUtil.removeClass(this._alts,"leaflet-control-geocoder-alternatives-minimized"),Waymark_L.DomUtil.addClass(this._container,"leaflet-control-geocoder-options-open");for(var n=0;n0?"nextSibling":"previousSibling"]),e._selection||(e._selection=e._alts[n>0?"firstChild":"lastChild"]),e._selection&&Waymark_L.DomUtil.addClass(e._selection,"leaflet-control-geocoder-selected")};switch(t.keyCode){case 27:this.options.collapsed?this._collapse():this._clearResults();break;case 38:n(-1);break;case 40:n(1);break;case 13:if(this._selection){var a=parseInt(this._selection.getAttribute("data-result-index"),10);this._geocodeResultSelected(this._results[a]),this._clearResults()}else this._geocode();break;default:return}Waymark_L.DomEvent.preventDefault(t)},_change:function(){var t=this._input.value;t!==this._lastGeocode&&(clearTimeout(this._suggestTimeout),t.length>=this.options.suggestMinLength?this._suggestTimeout=setTimeout(Waymark_L.bind(function(){this._geocode(!0)},this),this.options.suggestTimeout):this._clearResults())}});return Waymark_L.Util.extend(M,E),Waymark_L.Util.extend(Waymark_L.Control,{Geocoder:M,geocoder:function t(e){return new M(e)}}),M}(L),function(t,e){"function"==typeof define&&define.amd?define(["leaflet"],t):"object"==typeof exports&&(void 0!==e&&e.L?module.exports=t(L):module.exports=t(require("leaflet"))),void 0!==e&&e.L&&(e.Waymark_L.Control.Locate=t(L))}(function(t){var e=function(e,n,a){(a=a.split(" ")).forEach(function(a){t.DomUtil[e].call(this,n,a)})},n=function(t,n){e("addClass",t,n)},a=function(t,n){e("removeClass",t,n)},s=t.Marker.extend({initialize:function(e,n){t.Util.setOptions(this,n),this._latlng=e,this.createIcon()},createIcon:function(){var e=this.options,n="";void 0!==e.color&&(n+="stroke:"+e.color+";"),void 0!==e.weight&&(n+="stroke-width:"+e.weight+";"),void 0!==e.fillColor&&(n+="fill:"+e.fillColor+";"),void 0!==e.fillOpacity&&(n+="fill-opacity:"+e.fillOpacity+";"),void 0!==e.opacity&&(n+="opacity:"+e.opacity+";");var a=this._getIconSVG(e,n);this._locationIcon=t.divIcon({className:a.className,html:a.svg,iconSize:[a.w,a.h]}),this.setIcon(this._locationIcon)},_getIconSVG:function(t,e){var n=t.radius,a=n+t.weight,s=2*a;return{className:"leaflet-control-locate-location",svg:'',w:s,h:s}},setStyle:function(e){t.Util.setOptions(this,e),this.createIcon()}}),r=s.extend({initialize:function(e,n,a){t.Util.setOptions(this,a),this._latlng=e,this._heading=n,this.createIcon()},setHeading:function(t){this._heading=t},_getIconSVG:function(t,e){var n=t.radius,a=t.width+t.weight,s=2*(n+t.depth+t.weight),r="M0,0 l"+t.width/2+","+t.depth+" l-"+a+",0 z";return{className:"leaflet-control-locate-heading",svg:'',w:a,h:s}}}),l=t.Control.extend({options:{position:"topleft",layer:void 0,setView:"untilPanOrZoom",keepCurrentZoomLevel:!1,getLocationBounds:function(t){return t.bounds},flyTo:!1,clickBehavior:{inView:"stop",outOfView:"setView",inViewNotFollowing:"inView"},returnToPrevBounds:!1,cacheLocation:!0,drawCircle:!0,drawMarker:!0,showCompass:!0,markerClass:s,compassClass:r,circleStyle:{className:"leaflet-control-locate-circle",color:"#136AEC",fillColor:"#136AEC",fillOpacity:.15,weight:0},markerStyle:{className:"leaflet-control-locate-marker",color:"#fff",fillColor:"#2A93EE",fillOpacity:1,weight:3,opacity:1,radius:9},compassStyle:{fillColor:"#2A93EE",fillOpacity:1,weight:0,color:"#fff",opacity:1,radius:9,width:9,depth:6},followCircleStyle:{},followMarkerStyle:{},followCompassStyle:{},icon:"fa fa-map-marker",iconLoading:"fa fa-spinner fa-spin",iconElementTag:"span",circlePadding:[0,0],metric:!0,createButtonCallback:function(e,n){var a=t.DomUtil.create("a","leaflet-bar-part leaflet-bar-part-single",e);return a.title=n.strings.title,{link:a,icon:t.DomUtil.create(n.iconElementTag,n.icon,a)}},onLocationError:function(t,e){alert(t.message)},onLocationOutsideMapBounds:function(t){t.stop(),alert(t.options.strings.outsideMapBoundsMsg)},showPopup:!0,strings:{title:"Show me where I am",metersUnit:"meters",feetUnit:"feet",popup:"You are within {distance} {unit} from this point",outsideMapBoundsMsg:"You seem located outside the boundaries of the map"},locateOptions:{maxZoom:1/0,watch:!0,setView:!1}},initialize:function(e){for(var n in e)"object"==typeof this.options[n]?t.extend(this.options[n],e[n]):this.options[n]=e[n];this.options.followMarkerStyle=t.extend({},this.options.markerStyle,this.options.followMarkerStyle),this.options.followCircleStyle=t.extend({},this.options.circleStyle,this.options.followCircleStyle),this.options.followCompassStyle=t.extend({},this.options.compassStyle,this.options.followCompassStyle)},onAdd:function(e){var n=t.DomUtil.create("div","leaflet-control-locate leaflet-bar leaflet-control");this._layer=this.options.layer||new t.LayerGroup,this._layer.addTo(e),this._event=void 0,this._compassHeading=null,this._prevBounds=null;var a=this.options.createButtonCallback(n,this.options);return this._link=a.link,this._icon=a.icon,t.DomEvent.on(this._link,"click",t.DomEvent.stopPropagation).on(this._link,"click",t.DomEvent.preventDefault).on(this._link,"click",this._onClick,this).on(this._link,"dblclick",t.DomEvent.stopPropagation),this._resetVariables(),this._map.on("unload",this._unload,this),n},_onClick:function(){this._justClicked=!0;var t=this._isFollowing();if(this._userPanned=!1,this._userZoomed=!1,this._active&&!this._event)this.stop();else if(this._active&&void 0!==this._event){var e=this.options.clickBehavior,n=e.outOfView;switch(this._map.getBounds().contains(this._event.latlng)&&(n=t?e.inView:e.inViewNotFollowing),e[n]&&(n=e[n]),n){case"setView":this.setView();break;case"stop":this.stop(),this.options.returnToPrevBounds&&(this.options.flyTo?this._map.flyToBounds:this._map.fitBounds).bind(this._map)(this._prevBounds)}}else this.options.returnToPrevBounds&&(this._prevBounds=this._map.getBounds()),this.start();this._updateContainerStyle()},start:function(){this._activate(),this._event&&(this._drawMarker(this._map),this.options.setView&&this.setView()),this._updateContainerStyle()},stop:function(){this._deactivate(),this._cleanClasses(),this._resetVariables(),this._removeMarker()},stopFollowing:function(){this._userPanned=!0,this._updateContainerStyle(),this._drawMarker()},_activate:function(){this._active||(this._map.locate(this.options.locateOptions),this._active=!0,this._map.on("locationfound",this._onLocationFound,this),this._map.on("locationerror",this._onLocationError,this),this._map.on("dragstart",this._onDrag,this),this._map.on("zoomstart",this._onZoom,this),this._map.on("zoomend",this._onZoomEnd,this),this.options.showCompass&&("ondeviceorientationabsolute"in window?t.DomEvent.on(window,"deviceorientationabsolute",this._onDeviceOrientation,this):"ondeviceorientation"in window&&t.DomEvent.on(window,"deviceorientation",this._onDeviceOrientation,this)))},_deactivate:function(){this._map.stopLocate(),this._active=!1,this.options.cacheLocation||(this._event=void 0),this._map.off("locationfound",this._onLocationFound,this),this._map.off("locationerror",this._onLocationError,this),this._map.off("dragstart",this._onDrag,this),this._map.off("zoomstart",this._onZoom,this),this._map.off("zoomend",this._onZoomEnd,this),this.options.showCompass&&(this._compassHeading=null,"ondeviceorientationabsolute"in window?t.DomEvent.off(window,"deviceorientationabsolute",this._onDeviceOrientation,this):"ondeviceorientation"in window&&t.DomEvent.off(window,"deviceorientation",this._onDeviceOrientation,this))},setView:function(){if(this._drawMarker(),this._isOutsideMapBounds())this._event=void 0,this.options.onLocationOutsideMapBounds(this);else if(this.options.keepCurrentZoomLevel)(e=this.options.flyTo?this._map.flyTo:this._map.panTo).bind(this._map)([this._event.latitude,this._event.longitude]);else{var e=this.options.flyTo?this._map.flyToBounds:this._map.fitBounds;this._ignoreEvent=!0,e.bind(this._map)(this.options.getLocationBounds(this._event),{padding:this.options.circlePadding,maxZoom:this.options.locateOptions.maxZoom}),t.Util.requestAnimFrame(function(){this._ignoreEvent=!1},this)}},_drawCompass:function(){if(this._event){var t=this._event.latlng;if(this.options.showCompass&&t&&null!==this._compassHeading){var e=this._isFollowing()?this.options.followCompassStyle:this.options.compassStyle;this._compass?(this._compass.setLatLng(t),this._compass.setHeading(this._compassHeading),this._compass.setStyle&&this._compass.setStyle(e)):this._compass=new this.options.compassClass(t,this._compassHeading,e).addTo(this._layer)}!this._compass||this.options.showCompass&&null!==this._compassHeading||(this._compass.removeFrom(this._layer),this._compass=null)}},_drawMarker:function(){void 0===this._event.accuracy&&(this._event.accuracy=0);var e,n,a=this._event.accuracy,s=this._event.latlng;if(this.options.drawCircle){var r=this._isFollowing()?this.options.followCircleStyle:this.options.circleStyle;this._circle?this._circle.setLatLng(s).setRadius(a).setStyle(r):this._circle=t.circle(s,a,r).addTo(this._layer)}if(n=this.options.metric?(e=a.toFixed(0),this.options.strings.metersUnit):(e=(3.2808399*a).toFixed(0),this.options.strings.feetUnit),this.options.drawMarker){var l=this._isFollowing()?this.options.followMarkerStyle:this.options.markerStyle;this._marker?(this._marker.setLatLng(s),this._marker.setStyle&&this._marker.setStyle(l)):this._marker=new this.options.markerClass(s,l).addTo(this._layer)}this._drawCompass();var h=this.options.strings.popup;this.options.showPopup&&h&&this._marker&&this._marker.bindPopup(t.Util.template(h,{distance:e,unit:n}))._popup.setLatLng(s),this.options.showPopup&&h&&this._compass&&this._compass.bindPopup(t.Util.template(h,{distance:e,unit:n}))._popup.setLatLng(s)},_removeMarker:function(){this._layer.clearLayers(),this._marker=void 0,this._circle=void 0},_unload:function(){this.stop(),this._map.off("unload",this._unload,this)},_setCompassHeading:function(e){!isNaN(parseFloat(e))&&isFinite(e)?(e=Math.round(e),this._compassHeading=e,t.Util.requestAnimFrame(this._drawCompass,this)):this._compassHeading=null},_onCompassNeedsCalibration:function(){this._setCompassHeading()},_onDeviceOrientation:function(t){this._active&&(t.webkitCompassHeading?this._setCompassHeading(t.webkitCompassHeading):t.absolute&&t.alpha&&this._setCompassHeading(360-t.alpha))},_onLocationError:function(t){3==t.code&&this.options.locateOptions.watch||(this.stop(),this.options.onLocationError(t,this))},_onLocationFound:function(t){if((!this._event||this._event.latlng.lat!==t.latlng.lat||this._event.latlng.lng!==t.latlng.lng||this._event.accuracy!==t.accuracy)&&this._active){switch(this._event=t,this._drawMarker(),this._updateContainerStyle(),this.options.setView){case"once":this._justClicked&&this.setView();break;case"untilPan":this._userPanned||this.setView();break;case"untilPanOrZoom":this._userPanned||this._userZoomed||this.setView();break;case"always":this.setView()}this._justClicked=!1}},_onDrag:function(){this._event&&!this._ignoreEvent&&(this._userPanned=!0,this._updateContainerStyle(),this._drawMarker())},_onZoom:function(){this._event&&!this._ignoreEvent&&(this._userZoomed=!0,this._updateContainerStyle(),this._drawMarker())},_onZoomEnd:function(){this._event&&this._drawCompass(),this._event&&!this._ignoreEvent&&this._marker&&!this._map.getBounds().pad(-.3).contains(this._marker.getLatLng())&&(this._userPanned=!0,this._updateContainerStyle(),this._drawMarker())},_isFollowing:function(){return!!this._active&&("always"===this.options.setView||("untilPan"===this.options.setView?!this._userPanned:"untilPanOrZoom"===this.options.setView?!this._userPanned&&!this._userZoomed:void 0))},_isOutsideMapBounds:function(){return void 0!==this._event&&this._map.options.maxBounds&&!this._map.options.maxBounds.contains(this._event.latlng)},_updateContainerStyle:function(){this._container&&(this._active&&!this._event?this._setClasses("requesting"):this._isFollowing()?this._setClasses("following"):this._active?this._setClasses("active"):this._cleanClasses())},_setClasses:function(t){"requesting"==t?(a(this._container,"active following"),n(this._container,"requesting"),a(this._icon,this.options.icon),n(this._icon,this.options.iconLoading)):"active"==t?(a(this._container,"requesting following"),n(this._container,"active"),a(this._icon,this.options.iconLoading),n(this._icon,this.options.icon)):"following"==t&&(a(this._container,"requesting"),n(this._container,"active following"),a(this._icon,this.options.iconLoading),n(this._icon,this.options.icon))},_cleanClasses:function(){t.DomUtil.removeClass(this._container,"requesting"),t.DomUtil.removeClass(this._container,"active"),t.DomUtil.removeClass(this._container,"following"),a(this._icon,this.options.iconLoading),n(this._icon,this.options.icon)},_resetVariables:function(){this._active=!1,this._justClicked=!1,this._userPanned=!1,this._userZoomed=!1}});return t.control.locate=function(e){return new t.Control.Locate(e)},l},window),function(t){"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";var t,e;t=function(t){return t.locales={},t.locale=null,t.registerLocale=function e(n,a){t.locales[n]=t.Util.extend({},t.locales[n],a)},t.setLocale=function e(n){t.locale=n},t.i18n=t._=function e(n,a){t.locale&&t.locales[t.locale]&&t.locales[t.locale][n]&&(n=t.locales[t.locale][n]);try{n=t.Util.template(n,a)}catch(s){}return n}},e=window,"function"==typeof define&&define.amd?define(["leaflet"],t):"object"==typeof exports&&(module.exports=t(require("leaflet"))),void 0!==e&&e.L&&t(e.L),L.Control.Elevation=L.Control.extend({includes:L.Evented?L.Evented.prototype:L.Mixin.Events,options:{autohide:!L.Browser.mobile,autohideMarker:!0,collapsed:!1,controlButton:{iconCssClass:"elevation-toggle-icon",title:"Elevation"},detached:!0,distanceFactor:1,dragging:!L.Browser.mobile,downloadLink:"link",elevationDiv:"#elevation-div",followMarker:!0,forceAxisBounds:!1,gpxOptions:{async:!0,marker_options:{startIconUrl:null,endIconUrl:null,shadowUrl:null,wptIcons:{"":L.divIcon({className:"elevation-waypoint-marker",html:'',iconSize:[30,30],iconAnchor:[8,30]})}}},height:200,heightFactor:1,hoverNumber:{decimalsX:2,decimalsY:0,formatter:void 0},imperial:!1,interpolation:"curveLinear",lazyLoadJS:!0,legend:!0,loadData:{defer:!1,lazy:!1},marker:"elevation-line",markerIcon:L.divIcon({className:"elevation-position-marker",html:'',iconSize:[32,32],iconAnchor:[16,16]}),placeholder:!1,position:"topright",polyline:{className:"elevation-polyline",color:"#000",opacity:.75,weight:5,lineCap:"round"},reverseCoords:!1,skipNullZCoords:!1,theme:"lightblue-theme",margins:{top:10,right:20,bottom:30,left:50},responsive:!0,summary:"inline",width:600,xLabel:"km",xTicks:void 0,yAxisMax:void 0,yAxisMin:void 0,yLabel:"m",yTicks:void 0,zFollow:13},__mileFactor:.621371,__footFactor:3.28084,addData:function(t,e){L.Control.Elevation._d3LazyLoader=this._lazyLoadJS("https://unpkg.com/d3@5.15.0/dist/d3.min.js","object"!=typeof d3,L.Control.Elevation._d3LazyLoader).then((function(t,e){this._addData(t),this._container&&this._applyData(),null==e&&t.on&&(e=t),e&&(e._path&&L.DomUtil.addClass(e._path,this.options.polyline.className+" "+this.options.theme),e.on("mousemove",this._mousemoveLayerHandler,this).on("mouseout",this._mouseoutHandler,this)),this.track_info=L.extend({},this.track_info,{distance:this._distance,elevation_max:this._maxElevation,elevation_min:this._minElevation,ascent:this._ascent,descent:this._descent}),this._layers=this._layers||{},this._layers[L.Util.stamp(e)]=e,this._fireEvt("eledata_added",{data:t,layer:e,track_info:this.track_info},!0)}).bind(this,t,e))},addTo:function(t){return this.options.detached?this._appendElevationDiv(t._container).appendChild(this.onAdd(t)):L.Control.prototype.addTo.call(this,t),this},clear:function(){this._clearPath(),this._clearChart(),this._clearData(),this._fireEvt("eledata_clear")},disableDragging:function(){this._draggingEnabled=!1,this._resetDrag()},enableDragging:function(){this._draggingEnabled=!0},fitBounds:function(t){t=t||this._fullExtent,this._map&&t&&this._map.fitBounds(t)},getZFollow:function(){return this._zFollow},hide:function(){this._container.style.display="none"},initialize:function(t){this.options=this._deepMerge({},this.options,t),this.options.imperial?(this._distanceFactor=this.__mileFactor,this._heightFactor=this.__footFactor,this._xLabel="mi",this._yLabel="ft"):(this._distanceFactor=this.options.distanceFactor,this._heightFactor=this.options.heightFactor,this._xLabel=this.options.xLabel,this._yLabel=this.options.yLabel),this._chartEnabled=!0,this._draggingEnabled=this.options.dragging,this._zFollow=this.options.zFollow,this.options.followMarker&&(this._setMapView=L.Util.throttle(this._setMapView,300,this)),this.options.placeholder&&(this.options.loadData.lazy=this.options.loadData.defer=!0),this.on("waypoint_added",function(t){t.point._popup&&(t.point._popup.options.className="elevation-popup",t.point._popup._content=decodeURI(t.point._popup._content)),t.point._popup&&t.point._popup._content&&t.point.bindTooltip(t.point._popup._content,{direction:"top",sticky:!0,opacity:1,className:"elevation-tooltip"}).openTooltip()})},load:function(t,e){this.loadData(t,e)},loadChart:function(t){this.addTo(t)},loadData:function(t,e){(e=L.extend({},this.options.loadData,e)).defer?this.loadDefer(t,e):e.lazy?this.loadLazy(t,e):this._isXMLDoc(t)?this.loadGPX(t):this._isJSONDoc(t)?this.loadGeoJSON(t):this.loadFile(t)},loadDefer:function(t,e){(e=L.extend({},this.options.loadData,e)).defer=!1,"complete"!==document.readyState?window.addEventListener("load",L.bind(this.loadData,this,t,e),{once:!0}):this.loadData(t,e)},loadFile:function(t){this._downloadURL=t;try{let e=new XMLHttpRequest;e.responseType="text",e.open("GET",t),e.onload=(function(){if(200!==e.status)throw"Error "+e.status+" while fetching remote file: "+t;this.loadData(e.response,{lazy:!1,defer:!1})}).bind(this),e.send()}catch(n){console.warn(n)}},loadGeoJSON:function(t){"string"==typeof t&&(t=JSON.parse(t)),this.layer=this.geojson=L.geoJson(t,{style:(function(t){let e=L.extend({},this.options.polyline);return this.options.theme&&(e.className+=" "+this.options.theme),e}).bind(this),pointToLayer:(function(t,e){let n=L.marker(e,{icon:this.options.gpxOptions.marker_options.wptIcons[""]}),a=t.properties.desc?t.properties.desc:"",s=t.properties.name?t.properties.name:"";return(s||a)&&n.bindPopup(""+s+""+(a.length>0?"
"+a:"")).openPopup(),this.fire("waypoint_added",{point:n,point_type:"waypoint",element:e}),n}).bind(this),onEachFeature:(function(e,n){"Point"!=e.geometry.type&&(this.addData(e,n),this.track_info=L.extend({},this.track_info,{type:"geojson",name:t.name}))}).bind(this)}),this._map?(this._map.once("layeradd",function(e){this._fireEvt("eledata_loaded",{data:t,layer:this.layer,name:this.track_info.name,track_info:this.track_info},!0)},this),this.layer.addTo(this._map)):console.warn("Undefined elevation map object")},loadGPX:function(t){L.Control.Elevation._gpxLazyLoader=this._lazyLoadJS("https://unpkg.com/leaflet-gpx@1.5.0/gpx.js","function"!=typeof L.GPX,L.Control.Elevation._gpxLazyLoader).then((function(t){this.options.gpxOptions.polyline_options=L.extend({},this.options.polyline,this.options.gpxOptions.polyline_options),this.options.theme&&(this.options.gpxOptions.polyline_options.className+=" "+this.options.theme),this.layer=this.gpx=new L.GPX(t,this.options.gpxOptions),this.layer.on("loaded",function(t){this.fitBounds(t.target.getBounds())},this),this.layer.on("addpoint",function(t){this.fire("waypoint_added",t,!0)},this),this.layer.once("addline",function(e){this.addData(e.line),this.track_info=L.extend({},this.track_info,{type:"gpx",name:this.layer.get_name()}),this._fireEvt("eledata_loaded",{data:t,layer:this.layer,name:this.track_info.name,track_info:this.track_info},!0)},this),this._map?this.layer.addTo(this._map):console.warn("Undefined elevation map object")}).bind(this,t))},loadLazy:function(t,e){(e=L.extend({},this.options.loadData,e)).lazy=!1;let n=!1,a=L.bind(function(t){n||(L.Util.requestAnimFrame(function(){this._isVisible(this.placeholder)&&(window.removeEventListener("scroll",a),this.loadData(t,e),this.once("eledata_loaded",function(){this.placeholder&&this.placeholder.parentNode&&this.placeholder.parentNode.removeChild(this.placeholder)},this)),n=!1},this),n=!0)},this,t);window.addEventListener("scroll",a),this.placeholder&&this.placeholder.addEventListener("mouseenter",a,{once:!0}),a()},onAdd:function(t){this._map=t;let e=this._container=L.DomUtil.create("div","elevation-control elevation");if(this.options.detached||L.DomUtil.addClass(e,"leaflet-control"),this.options.theme&&L.DomUtil.addClass(e,this.options.theme),this.options.placeholder&&!this._data){if(this.placeholder=L.DomUtil.create("img","elevation-placeholder"),"string"==typeof this.options.placeholder)this.placeholder.src=this.options.placeholder,this.placeholder.alt="";else for(let n in this.options.placeholder)this.placeholder.setAttribute(n,this.options.placeholder[n]);e.insertBefore(this.placeholder,e.firstChild)}return L.Control.Elevation._d3LazyLoader=this._lazyLoadJS("https://unpkg.com/d3@5.15.0/dist/d3.min.js","object"!=typeof d3,L.Control.Elevation._d3LazyLoader).then((function(t,e){this._initToggle(e),this._initChart(e),this._applyData(),this._map.on("zoom viewreset zoomanim",this._hidePositionMarker,this),this._map.on("resize",this._resetView,this),this._map.on("resize",this._resizeChart,this),this._map.on("mousedown",this._resetDrag,this),this._map.on("eledata_added",this._updateSummary,this),L.DomEvent.on(this._map._container,"mousewheel",this._resetDrag,this),L.DomEvent.on(this._map._container,"touchstart",this._resetDrag,this)}).bind(this,t,e)),e},onRemove:function(t){this._container=null},redraw:function(){this._resizeChart()},setZFollow:function(t){this._zFollow=t},show:function(){this._container.style.display="block"},_addData:function(t){let e=t&&t.geometry,n=t&&"FeatureCollection"===t.type,a=t&&t._latlngs;if(e)switch(e.type){case"LineString":this._addGeoJSONData(e.coordinates);break;case"MultiLineString":e.coordinates.forEach(t=>this._addGeoJSONData(t));break;default:console.warn("Unsopperted GeoJSON feature geometry type:"+e.type)}n&&t.features.forEach(t=>this._addData(t)),a&&this._addGPXdata(t._latlngs)},_addGeoJSONData:function(t){t&&t.forEach(t=>this._addPoint(t[1],t[0],t[2]))},_addGPXdata:function(t){t&&t.forEach(t=>this._addPoint(t.lat,t.lng,t.meta.ele))},_addPoint:function(t,e,n){this.options.reverseCoords&&([t,e]=[e,t]);let a=this._data||[],s=this._maxElevation||-1/0,r=this._minElevation||Infinity,l=this._distance||0,h=new L.LatLng(t,e),c=a.length?a[a.length-1].latlng:h;if(l+=Math.round(h.distanceTo(c)*this._distanceFactor/1e3*1e5)/1e5,!this.options.skipNullZCoords&&a.length>0){let d=a[a.length-1].z;if(isNaN(d)){let u=this._lastValidZ,p=n*this._heightFactor;isNaN(u)||isNaN(p)?isNaN(u)?isNaN(p)||(d=p):d=u:d=(u+p)/2,isNaN(d)?a.splice(a.length-1,1):a[a.length-1].z=d}}if(!isNaN(n*=this._heightFactor)){s=sn?n:r;let m=n-this._lastValidZ;m>0?(this.track_info.ascent=(this.track_info.ascent||0)+m,this._ascent=this.track_info.ascent):m<0&&(this.track_info.descent=(this.track_info.descent||0)-m,this._descent=this.track_info.descent),this._lastValidZ=n}a.push({dist:l,x:t,y:e,z:n,latlng:h}),this._data=a,this._distance=l,this._maxElevation=s,this._minElevation=r},_appendChart:function(t){let e=t.append("g").attr("transform","translate("+this.options.margins.left+","+this.options.margins.top+")");this._appendGrid(e),this._appendAreaPath(e),this._appendAxis(e),this._appendFocusRect(e),this._appendMouseFocusG(e),this._appendLegend(e)},_appendElevationDiv:function(t){let e=document.querySelector(this.options.elevationDiv);return e||(e=L.DomUtil.create("div","leaflet-control elevation elevation-div"),this.options.elevationDiv="#elevation-div_"+Math.random().toString(36).substr(2,9),e.id=this.options.elevationDiv.substr(1),t.parentNode.insertBefore(e,t.nextSibling)),this.options.detached&&(L.DomUtil.addClass(e,"elevation-detached"),L.DomUtil.removeClass(e,"leaflet-control")),this.eleDiv=e,this.eleDiv},_appendXaxis:function(t){t.append("g").attr("class","x axis").attr("transform","translate(0,"+this._height()+")").call(d3.axisBottom().scale(this._x).ticks(this.options.xTicks)).append("text").attr("x",this._width()+6).attr("y",30).text(this._xLabel)},_appendXGrid:function(t){t.append("g").attr("class","x grid").attr("transform","translate(0,"+this._height()+")").call(d3.axisBottom().scale(this._x).ticks(this.options.xTicks).tickSize(-this._height()).tickFormat(""))},_appendYaxis:function(t){t.append("g").attr("class","y axis").call(d3.axisLeft().scale(this._y).ticks(this.options.yTicks)).append("text").attr("x",-30).attr("y",3).text(this._yLabel)},_appendYGrid:function(t){t.append("g").attr("class","y grid").call(d3.axisLeft().scale(this._y).ticks(this.options.yTicks).tickSize(-this._width()).tickFormat(""))},_appendAreaPath:function(t){this._areapath=t.append("path").attr("class","area")},_appendAxis:function(t){this._axis=t.append("g").attr("class","axis"),this._appendXaxis(this._axis),this._appendYaxis(this._axis)},_appendFocusRect:function(t){let e=this._focusRect=t.append("rect").attr("width",this._width()).attr("height",this._height()).style("fill","none").style("stroke","none").style("pointer-events","all");L.Browser.mobile&&(e.on("touchmove.drag",this._dragHandler.bind(this)).on("touchstart.drag",this._dragStartHandler.bind(this)).on("touchstart.focus",this._mousemoveHandler.bind(this)).on("touchmove.focus",this._mousemoveHandler.bind(this)),L.DomEvent.on(this._container,"touchend",this._dragEndHandler,this)),e.on("mousemove.drag",this._dragHandler.bind(this)).on("mousedown.drag",this._dragStartHandler.bind(this)).on("mouseenter.focus",this._mouseenterHandler.bind(this)).on("mousemove.focus",this._mousemoveHandler.bind(this)).on("mouseout.focus",this._mouseoutHandler.bind(this)),L.DomEvent.on(this._container,"mouseup",this._dragEndHandler,this)},_appendGrid:function(t){this._grid=t.append("g").attr("class","grid"),this._appendXGrid(this._grid),this._appendYGrid(this._grid)},_appendMouseFocusG:function(t){let e=this._focusG=t.append("g").attr("class","mouse-focus-group");this._mousefocus=e.append("svg:line").attr("class","mouse-focus-line").attr("x2","0").attr("y2","0").attr("x1","0").attr("y1","0"),this._focuslabelrect=e.append("rect").attr("class","mouse-focus-label").attr("x",0).attr("y",0).attr("width",0).attr("height",0).attr("rx",3).attr("ry",3),this._focuslabeltext=e.append("svg:text").attr("class","mouse-focus-label-text"),this._focuslabelY=this._focuslabeltext.append("svg:tspan").attr("class","mouse-focus-label-y").attr("dy","-1em"),this._focuslabelX=this._focuslabeltext.append("svg:tspan").attr("class","mouse-focus-label-x").attr("dy","2em")},_appendLegend:function(t){if(!this.options.legend)return;let e=this._legend=t.append("g").attr("class","legend"),n=this._altitudeLegend=this._legend.append("g").attr("class","legend-altitude");n.append("rect").attr("class","area").attr("x",this._width()/2-50).attr("y",this._height()+this.options.margins.bottom-17).attr("width",50).attr("height",5).attr("opacity",.75),n.append("text").text(L._("Altitude")).attr("x",this._width()/2+5).attr("font-size",10).style("text-decoration-thickness","2px").style("font-weight","700").attr("y",this._height()+this.options.margins.bottom-11),e.on("click",(function(){if(this._chartEnabled)this._clearChart(),this._clearPath(),this._chartEnabled=!1;else{for(let t in this._resizeChart(),this._layers)L.DomUtil.addClass(this._layers[t]._path,this.options.polyline.className+" "+this.options.theme);this._chartEnabled=!0}}).bind(this))},_appendPositionMarker:function(t){let e=this.options.theme,n=t.select("g");this._mouseHeightFocus=n.append("svg:line").attr("class",e+" height-focus line").attr("x2",0).attr("y2",0).attr("x1",0).attr("y1",0),this._pointG=n.append("g"),this._pointG.append("svg:circle").attr("class",e+" height-focus circle-lower").attr("r",6).attr("cx",0).attr("cy",0),this._mouseHeightFocusLabel=n.append("svg:text").attr("class",e+" height-focus-label").style("pointer-events","none")},_applyData:function(){if(!this._data)return;let t=d3.extent(this._data,t=>t.dist),e=d3.extent(this._data,t=>t.z),n=this.options;void 0!==n.yAxisMin&&(n.yAxisMine[1]||n.forceAxisBounds)&&(e[1]=n.yAxisMax),this._x.domain(t),this._y.domain(e),this._areapath.datum(this._data).attr("d",this._area),this._updateAxis(),this._fullExtent=this._calculateFullExtent(this._data)},_calculateFullExtent:function(t){if(!t||t.length<1)throw Error("no data in parameters");let e=new L.latLngBounds(t[0].latlng,t[0].latlng);return t.forEach(t=>e.extend(t.latlng)),e},_clearChart:function(){this._resetDrag(),this._areapath&&(this._areapath.attr("d","M0 0"),this._x.domain([0,1]),this._y.domain([0,1]),this._updateAxis()),this._altitudeLegend&&this._altitudeLegend.select("text").style("text-decoration-line","line-through")},_clearData:function(){this._data=null,this._distance=null,this._maxElevation=null,this._minElevation=null,this.track_info=null,this._layers=null},_clearPath:function(){for(let t in this._hidePositionMarker(),this._layers)L.DomUtil.removeClass(this._layers[t]._path,this.options.polyline.className),L.DomUtil.removeClass(this._layers[t]._path,this.options.theme)},_collapse:function(){this._container&&(L.DomUtil.removeClass(this._container,"elevation-expanded"),L.DomUtil.addClass(this._container,"elevation-collapsed"))},_deepMerge:function(t,...e){if(!e.length)return t;let n=e.shift();if(this._isObject(t)&&this._isObject(n))for(let a in n)this._isObject(n[a])?(t[a]||Object.assign(t,{[a]:{}}),this._deepMerge(t[a],n[a])):Object.assign(t,{[a]:n[a]});return this._deepMerge(t,...e)},_dragHandler:function(){d3.event.preventDefault(),d3.event.stopPropagation(),this._gotDragged=!0,this._drawDragRectangle()},_dragEndHandler:function(){if(!this._dragStartCoords||!this._dragCurrentCoords||!this._gotDragged){this._dragStartCoords=null,this._gotDragged=!1,this._draggingEnabled&&this._resetDrag();return}let t=this._findItemForX(this._dragStartCoords[0]),e=this._findItemForX(this._dragCurrentCoords[0]);t!=e&&(this._hidePositionMarker(),this._fitSection(t,e),this._dragStartCoords=null,this._gotDragged=!1,this._fireEvt("elechart_dragged",{data:{dragstart:this._data[t],dragend:this._data[e]}},!0))},_dragStartHandler:function(){d3.event.preventDefault(),d3.event.stopPropagation(),this._gotDragged=!1,this._dragStartCoords=d3.mouse(this._focusRect.node())},_drawDragRectangle:function(){if(!this._dragStartCoords||!this._draggingEnabled)return;let t=this._dragCurrentCoords=d3.mouse(this._focusRect.node()),e=Math.min(this._dragStartCoords[0],t[0]),n=Math.max(this._dragStartCoords[0],t[0]);if(this._dragRectangle||this._dragRectangleG)this._dragRectangle.attr("width",n-e).attr("x",e);else{let a=d3.select(this._container).select("svg").select("g");this._dragRectangleG=a.insert("g",".mouse-focus-group"),this._dragRectangle=this._dragRectangleG.append("rect").attr("width",n-e).attr("height",this._height()).attr("x",e).attr("class","mouse-drag").style("pointer-events","none")}},_expand:function(){this._container&&(L.DomUtil.removeClass(this._container,"elevation-collapsed"),L.DomUtil.addClass(this._container,"elevation-expanded"))},_findItemForLatLng:function(t){let e=null,n=1/0;return this._data.forEach(a=>{let s=t.distanceTo(a.latlng);st.dist).left)(e,this._x.invert(t))},_fireEvt:function(t,e,n){this.fire&&this.fire(t,e,n),this._map&&this._map.fire(t,e,n)},_fitSection:function(t,e){let n=this._calculateFullExtent(this._data.slice(Math.min(t,e),Math.max(t,e)));this.fitBounds(n)},_formatter:function(t,e,n){let a=L.Util.formatNum(t,e).toString(),s=a.split(".");if(s[1]){for(let r=e-s[1].length;r>0;r--)s[1]+="0";a=s.join(n||".")}return a},_height:function(){let t=this.options;return t.height-t.margins.top-t.margins.bottom},_hidePositionMarker:function(){this.options.autohideMarker&&(this._selectedItem=null,this._marker&&(this._map&&this._map.removeLayer(this._marker),this._marker=null),this._mouseHeightFocus&&(this._mouseHeightFocus.style("visibility","hidden"),this._mouseHeightFocusLabel.style("visibility","hidden")),this._pointG&&this._pointG.style("visibility","hidden"),this._focusG&&this._focusG.style("visibility","hidden"))},_initChart:function(){let t=this.options;if(t.xTicks=t.xTicks||Math.round(this._width()/75),t.yTicks=t.yTicks||Math.round(this._height()/30),t.hoverNumber.formatter=t.hoverNumber.formatter||this._formatter,t.responsive){if(t.detached){let e=this.eleDiv.offsetWidth,n=this.eleDiv.offsetHeight;t.width=e>0?e:t.width,t.height=n-20>0?n-20:t.height}else{t._maxWidth=t._maxWidth>t.width?t._maxWidth:t.width;let a=this._map._container.clientWidth;t.width=t._maxWidth>a?a-30:t.width}}let s=this._x=d3.scaleLinear().range([0,this._width()]),r=this._y=d3.scaleLinear().range([this._height(),0]),l="function"==typeof t.interpolation?t.interpolation:d3[t.interpolation];this._area=d3.area().curve(l).x(t=>t.xDiagCoord=s(t.dist)).y0(this._height()).y1(t=>r(t.z)),this._line=d3.line().x(t=>d3.mouse(c.select("g"))[0]).y(t=>this._height());let h=d3.select(this._container),c=h.append("svg").attr("class","background").attr("width",t.width).attr("height",t.height);this.summaryDiv=h.append("div").attr("class","elevation-summary "+(this.options.summary?this.options.summary+"-summary":"")).node(),this._appendChart(c),this._updateSummary()},_initToggle:function(t){if(t.setAttribute("aria-haspopup",!0),this.options.detached||L.DomEvent.disableClickPropagation(t),L.Browser.mobile&&L.DomEvent.on(t,"click",L.DomEvent.stopPropagation),!this.options.detached){let e="elevation-toggle "+this.options.controlButton.iconCssClass+(this.options.autohide?"":" close-button"),n=this._button=L.DomUtil.create("a",e,t);n.href="#",n.title=this.options.controlButton.title,this.options.collapsed&&(this._collapse(),this.options.autohide?L.DomEvent.on(t,"mouseover",this._expand,this).on(t,"mouseout",this._collapse,this):L.DomEvent.on(n,"click",L.DomEvent.stop).on(n,"click",this._toggle,this),L.DomEvent.on(n,"focus",this._toggle,this),this._map.on("click",this._collapse,this))}},_isObject:function(t){return t&&"object"==typeof t&&!Array.isArray(t)},_isJSONDoc:function(t,e){if(e=void 0===e||e,"string"==typeof t&&e)return 0==(t=t.trim()).indexOf("{")||0==t.indexOf("[");try{JSON.parse(t.toString())}catch(n){if("object"==typeof t&&e)return!0;return console.warn(n),!1}return!0},_isXMLDoc:function(t,e){if(e=void 0===e||e,"string"==typeof t&&e)return 0==(t=t.trim()).indexOf("<");{let n=(t?t.ownerDocument||t:0).documentElement;return!!n&&"HTML"!==n.nodeName}},_isDomVisible:function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)},_isVisible:function(t){var e,n,a,s;if(!t)return!1;let r=window.getComputedStyle(t);if("hidden"===(n=r).visibility||"none"===n.display)return!1;let l,h,c,d,u,p;return a=t,s=r,h=(l=a.getBoundingClientRect()).left+1,c=l.right-1,d=l.top+1,l.bottom,u=!0,p=a.style.pointerEvents,"none"==s["pointer-events"]&&(a.style.pointerEvents="auto"),document.elementFromPoint(h,d)!==a&&(u=!1),document.elementFromPoint(c,d)!==a&&(u=!1),a.style.pointerEvents=p,!!u},_lazyLoadJS:function(t,e,n){return!1!==e&&this.options.lazyLoadJS?n instanceof Promise?n:new Promise((e,n)=>{let a=document.createElement("script");a.addEventListener("load",e,{once:!0}),a.src=t,document.head.appendChild(a)}):Promise.resolve()},_mouseenterHandler:function(){this._fireEvt("elechart_enter",null,!0)},_mousemoveHandler:function(t,e,n){if(!this._data||0===this._data.length||!this._chartEnabled)return;let a=d3.mouse(this._focusRect.node())[0],s=this._data[this._findItemForX(a)];this._hidePositionMarker(),this._showDiagramIndicator(s,a),this._showPositionMarker(s),this._setMapView(s),this._map&&this._map._container&&L.DomUtil.addClass(this._map._container,"elechart-hover"),this._fireEvt("elechart_change",{data:s},!0),this._fireEvt("elechart_hover",{data:s},!0)},_mousemoveLayerHandler:function(t){if(!this._data||0===this._data.length)return;let e=t.latlng,n=this._findItemForLatLng(e);if(n){let a=n.xDiagCoord;this._hidePositionMarker(),this._showDiagramIndicator(n,a),this._showPositionMarker(n)}},_mouseoutHandler:function(){this.options.detached||this._hidePositionMarker(),this._map&&this._map._container&&L.DomUtil.removeClass(this._map._container,"elechart-hover"),this._fireEvt("elechart_leave",null,!0)},_mousewheelHandler:function(t){if(this._map.gestureHandling&&this._map.gestureHandling._enabled)return;let e=this._selectedItem?this._selectedItem.latlng:this._map.getCenter(),n=t.deltaY>0?this._map.getZoom()-1:this._map.getZoom()+1;this._resetDrag(),this._map.flyTo(e,n)},_resetDrag:function(){this._dragRectangleG&&(this._dragRectangleG.remove(),this._dragRectangleG=null,this._dragRectangle=null,this._hidePositionMarker())},_resetView:function(){this._map&&this._map._isFullscreen||(this._resetDrag(),this._hidePositionMarker(),this.fitBounds(this._fullExtent))},_resizeChart:function(){if(this.options.responsive){if(this.options.detached){let t=this.eleDiv.offsetWidth;t<=0||(this.options.width=t,this.eleDiv.innerHTML="",this.eleDiv.appendChild(this.onAdd(this._map)))}else this._map.removeControl(this._container),this.addTo(this._map)}},_saveFile:function(t){let e=document,n=e.createElement("a"),a=e.body;n.href=t,n.target="_new",n.download="",n.style.display="none",a.appendChild(n),n.click(),a.removeChild(n)},_showDiagramIndicator:function(t,e){if(!this._chartEnabled)return;let n=this.options;this._focusG.style("visibility","visible"),this._mousefocus.attr("x1",e).attr("y1",0).attr("x2",e).attr("y2",this._height()).classed("hidden",!1);let a=t.z,s=t.dist,r=(t.latlng,n.hoverNumber.formatter(a,n.hoverNumber.decimalsY)),l=n.hoverNumber.formatter(s,n.hoverNumber.decimalsX);this._focuslabeltext.attr("y",this._y(t.z)).style("font-weight","700"),this._focuslabelX.text(l+" "+this._xLabel).attr("x",e+10),this._focuslabelY.text(r+" "+this._yLabel).attr("x",e+10);let h=this._focuslabeltext.node();if(this._isDomVisible(h)){let c=h.getBBox();this._focuslabelrect.attr("x",c.x-2).attr("y",c.y-2).attr("width",c.width+4).attr("height",c.height+4),e>=this._width()/2&&(this._focuslabelrect.attr("x",this._focuslabelrect.attr("x")-this._focuslabelrect.attr("width")-4-10),this._focuslabelX.attr("x",this._focuslabelX.attr("x")-this._focuslabelrect.attr("width")-4-10),this._focuslabelY.attr("x",this._focuslabelY.attr("x")-this._focuslabelrect.attr("width")-4-10))}},_toggle:function(){L.DomUtil.hasClass(this._container,"elevation-expanded")?this._collapse():this._expand()},_setMapView:function(t){if(!this.options.followMarker||!this._map)return;let e=this._map.getZoom();e=e'+L._("Total Length: ")+''+this.track_info.distance.toFixed(2)+" "+this._xLabel+''+L._("Max Elevation: ")+''+this.track_info.elevation_max.toFixed(2)+" "+this._yLabel+''+L._("Min Elevation: ")+''+this.track_info.elevation_min.toFixed(2)+" "+this._yLabel+''+L._("Total Ascent: ")+''+this.track_info.ascent.toFixed(0)+" "+this._yLabel+''+L._("Total Descent: ")+''+this.track_info.descent.toFixed(0)+" "+this._yLabel+""),this.options.downloadLink&&this._downloadURL&&(this.summaryDiv.innerHTML+=''+L._("Download")+"",this.summaryDiv.querySelector(".download a").onclick=(function(t){t.preventDefault();let e={confirm:this._saveFile.bind(this,this._downloadURL)},n=this.options.downloadLink;"modal"==n?("function"==typeof CustomEvent&&document.dispatchEvent(new CustomEvent("eletrack_download",{detail:e})),this._fireEvt("eletrack_download",e)):("link"==n||!0===n)&&e.confirm()}).bind(this))},_width:function(){let t=this.options;return t.width-t.margins.left-t.margins.right}}),L.control.elevation=function(t){return new L.Control.Elevation(t)}}),function(t,e){"function"==typeof define&&define.amd?define(["leaflet"],t):"object"==typeof exports&&(module.exports=t(require("leaflet"))),void 0!==e&&e.L&&t(e.L)}(function(t){Waymark_L.Editable=Waymark_L.Evented.extend({statics:{FORWARD:1,BACKWARD:-1},options:{zIndex:1e3,polygonClass:Waymark_L.Polygon,polylineClass:Waymark_L.Polyline,markerClass:Waymark_L.Marker,rectangleClass:Waymark_L.Rectangle,circleClass:Waymark_L.Circle,drawingCSSClass:"leaflet-editable-drawing",drawingCursor:"crosshair",editLayer:void 0,featuresLayer:void 0,polylineEditorClass:void 0,polygonEditorClass:void 0,markerEditorClass:void 0,rectangleEditorClass:void 0,circleEditorClass:void 0,lineGuideOptions:{},skipMiddleMarkers:!1},initialize:function(t,e){Waymark_L.setOptions(this,e),this._lastZIndex=this.options.zIndex,this.map=t,this.editLayer=this.createEditLayer(),this.featuresLayer=this.createFeaturesLayer(),this.forwardLineGuide=this.createLineGuide(),this.backwardLineGuide=this.createLineGuide()},fireAndForward:function(t,e){(e=e||{}).editTools=this,this.fire(t,e),this.map.fire(t,e)},createLineGuide:function(){var t=Waymark_L.extend({dashArray:"5,10",weight:1,interactive:!1},this.options.lineGuideOptions);return Waymark_L.polyline([],t)},createVertexIcon:function(t){return Waymark_L.Browser.mobile&&Waymark_L.Browser.touch?new Waymark_L.Editable.TouchVertexIcon(t):new Waymark_L.Editable.VertexIcon(t)},createEditLayer:function(){return this.options.editLayer||new Waymark_L.LayerGroup().addTo(this.map)},createFeaturesLayer:function(){return this.options.featuresLayer||new Waymark_L.LayerGroup().addTo(this.map)},moveForwardLineGuide:function(t){this.forwardLineGuide._latlngs.length&&(this.forwardLineGuide._latlngs[1]=t,this.forwardLineGuide._bounds.extend(t),this.forwardLineGuide.redraw())},moveBackwardLineGuide:function(t){this.backwardLineGuide._latlngs.length&&(this.backwardLineGuide._latlngs[1]=t,this.backwardLineGuide._bounds.extend(t),this.backwardLineGuide.redraw())},anchorForwardLineGuide:function(t){this.forwardLineGuide._latlngs[0]=t,this.forwardLineGuide._bounds.extend(t),this.forwardLineGuide.redraw()},anchorBackwardLineGuide:function(t){this.backwardLineGuide._latlngs[0]=t,this.backwardLineGuide._bounds.extend(t),this.backwardLineGuide.redraw()},attachForwardLineGuide:function(){this.editLayer.addLayer(this.forwardLineGuide)},attachBackwardLineGuide:function(){this.editLayer.addLayer(this.backwardLineGuide)},detachForwardLineGuide:function(){this.forwardLineGuide.setLatLngs([]),this.editLayer.removeLayer(this.forwardLineGuide)},detachBackwardLineGuide:function(){this.backwardLineGuide.setLatLngs([]),this.editLayer.removeLayer(this.backwardLineGuide)},blockEvents:function(){this._oldTargets||(this._oldTargets=this.map._targets,this.map._targets={})},unblockEvents:function(){this._oldTargets&&(this.map._targets=Waymark_L.extend(this.map._targets,this._oldTargets),delete this._oldTargets)},registerForDrawing:function(t){this._drawingEditor&&this.unregisterForDrawing(this._drawingEditor),this.blockEvents(),t.reset(),this._drawingEditor=t,this.map.on("mousemove touchmove",t.onDrawingMouseMove,t),this.map.on("mousedown",this.onMousedown,this),this.map.on("mouseup",this.onMouseup,this),Waymark_L.DomUtil.addClass(this.map._container,this.options.drawingCSSClass),this.defaultMapCursor=this.map._container.style.cursor,this.map._container.style.cursor=this.options.drawingCursor},unregisterForDrawing:function(t){this.unblockEvents(),Waymark_L.DomUtil.removeClass(this.map._container,this.options.drawingCSSClass),this.map._container.style.cursor=this.defaultMapCursor,(t=t||this._drawingEditor)&&(this.map.off("mousemove touchmove",t.onDrawingMouseMove,t),this.map.off("mousedown",this.onMousedown,this),this.map.off("mouseup",this.onMouseup,this),t===this._drawingEditor&&(delete this._drawingEditor,t._drawing&&t.cancelDrawing()))},onMousedown:function(t){1==t.originalEvent.which&&(this._mouseDown=t,this._drawingEditor.onDrawingMouseDown(t))},onMouseup:function(t){if(this._mouseDown){var e=this._drawingEditor,n=this._mouseDown;if(this._mouseDown=null,e.onDrawingMouseUp(t),this._drawingEditor===e){var a=Waymark_L.point(n.originalEvent.clientX,n.originalEvent.clientY);Math.abs(Waymark_L.point(t.originalEvent.clientX,t.originalEvent.clientY).distanceTo(a))<9*(window.devicePixelRatio||1)&&this._drawingEditor.onDrawingClick(t)}}},drawing:function(){return this._drawingEditor&&this._drawingEditor.drawing()},stopDrawing:function(){this.unregisterForDrawing()},commitDrawing:function(t){this._drawingEditor&&this._drawingEditor.commitDrawing(t)},connectCreatedToMap:function(t){return this.featuresLayer.addLayer(t)},startPolyline:function(t,e){var n=this.createPolyline([],e);return n.enableEdit(this.map).newShape(t),n},startPolygon:function(t,e){var n=this.createPolygon([],e);return n.enableEdit(this.map).newShape(t),n},startMarker:function(t,e){t=t||this.map.getCenter().clone();var n=this.createMarker(t,e);return n.enableEdit(this.map).startDrawing(),n},startRectangle:function(t,e){var n=t||Waymark_L.latLng([0,0]),a=new Waymark_L.LatLngBounds(n,n),s=this.createRectangle(a,e);return s.enableEdit(this.map).startDrawing(),s},startCircle:function(t,e){t=t||this.map.getCenter().clone();var n=this.createCircle(t,e);return n.enableEdit(this.map).startDrawing(),n},startHole:function(t,e){t.newHole(e)},createLayer:function(t,e,n){n=Waymark_L.Util.extend({editOptions:{editTools:this}},n);var a=new t(e,n);return this.fireAndForward("editable:created",{layer:a}),a},createPolyline:function(t,e){return this.createLayer(e&&e.polylineClass||this.options.polylineClass,t,e)},createPolygon:function(t,e){return this.createLayer(e&&e.polygonClass||this.options.polygonClass,t,e)},createMarker:function(t,e){return this.createLayer(e&&e.markerClass||this.options.markerClass,t,e)},createRectangle:function(t,e){return this.createLayer(e&&e.rectangleClass||this.options.rectangleClass,t,e)},createCircle:function(t,e){return this.createLayer(e&&e.circleClass||this.options.circleClass,t,e)}}),Waymark_L.extend(Waymark_L.Editable,{makeCancellable:function(t){t.cancel=function(){t._cancelled=!0}}}),Waymark_L.Map.mergeOptions({editToolsClass:Waymark_L.Editable,editable:!1,editOptions:{}}),Waymark_L.Map.addInitHook(function(){this.whenReady(function(){this.options.editable&&(this.editTools=new this.options.editToolsClass(this,this.options.editOptions))})}),Waymark_L.Editable.VertexIcon=Waymark_L.DivIcon.extend({options:{iconSize:new Waymark_L.Point(8,8)}}),Waymark_L.Editable.TouchVertexIcon=Waymark_L.Editable.VertexIcon.extend({options:{iconSize:new Waymark_L.Point(20,20)}}),Waymark_L.Editable.VertexMarker=Waymark_L.Marker.extend({options:{draggable:!0,className:"leaflet-div-icon leaflet-vertex-icon"},initialize:function(t,e,n,a){this.latlng=t,this.latlngs=e,this.editor=n,Waymark_L.Marker.prototype.initialize.call(this,t,a),this.options.icon=this.editor.tools.createVertexIcon({className:this.options.className}),this.latlng.__vertex=this,this.editor.editLayer.addLayer(this),this.setZIndexOffset(n.tools._lastZIndex+1)},onAdd:function(t){Waymark_L.Marker.prototype.onAdd.call(this,t),this.on("drag",this.onDrag),this.on("dragstart",this.onDragStart),this.on("dragend",this.onDragEnd),this.on("mouseup",this.onMouseup),this.on("click",this.onClick),this.on("contextmenu",this.onContextMenu),this.on("mousedown touchstart",this.onMouseDown),this.on("mouseover",this.onMouseOver),this.on("mouseout",this.onMouseOut),this.addMiddleMarkers()},onRemove:function(t){this.middleMarker&&this.middleMarker.delete(),delete this.latlng.__vertex,this.off("drag",this.onDrag),this.off("dragstart",this.onDragStart),this.off("dragend",this.onDragEnd),this.off("mouseup",this.onMouseup),this.off("click",this.onClick),this.off("contextmenu",this.onContextMenu),this.off("mousedown touchstart",this.onMouseDown),this.off("mouseover",this.onMouseOver),this.off("mouseout",this.onMouseOut),Waymark_L.Marker.prototype.onRemove.call(this,t)},onDrag:function(t){t.vertex=this,this.editor.onVertexMarkerDrag(t);var e=Waymark_L.DomUtil.getPosition(this._icon),n=this._map.layerPointToLatLng(e);this.latlng.update(n),this._latlng=this.latlng,this.editor.refresh(),this.middleMarker&&this.middleMarker.updateLatLng();var a=this.getNext();a&&a.middleMarker&&a.middleMarker.updateLatLng()},onDragStart:function(t){t.vertex=this,this.editor.onVertexMarkerDragStart(t)},onDragEnd:function(t){t.vertex=this,this.editor.onVertexMarkerDragEnd(t)},onClick:function(t){t.vertex=this,this.editor.onVertexMarkerClick(t)},onMouseup:function(t){Waymark_L.DomEvent.stop(t),t.vertex=this,this.editor.map.fire("mouseup",t)},onContextMenu:function(t){t.vertex=this,this.editor.onVertexMarkerContextMenu(t)},onMouseDown:function(t){t.vertex=this,this.editor.onVertexMarkerMouseDown(t)},onMouseOver:function(t){t.vertex=this,this.editor.onVertexMarkerMouseOver(t)},onMouseOut:function(t){t.vertex=this,this.editor.onVertexMarkerMouseOut(t)},delete:function(){var t=this.getNext();this.latlngs.splice(this.getIndex(),1),this.editor.editLayer.removeLayer(this),this.editor.onVertexDeleted({latlng:this.latlng,vertex:this}),this.latlngs.length||this.editor.deleteShape(this.latlngs),t&&t.resetMiddleMarker(),this.editor.refresh()},getIndex:function(){return this.latlngs.indexOf(this.latlng)},getLastIndex:function(){return this.latlngs.length-1},getPrevious:function(){if(!(this.latlngs.length<2)){var t=this.getIndex(),e=t-1;0===t&&this.editor.CLOSED&&(e=this.getLastIndex());var n=this.latlngs[e];if(n)return n.__vertex}},getNext:function(){if(!(this.latlngs.length<2)){var t=this.getIndex(),e=t+1;t===this.getLastIndex()&&this.editor.CLOSED&&(e=0);var n=this.latlngs[e];if(n)return n.__vertex}},addMiddleMarker:function(t){this.editor.hasMiddleMarkers()&&(t=t||this.getPrevious())&&!this.middleMarker&&(this.middleMarker=this.editor.addMiddleMarker(t,this,this.latlngs,this.editor))},addMiddleMarkers:function(){if(this.editor.hasMiddleMarkers()){var t=this.getPrevious();t&&this.addMiddleMarker(t);var e=this.getNext();e&&e.resetMiddleMarker()}},resetMiddleMarker:function(){this.middleMarker&&this.middleMarker.delete(),this.addMiddleMarker()},split:function(){this.editor.splitShape&&this.editor.splitShape(this.latlngs,this.getIndex())},continue:function(){if(this.editor.continueBackward){var t=this.getIndex();0===t?this.editor.continueBackward(this.latlngs):t===this.getLastIndex()&&this.editor.continueForward(this.latlngs)}}}),Waymark_L.Editable.mergeOptions({vertexMarkerClass:Waymark_L.Editable.VertexMarker}),Waymark_L.Editable.MiddleMarker=Waymark_L.Marker.extend({options:{opacity:.5,className:"leaflet-div-icon leaflet-middle-icon",draggable:!0},initialize:function(t,e,n,a,s){this.left=t,this.right=e,this.editor=a,this.latlngs=n,Waymark_L.Marker.prototype.initialize.call(this,this.computeLatLng(),s),this._opacity=this.options.opacity,this.options.icon=this.editor.tools.createVertexIcon({className:this.options.className}),this.editor.editLayer.addLayer(this),this.setVisibility()},setVisibility:function(){var t=this._map.latLngToContainerPoint(this.left.latlng),e=this._map.latLngToContainerPoint(this.right.latlng),n=Waymark_L.point(this.options.icon.options.iconSize);t.distanceTo(e)<3*n.x?this.hide():this.show()},show:function(){this.setOpacity(this._opacity)},hide:function(){this.setOpacity(0)},updateLatLng:function(){this.setLatLng(this.computeLatLng()),this.setVisibility()},computeLatLng:function(){var t=this.editor.map.latLngToContainerPoint(this.left.latlng),e=this.editor.map.latLngToContainerPoint(this.right.latlng),n=(t.y+e.y)/2,a=(t.x+e.x)/2;return this.editor.map.containerPointToLatLng([a,n])},onAdd:function(t){Waymark_L.Marker.prototype.onAdd.call(this,t),Waymark_L.DomEvent.on(this._icon,"mousedown touchstart",this.onMouseDown,this),t.on("zoomend",this.setVisibility,this)},onRemove:function(t){delete this.right.middleMarker,Waymark_L.DomEvent.off(this._icon,"mousedown touchstart",this.onMouseDown,this),t.off("zoomend",this.setVisibility,this),Waymark_L.Marker.prototype.onRemove.call(this,t)},onMouseDown:function(t){var e=Waymark_L.DomUtil.getPosition(this._icon);if(t={originalEvent:t,latlng:this.editor.map.layerPointToLatLng(e)},0!==this.options.opacity&&(Waymark_L.Editable.makeCancellable(t),this.editor.onMiddleMarkerMouseDown(t),!t._cancelled)){this.latlngs.splice(this.index(),0,t.latlng),this.editor.refresh();var n=this._icon,a=this.editor.addVertexMarker(t.latlng,this.latlngs);this.editor.onNewVertex(a);var s=a._icon.parentNode;s.removeChild(a._icon),a._icon=n,s.appendChild(a._icon),a._initIcon(),a._initInteraction(),a.setOpacity(1),Waymark_L.Draggable._dragging=!1,a.dragging._draggable._onDown(t.originalEvent),this.delete()}},delete:function(){this.editor.editLayer.removeLayer(this)},index:function(){return this.latlngs.indexOf(this.right.latlng)}}),Waymark_L.Editable.mergeOptions({middleMarkerClass:Waymark_L.Editable.MiddleMarker}),Waymark_L.Editable.BaseEditor=Waymark_L.Handler.extend({initialize:function(t,e,n){Waymark_L.setOptions(this,n),this.map=t,this.feature=e,this.feature.editor=this,this.editLayer=new Waymark_L.LayerGroup,this.tools=this.options.editTools||t.editTools},addHooks:function(){this.isConnected()?this.onFeatureAdd():this.feature.once("add",this.onFeatureAdd,this),this.onEnable(),this.feature.on(this._getEvents(),this)},removeHooks:function(){this.feature.off(this._getEvents(),this),this.feature.dragging&&this.feature.dragging.disable(),this.editLayer.clearLayers(),this.tools.editLayer.removeLayer(this.editLayer),this.onDisable(),this._drawing&&this.cancelDrawing()},drawing:function(){return!!this._drawing},reset:function(){},onFeatureAdd:function(){this.tools.editLayer.addLayer(this.editLayer),this.feature.dragging&&this.feature.dragging.enable()},hasMiddleMarkers:function(){return!this.options.skipMiddleMarkers&&!this.tools.options.skipMiddleMarkers},fireAndForward:function(t,e){(e=e||{}).layer=this.feature,this.feature.fire(t,e),this.tools.fireAndForward(t,e)},onEnable:function(){this.fireAndForward("editable:enable")},onDisable:function(){this.fireAndForward("editable:disable")},onEditing:function(){this.fireAndForward("editable:editing")},onStartDrawing:function(){this.fireAndForward("editable:drawing:start")},onEndDrawing:function(){this.fireAndForward("editable:drawing:end")},onCancelDrawing:function(){this.fireAndForward("editable:drawing:cancel")},onCommitDrawing:function(t){this.fireAndForward("editable:drawing:commit",t)},onDrawingMouseDown:function(t){this.fireAndForward("editable:drawing:mousedown",t)},onDrawingMouseUp:function(t){this.fireAndForward("editable:drawing:mouseup",t)},startDrawing:function(){this._drawing||(this._drawing=Waymark_L.Editable.FORWARD),this.tools.registerForDrawing(this),this.onStartDrawing()},commitDrawing:function(t){this.onCommitDrawing(t),this.endDrawing()},cancelDrawing:function(){Waymark_L.Draggable._dragging=!1,this.onCancelDrawing(),this.endDrawing()},endDrawing:function(){this._drawing=!1,this.tools.unregisterForDrawing(this),this.onEndDrawing()},onDrawingClick:function(t){this.drawing()&&(Waymark_L.Editable.makeCancellable(t),this.fireAndForward("editable:drawing:click",t),t._cancelled||(this.isConnected()||this.connect(t),this.processDrawingClick(t)))},isConnected:function(){return this.map.hasLayer(this.feature)},connect:function(){this.tools.connectCreatedToMap(this.feature),this.tools.editLayer.addLayer(this.editLayer)},onMove:function(t){this.fireAndForward("editable:drawing:move",t)},onDrawingMouseMove:function(t){this.onMove(t)},_getEvents:function(){return{dragstart:this.onDragStart,drag:this.onDrag,dragend:this.onDragEnd,remove:this.disable}},onDragStart:function(t){this.onEditing(),this.fireAndForward("editable:dragstart",t)},onDrag:function(t){this.onMove(t),this.fireAndForward("editable:drag",t)},onDragEnd:function(t){this.fireAndForward("editable:dragend",t)}}),Waymark_L.Editable.MarkerEditor=Waymark_L.Editable.BaseEditor.extend({onDrawingMouseMove:function(t){Waymark_L.Editable.BaseEditor.prototype.onDrawingMouseMove.call(this,t),this._drawing&&this.feature.setLatLng(t.latlng)},processDrawingClick:function(t){this.fireAndForward("editable:drawing:clicked",t),this.commitDrawing(t)},connect:function(t){t&&(this.feature._latlng=t.latlng),Waymark_L.Editable.BaseEditor.prototype.connect.call(this,t)}}),Waymark_L.Editable.PathEditor=Waymark_L.Editable.BaseEditor.extend({CLOSED:!1,MIN_VERTEX:2,addHooks:function(){return Waymark_L.Editable.BaseEditor.prototype.addHooks.call(this),this.feature&&this.initVertexMarkers(),this},initVertexMarkers:function(t){if(this.enabled()){if(a(t=t||this.getLatLngs()))this.addVertexMarkers(t);else for(var e=0;e=this.MIN_VERTEX-1&&(e=!0):0===n&&this._drawing===Waymark_L.Editable.BACKWARD&&this._drawnLatLngs.length>=this.MIN_VERTEX?e=!0:0===n&&this._drawing===Waymark_L.Editable.FORWARD&&this._drawnLatLngs.length>=this.MIN_VERTEX&&this.CLOSED?e=!0:this.onVertexRawMarkerClick(t),this.fireAndForward("editable:vertex:clicked",t),e&&this.commitDrawing(t)}},onVertexRawMarkerClick:function(t){this.fireAndForward("editable:vertex:rawclick",t),!t._cancelled&&this.vertexCanBeDeleted(t.vertex)&&t.vertex.delete()},vertexCanBeDeleted:function(t){return t.latlngs.length>this.MIN_VERTEX},onVertexDeleted:function(t){this.fireAndForward("editable:vertex:deleted",t)},onVertexMarkerCtrlClick:function(t){this.fireAndForward("editable:vertex:ctrlclick",t)},onVertexMarkerShiftClick:function(t){this.fireAndForward("editable:vertex:shiftclick",t)},onVertexMarkerMetaKeyClick:function(t){this.fireAndForward("editable:vertex:metakeyclick",t)},onVertexMarkerAltClick:function(t){this.fireAndForward("editable:vertex:altclick",t)},onVertexMarkerContextMenu:function(t){this.fireAndForward("editable:vertex:contextmenu",t)},onVertexMarkerMouseDown:function(t){this.fireAndForward("editable:vertex:mousedown",t)},onVertexMarkerMouseOver:function(t){this.fireAndForward("editable:vertex:mouseover",t)},onVertexMarkerMouseOut:function(t){this.fireAndForward("editable:vertex:mouseout",t)},onMiddleMarkerMouseDown:function(t){this.fireAndForward("editable:middlemarker:mousedown",t)},onVertexMarkerDrag:function(t){this.onMove(t),this.feature._bounds&&this.extendBounds(t),this.fireAndForward("editable:vertex:drag",t)},onVertexMarkerDragStart:function(t){this.fireAndForward("editable:vertex:dragstart",t)},onVertexMarkerDragEnd:function(t){this.fireAndForward("editable:vertex:dragend",t)},setDrawnLatLngs:function(t){this._drawnLatLngs=t||this.getDefaultLatLngs()},startDrawing:function(){this._drawnLatLngs||this.setDrawnLatLngs(),Waymark_L.Editable.BaseEditor.prototype.startDrawing.call(this)},startDrawingForward:function(){this.startDrawing()},endDrawing:function(){this.tools.detachForwardLineGuide(),this.tools.detachBackwardLineGuide(),this._drawnLatLngs&&this._drawnLatLngs.length0&&(this.tools.attachBackwardLineGuide(),this.tools.anchorBackwardLineGuide(t[0])),this.startDrawingBackward())},continueForward:function(t){this.drawing()||(t=t||this.getDefaultLatLngs(),this.setDrawnLatLngs(t),t.length>0&&(this.tools.attachForwardLineGuide(),this.tools.anchorForwardLineGuide(t[t.length-1])),this.startDrawingForward())},getDefaultLatLngs:function(t){return!(t=t||this.feature._latlngs).length||t[0]instanceof Waymark_L.LatLng?t:this.getDefaultLatLngs(t[0])},ensureMulti:function(){this.feature._latlngs.length&&a(this.feature._latlngs)&&(this.feature._latlngs=[this.feature._latlngs])},addNewEmptyShape:function(){if(!this.feature._latlngs.length)return this.feature._latlngs;var t=[];return this.appendShape(t),t},formatShape:function(t){return a(t)?t:t[0]?this.formatShape(t[0]):void 0},splitShape:function(t,e){if(e&&!(e>=t.length-1)){this.ensureMulti();var n=this.feature._latlngs.indexOf(t);if(-1!==n){var a=t.slice(0,e+1),s=t.slice(e);s[0]=Waymark_L.latLng(s[0].lat,s[0].lng,s[0].alt),this.feature._latlngs.splice(n,1,a,s),this.refresh(),this.reset()}}}}),Waymark_L.Editable.PolygonEditor=Waymark_L.Editable.PathEditor.extend({CLOSED:!0,MIN_VERTEX:3,newPointForward:function(t){Waymark_L.Editable.PathEditor.prototype.newPointForward.call(this,t),this.tools.backwardLineGuide._latlngs.length||this.tools.anchorBackwardLineGuide(t),2===this._drawnLatLngs.length&&this.tools.attachBackwardLineGuide()},addNewEmptyHole:function(t){this.ensureNotFlat();var e=this.feature.shapeAt(t);if(e){var n=[];return e.push(n),n}},newHole:function(t){var e=this.addNewEmptyHole(t);e&&(this.setDrawnLatLngs(e),this.startDrawingForward(),t&&this.newPointForward(t))},addNewEmptyShape:function(){if(!this.feature._latlngs.length||!this.feature._latlngs[0].length)return this.feature._latlngs;var t=[];return this.appendShape(t),t},ensureMulti:function(){this.feature._latlngs.length&&a(this.feature._latlngs[0])&&(this.feature._latlngs=[this.feature._latlngs])},ensureNotFlat:function(){(!this.feature._latlngs.length||a(this.feature._latlngs))&&(this.feature._latlngs=[this.feature._latlngs])},vertexCanBeDeleted:function(t){var e=this.feature.parentShape(t.latlngs);return Waymark_L.Util.indexOf(e,t.latlngs)>0||Waymark_L.Editable.PathEditor.prototype.vertexCanBeDeleted.call(this,t)},getDefaultLatLngs:function(){return this.feature._latlngs.length||this.feature._latlngs.push([]),this.feature._latlngs[0]},formatShape:function(t){return a(t)&&(!t[0]||0!==t[0].length)?[t]:t}}),Waymark_L.Editable.RectangleEditor=Waymark_L.Editable.PathEditor.extend({CLOSED:!0,MIN_VERTEX:4,options:{skipMiddleMarkers:!0},extendBounds:function(t){var e=t.vertex.getIndex(),n=t.vertex.getNext(),a=t.vertex.getPrevious(),s=t.vertex.latlngs[(e+2)%4],r=new Waymark_L.LatLngBounds(t.latlng,s);a.latlng.update([t.latlng.lat,s.lng]),n.latlng.update([s.lat,t.latlng.lng]),this.updateBounds(r),this.refreshVertexMarkers()},onDrawingMouseDown:function(t){Waymark_L.Editable.PathEditor.prototype.onDrawingMouseDown.call(this,t),this.connect();var e=this.getDefaultLatLngs();3===e.length&&e.push(t.latlng);var n=new Waymark_L.LatLngBounds(t.latlng,t.latlng);this.updateBounds(n),this.updateLatLngs(n),this.refresh(),this.reset(),t.originalEvent._simulated=!1,this.map.dragging._draggable._onUp(t.originalEvent),e[3].__vertex.dragging._draggable._onDown(t.originalEvent)},onDrawingMouseUp:function(t){this.commitDrawing(t),t.originalEvent._simulated=!1,Waymark_L.Editable.PathEditor.prototype.onDrawingMouseUp.call(this,t)},onDrawingMouseMove:function(t){t.originalEvent._simulated=!1,Waymark_L.Editable.PathEditor.prototype.onDrawingMouseMove.call(this,t)},getDefaultLatLngs:function(t){return t||this.feature._latlngs[0]},updateBounds:function(t){this.feature._bounds=t},updateLatLngs:function(t){for(var e=this.getDefaultLatLngs(),n=this.feature._boundsToLatLngs(t),a=0;at.lat!=a.lat>t.lat&&t.lng<(a.lng-n.lng)*(t.lat-n.lat)/(a.lat-n.lat)+n.lng&&(h=!h);return h},parentShape:function(t,e){if(e=e||this._latlngs){var n=Waymark_L.Util.indexOf(e,t);if(-1!==n)return e;for(var a=0;a=n;)e=e.__parent;return this._currentShownBounds.contains(e.getLatLng())&&(this.options.animateAddingMarkers?this._animationAddLayer(t,e):this._animationAddLayerNonAnimated(t,e)),this},removeLayer:function(t){return t instanceof L.LayerGroup?this.removeLayers([t]):t.getLatLng?this._map?(t.__parent&&(this._unspiderfy&&(this._unspiderfy(),this._unspiderfyLayer(t)),this._removeLayer(t,!0),this.fire("layerremove",{layer:t}),this._topClusterLevel._recalculateBounds(),this._refreshClustersIcons(),t.off(this._childMarkerEventHandlers,this),this._featureGroup.hasLayer(t)&&(this._featureGroup.removeLayer(t),t.clusterShow&&t.clusterShow())),this):(!this._arraySplice(this._needsClustering,t)&&this.hasLayer(t)&&this._needsRemoving.push({layer:t,latlng:t._latlng}),this.fire("layerremove",{layer:t}),this):(this._nonPointGroup.removeLayer(t),this.fire("layerremove",{layer:t}),this)},addLayers:function(t,e){if(!L.Util.isArray(t))return this.addLayer(t);var n,a=this._featureGroup,s=this._nonPointGroup,r=this.options.chunkedLoading,l=this.options.chunkInterval,h=this.options.chunkProgress,c=t.length,d=0,u=!0;if(this._map){var p=(new Date).getTime(),m=L.bind(function(){for(var f=(new Date).getTime();c>d&&!(r&&0==d%200&&(new Date).getTime()-f>l);d++){if((n=t[d])instanceof L.LayerGroup)u&&(t=t.slice(),u=!1),this._extractNonGroupLayers(n,t),c=t.length;else if(n.getLatLng){if(!this.hasLayer(n)&&(this._addLayer(n,this._maxZoom),e||this.fire("layeradd",{layer:n}),n.__parent&&2===n.__parent.getChildCount())){var g=n.__parent.getAllChildMarkers(),y=g[0]===n?g[1]:g[0];a.removeLayer(y)}}else s.addLayer(n),e||this.fire("layeradd",{layer:n})}h&&h(d,c,(new Date).getTime()-p),d===c?(this._topClusterLevel._recalculateBounds(),this._refreshClustersIcons(),this._topClusterLevel._recursivelyAddChildrenToMap(null,this._zoom,this._currentShownBounds)):setTimeout(m,this.options.chunkDelay)},this);m()}else for(var f=this._needsClustering;c>d;d++)(n=t[d])instanceof L.LayerGroup?(u&&(t=t.slice(),u=!1),this._extractNonGroupLayers(n,t),c=t.length):n.getLatLng?this.hasLayer(n)||f.push(n):s.addLayer(n);return this},removeLayers:function(t){var e,n,a=t.length,s=this._featureGroup,r=this._nonPointGroup,l=!0;if(!this._map){for(e=0;a>e;e++)(n=t[e])instanceof L.LayerGroup?(l&&(t=t.slice(),l=!1),this._extractNonGroupLayers(n,t),a=t.length):(this._arraySplice(this._needsClustering,n),r.removeLayer(n),this.hasLayer(n)&&this._needsRemoving.push({layer:n,latlng:n._latlng}),this.fire("layerremove",{layer:n}));return this}if(this._unspiderfy){this._unspiderfy();var h=t.slice(),c=a;for(e=0;c>e;e++)(n=h[e])instanceof L.LayerGroup?(this._extractNonGroupLayers(n,h),c=h.length):this._unspiderfyLayer(n)}for(e=0;a>e;e++)(n=t[e])instanceof L.LayerGroup?(l&&(t=t.slice(),l=!1),this._extractNonGroupLayers(n,t),a=t.length):n.__parent?(this._removeLayer(n,!0,!0),this.fire("layerremove",{layer:n}),s.hasLayer(n)&&(s.removeLayer(n),n.clusterShow&&n.clusterShow())):(r.removeLayer(n),this.fire("layerremove",{layer:n}));return this._topClusterLevel._recalculateBounds(),this._refreshClustersIcons(),this._topClusterLevel._recursivelyAddChildrenToMap(null,this._zoom,this._currentShownBounds),this},clearLayers:function(){return this._map||(this._needsClustering=[],this._needsRemoving=[],delete this._gridClusters,delete this._gridUnclustered),this._noanimationUnspiderfy&&this._noanimationUnspiderfy(),this._featureGroup.clearLayers(),this._nonPointGroup.clearLayers(),this.eachLayer(function(t){t.off(this._childMarkerEventHandlers,this),delete t.__parent},this),this._map&&this._generateInitialClusters(),this},getBounds:function(){var t=new L.LatLngBounds;this._topClusterLevel&&t.extend(this._topClusterLevel._bounds);for(var e=this._needsClustering.length-1;e>=0;e--)t.extend(this._needsClustering[e].getLatLng());return t.extend(this._nonPointGroup.getBounds()),t},eachLayer:function(t,e){var n,a,s,r=this._needsClustering.slice(),l=this._needsRemoving;for(this._topClusterLevel&&this._topClusterLevel.getAllChildMarkers(r),a=r.length-1;a>=0;a--){for(n=!0,s=l.length-1;s>=0;s--)if(l[s].layer===r[a]){n=!1;break}n&&t.call(e,r[a])}this._nonPointGroup.eachLayer(t,e)},getLayers:function(){var t=[];return this.eachLayer(function(e){t.push(e)}),t},getLayer:function(t){var e=null;return t=parseInt(t,10),this.eachLayer(function(n){L.stamp(n)===t&&(e=n)}),e},hasLayer:function(t){if(!t)return!1;var e,n=this._needsClustering;for(e=n.length-1;e>=0;e--)if(n[e]===t)return!0;for(e=(n=this._needsRemoving).length-1;e>=0;e--)if(n[e].layer===t)return!1;return!(!t.__parent||t.__parent._group!==this)||this._nonPointGroup.hasLayer(t)},zoomToShowLayer:function(t,e){"function"!=typeof e&&(e=function(){});var n=function(){!t._icon&&!t.__parent._icon||this._inZoomAnimation||(this._map.off("moveend",n,this),this.off("animationend",n,this),t._icon?e():t.__parent._icon&&(this.once("spiderfied",e,this),t.__parent.spiderfy()))};t._icon&&this._map.getBounds().contains(t.getLatLng())?e():t.__parent._zoome;e++)(a=this._needsRemoving[e]).newlatlng=a.layer._latlng,a.layer._latlng=a.latlng;for(e=0,n=this._needsRemoving.length;n>e;e++)a=this._needsRemoving[e],this._removeLayer(a.layer,!0),a.layer._latlng=a.newlatlng;this._needsRemoving=[],this._zoom=Math.round(this._map._zoom),this._currentShownBounds=this._getExpandedVisibleBounds(),this._map.on("zoomend",this._zoomEnd,this),this._map.on("moveend",this._moveEnd,this),this._spiderfierOnAdd&&this._spiderfierOnAdd(),this._bindEvents(),n=this._needsClustering,this._needsClustering=[],this.addLayers(n,!0)},onRemove:function(t){t.off("zoomend",this._zoomEnd,this),t.off("moveend",this._moveEnd,this),this._unbindEvents(),this._map._mapPane.className=this._map._mapPane.className.replace(" leaflet-cluster-anim",""),this._spiderfierOnRemove&&this._spiderfierOnRemove(),delete this._maxLat,this._hideCoverage(),this._featureGroup.remove(),this._nonPointGroup.remove(),this._featureGroup.clearLayers(),this._map=null},getVisibleParent:function(t){for(var e=t;e&&!e._icon;)e=e.__parent;return e||null},_arraySplice:function(t,e){for(var n=t.length-1;n>=0;n--)if(t[n]===e)return t.splice(n,1),!0},_removeFromGridUnclustered:function(t,e){for(var n=this._map,a=this._gridUnclustered,s=Math.floor(this._map.getMinZoom());e>=s&&a[e].removeObject(t,n.project(t.getLatLng(),e));e--);},_childMarkerDragStart:function(t){t.target.__dragStart=t.target._latlng},_childMarkerMoved:function(t){if(!this._ignoreMove&&!t.target.__dragStart){var e=t.target._popup&&t.target._popup.isOpen();this._moveChild(t.target,t.oldLatLng,t.latlng),e&&t.target.openPopup()}},_moveChild:function(t,e,n){t._latlng=e,this.removeLayer(t),t._latlng=n,this.addLayer(t)},_childMarkerDragEnd:function(t){var e=t.target.__dragStart;delete t.target.__dragStart,e&&this._moveChild(t.target,e,t.target._latlng)},_removeLayer:function(t,e,n){var a=this._gridClusters,s=this._gridUnclustered,r=this._featureGroup,l=this._map,h=Math.floor(this._map.getMinZoom());e&&this._removeFromGridUnclustered(t,this._maxZoom);var c,d=t.__parent,u=d._markers;for(this._arraySplice(u,t);d&&(d._childCount--,d._boundsNeedUpdate=!0,!(d._zoome?"small":100>e?"medium":"large",new L.DivIcon({html:""+e+"
",className:"marker-cluster"+n,iconSize:new L.Point(40,40)})},_bindEvents:function(){var t=this._map,e=this.options.spiderfyOnMaxZoom,n=this.options.showCoverageOnHover,a=this.options.zoomToBoundsOnClick;(e||a)&&this.on("clusterclick",this._zoomOrSpiderfy,this),n&&(this.on("clustermouseover",this._showCoverage,this),this.on("clustermouseout",this._hideCoverage,this),t.on("zoomend",this._hideCoverage,this))},_zoomOrSpiderfy:function(t){for(var e=t.layer,n=e;1===n._childClusters.length;)n=n._childClusters[0];n._zoom===this._maxZoom&&n._childCount===e._childCount&&this.options.spiderfyOnMaxZoom?e.spiderfy():this.options.zoomToBoundsOnClick&&e.zoomToBounds(),t.originalEvent&&13===t.originalEvent.keyCode&&this._map._container.focus()},_showCoverage:function(t){var e=this._map;this._inZoomAnimation||(this._shownPolygon&&e.removeLayer(this._shownPolygon),t.layer.getChildCount()>2&&t.layer!==this._spiderfied&&(this._shownPolygon=new L.Polygon(t.layer.getConvexHull(),this.options.polygonOptions),e.addLayer(this._shownPolygon)))},_hideCoverage:function(){this._shownPolygon&&(this._map.removeLayer(this._shownPolygon),this._shownPolygon=null)},_unbindEvents:function(){var t=this.options.spiderfyOnMaxZoom,e=this.options.showCoverageOnHover,n=this.options.zoomToBoundsOnClick,a=this._map;(t||n)&&this.off("clusterclick",this._zoomOrSpiderfy,this),e&&(this.off("clustermouseover",this._showCoverage,this),this.off("clustermouseout",this._hideCoverage,this),a.off("zoomend",this._hideCoverage,this))},_zoomEnd:function(){this._map&&(this._mergeSplitClusters(),this._zoom=Math.round(this._map._zoom),this._currentShownBounds=this._getExpandedVisibleBounds())},_moveEnd:function(){if(!this._inZoomAnimation){var t=this._getExpandedVisibleBounds();this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,Math.floor(this._map.getMinZoom()),this._zoom,t),this._topClusterLevel._recursivelyAddChildrenToMap(null,Math.round(this._map._zoom),t),this._currentShownBounds=t}},_generateInitialClusters:function(){var t=Math.ceil(this._map.getMaxZoom()),e=Math.floor(this._map.getMinZoom()),n=this.options.maxClusterRadius,a=n;"function"!=typeof n&&(a=function(){return n}),null!==this.options.disableClusteringAtZoom&&(t=this.options.disableClusteringAtZoom-1),this._maxZoom=t,this._gridClusters={},this._gridUnclustered={};for(var s=t;s>=e;s--)this._gridClusters[s]=new L.DistanceGrid(a(s)),this._gridUnclustered[s]=new L.DistanceGrid(a(s));this._topClusterLevel=new this._markerCluster(this,e-1)},_addLayer:function(t,e){var n,a,s=this._gridClusters,r=this._gridUnclustered,l=Math.floor(this._map.getMinZoom());for(this.options.singleMarkerMode&&this._overrideMarkerIcon(t),t.on(this._childMarkerEventHandlers,this);e>=l;e--){n=this._map.project(t.getLatLng(),e);var h=s[e].getNearObject(n);if(h)return h._addChild(t),void(t.__parent=h);if(h=r[e].getNearObject(n)){var c=h.__parent;c&&this._removeLayer(h,!1);var d=new this._markerCluster(this,e,h,t);s[e].addObject(d,this._map.project(d._cLatLng,e)),h.__parent=d,t.__parent=d;var u=d;for(a=e-1;a>c._zoom;a--)u=new this._markerCluster(this,a,u),s[a].addObject(u,this._map.project(h.getLatLng(),a));return c._addChild(u),void this._removeFromGridUnclustered(h,e)}r[e].addObject(t,n)}this._topClusterLevel._addChild(t),t.__parent=this._topClusterLevel},_refreshClustersIcons:function(){this._featureGroup.eachLayer(function(t){t instanceof L.MarkerCluster&&t._iconNeedsUpdate&&t._updateIcon()})},_enqueue:function(t){this._queue.push(t),this._queueTimeout||(this._queueTimeout=setTimeout(L.bind(this._processQueue,this),300))},_processQueue:function(){for(var t=0;tt?(this._animationStart(),this._animationZoomOut(this._zoom,t)):this._moveEnd()},_getExpandedVisibleBounds:function(){return this.options.removeOutsideVisibleBounds?L.Browser.mobile?this._checkBoundsMaxLat(this._map.getBounds()):this._checkBoundsMaxLat(this._map.getBounds().pad(1)):this._mapBoundsInfinite},_checkBoundsMaxLat:function(t){var e=this._maxLat;return void 0!==e&&(t.getNorth()>=e&&(t._northEast.lat=1/0),t.getSouth()<=-e&&(t._southWest.lat=-1/0)),t},_animationAddLayerNonAnimated:function(t,e){if(e===t)this._featureGroup.addLayer(t);else if(2===e._childCount){e._addToMap();var n=e.getAllChildMarkers();this._featureGroup.removeLayer(n[0]),this._featureGroup.removeLayer(n[1])}else e._updateIcon()},_extractNonGroupLayers:function(t,e){var n,a=t.getLayers(),s=0;for(e=e||[];s=0;n--)l=c[n],a.contains(l._latlng)||s.removeLayer(l)}),this._forceLayout(),this._topClusterLevel._recursivelyBecomeVisible(a,e),s.eachLayer(function(t){t instanceof L.MarkerCluster||!t._icon||t.clusterShow()}),this._topClusterLevel._recursively(a,t,e,function(t){t._recursivelyRestoreChildPositions(e)}),this._ignoreMove=!1,this._enqueue(function(){this._topClusterLevel._recursively(a,t,r,function(t){s.removeLayer(t),t.clusterShow()}),this._animationEnd()})},_animationZoomOut:function(t,e){this._animationZoomOutSingle(this._topClusterLevel,t-1,e),this._topClusterLevel._recursivelyAddChildrenToMap(null,e,this._getExpandedVisibleBounds()),this._topClusterLevel._recursivelyRemoveChildrenFromMap(this._currentShownBounds,Math.floor(this._map.getMinZoom()),t,this._getExpandedVisibleBounds())},_animationAddLayer:function(t,e){var n=this,a=this._featureGroup;a.addLayer(t),e!==t&&(e._childCount>2?(e._updateIcon(),this._forceLayout(),this._animationStart(),t._setPos(this._map.latLngToLayerPoint(e.getLatLng())),t.clusterHide(),this._enqueue(function(){a.removeLayer(t),t.clusterShow(),n._animationEnd()})):(this._forceLayout(),n._animationStart(),n._animationZoomOutSingle(e,this._map.getMaxZoom(),this._zoom)))}},_animationZoomOutSingle:function(t,e,n){var a=this._getExpandedVisibleBounds(),s=Math.floor(this._map.getMinZoom());t._recursivelyAnimateChildrenInAndAddSelfToMap(a,s,e+1,n);var r=this;this._forceLayout(),t._recursivelyBecomeVisible(a,n),this._enqueue(function(){if(1===t._childCount){var l=t._markers[0];this._ignoreMove=!0,l.setLatLng(l.getLatLng()),this._ignoreMove=!1,l.clusterShow&&l.clusterShow()}else t._recursively(a,n,s,function(t){t._recursivelyRemoveChildrenFromMap(a,s,e+1)});r._animationEnd()})},_animationEnd:function(){this._map&&(this._map._mapPane.className=this._map._mapPane.className.replace(" leaflet-cluster-anim","")),this._inZoomAnimation--,this.fire("animationend")},_forceLayout:function(){L.Util.falseFn(document.body.offsetWidth)}}),L.markerClusterGroup=function(t){return new L.MarkerClusterGroup(t)};var n=L.MarkerCluster=L.Marker.extend({options:L.Icon.prototype.options,initialize:function(t,e,n,a){L.Marker.prototype.initialize.call(this,n?n._cLatLng||n.getLatLng():new L.LatLng(0,0),{icon:this,pane:t.options.clusterPane}),this._group=t,this._zoom=e,this._markers=[],this._childClusters=[],this._childCount=0,this._iconNeedsUpdate=!0,this._boundsNeedUpdate=!0,this._bounds=new L.LatLngBounds,n&&this._addChild(n),a&&this._addChild(a)},getAllChildMarkers:function(t,e){t=t||[];for(var n=this._childClusters.length-1;n>=0;n--)this._childClusters[n].getAllChildMarkers(t);for(var a=this._markers.length-1;a>=0;a--)e&&this._markers[a].__dragStart||t.push(this._markers[a]);return t},getChildCount:function(){return this._childCount},zoomToBounds:function(t){for(var e,n=this._childClusters.slice(),a=this._group._map,s=a.getBoundsZoom(this._bounds),r=this._zoom+1,l=a.getZoom();n.length>0&&s>r;){r++;var h=[];for(e=0;er?this._group._map.setView(this._latlng,r):l>=s?this._group._map.setView(this._latlng,l+1):this._group._map.fitBounds(this._bounds,t)},getBounds:function(){var t=new L.LatLngBounds;return t.extend(this._bounds),t},_updateIcon:function(){this._iconNeedsUpdate=!0,this._icon&&this.setIcon(this)},createIcon:function(){return this._iconNeedsUpdate&&(this._iconObj=this._group.options.iconCreateFunction(this),this._iconNeedsUpdate=!1),this._iconObj.createIcon()},createShadow:function(){return this._iconObj.createShadow()},_addChild:function(t,e){this._iconNeedsUpdate=!0,this._boundsNeedUpdate=!0,this._setClusterCenter(t),t instanceof L.MarkerCluster?(e||(this._childClusters.push(t),t.__parent=this),this._childCount+=t._childCount):(e||this._markers.push(t),this._childCount++),this.__parent&&this.__parent._addChild(t,!0)},_setClusterCenter:function(t){this._cLatLng||(this._cLatLng=t._cLatLng||t._latlng)},_resetBounds:function(){var t=this._bounds;t._southWest&&(t._southWest.lat=1/0,t._southWest.lng=1/0),t._northEast&&(t._northEast.lat=-1/0,t._northEast.lng=-1/0)},_recalculateBounds:function(){var t,e,n,a,s=this._markers,r=this._childClusters,l=0,h=0,c=this._childCount;if(0!==c){for(this._resetBounds(),t=0;t=0;n--)(a=s[n])._icon&&(a._setPos(e),a.clusterHide())},function(t){var n,a,s=t._childClusters;for(n=s.length-1;n>=0;n--)(a=s[n])._icon&&(a._setPos(e),a.clusterHide())})},_recursivelyAnimateChildrenInAndAddSelfToMap:function(t,e,n,a){this._recursively(t,a,e,function(s){s._recursivelyAnimateChildrenIn(t,s._group._map.latLngToLayerPoint(s.getLatLng()).round(),n),s._isSingleParent()&&n-1===a?(s.clusterShow(),s._recursivelyRemoveChildrenFromMap(t,e,n)):s.clusterHide(),s._addToMap()})},_recursivelyBecomeVisible:function(t,e){this._recursively(t,this._group._map.getMinZoom(),e,null,function(t){t.clusterShow()})},_recursivelyAddChildrenToMap:function(t,e,n){this._recursively(n,this._group._map.getMinZoom()-1,e,function(a){if(e!==a._zoom)for(var s=a._markers.length-1;s>=0;s--){var r=a._markers[s];n.contains(r._latlng)&&(t&&(r._backupLatlng=r.getLatLng(),r.setLatLng(t),r.clusterHide&&r.clusterHide()),a._group._featureGroup.addLayer(r))}},function(e){e._addToMap(t)})},_recursivelyRestoreChildPositions:function(t){for(var e=this._markers.length-1;e>=0;e--){var n=this._markers[e];n._backupLatlng&&(n.setLatLng(n._backupLatlng),delete n._backupLatlng)}if(t-1===this._zoom)for(var a=this._childClusters.length-1;a>=0;a--)this._childClusters[a]._restorePosition();else for(var s=this._childClusters.length-1;s>=0;s--)this._childClusters[s]._recursivelyRestoreChildPositions(t)},_restorePosition:function(){this._backupLatlng&&(this.setLatLng(this._backupLatlng),delete this._backupLatlng)},_recursivelyRemoveChildrenFromMap:function(t,e,n,a){var s,r;this._recursively(t,e-1,n-1,function(t){for(r=t._markers.length-1;r>=0;r--)s=t._markers[r],a&&a.contains(s._latlng)||(t._group._featureGroup.removeLayer(s),s.clusterShow&&s.clusterShow())},function(t){for(r=t._childClusters.length-1;r>=0;r--)s=t._childClusters[r],a&&a.contains(s._latlng)||(t._group._featureGroup.removeLayer(s),s.clusterShow&&s.clusterShow())})},_recursively:function(t,e,n,a,s){var r,l,h=this._childClusters,c=this._zoom;if(c>=e&&(a&&a(this),s&&c===n&&s(this)),e>c||n>c)for(r=h.length-1;r>=0;r--)(l=h[r])._boundsNeedUpdate&&l._recalculateBounds(),t.intersects(l._bounds)&&l._recursively(t,e,n,a,s)},_isSingleParent:function(){return this._childClusters.length>0&&this._childClusters[0]._childCount===this._childCount}});L.Marker.include({clusterHide:function(){var t=this.options.opacity;return this.setOpacity(0),this.options.opacity=t,this},clusterShow:function(){return this.setOpacity(this.options.opacity)}}),L.DistanceGrid=function(t){this._cellSize=t,this._sqCellSize=t*t,this._grid={},this._objectPoint={}},L.DistanceGrid.prototype={addObject:function(t,e){var n=this._getCoord(e.x),a=this._getCoord(e.y),s=this._grid,r=s[a]=s[a]||{},l=r[n]=r[n]||[],h=L.Util.stamp(t);this._objectPoint[h]=e,l.push(t)},updateObject:function(t,e){this.removeObject(t),this.addObject(t,e)},removeObject:function(t,e){var n,a,s=this._getCoord(e.x),r=this._getCoord(e.y),l=this._grid,h=l[r]=l[r]||{},c=h[s]=h[s]||[];for(delete this._objectPoint[L.Util.stamp(t)],n=0,a=c.length;a>n;n++)if(c[n]===t)return c.splice(n,1),1===a&&delete h[s],!0},eachObject:function(t,e){var n,a,s,r,l,h,c,d=this._grid;for(n in d)for(a in l=d[n])for(h=l[a],s=0,r=h.length;r>s;s++)(c=t.call(e,h[s]))&&(s--,r--)},getNearObject:function(t){var e,n,a,s,r,l,h,c,d=this._getCoord(t.x),u=this._getCoord(t.y),p=this._objectPoint,m=this._sqCellSize,f=null;for(e=u-1;u+1>=e;e++)if(s=this._grid[e]){for(n=d-1;d+1>=n;n++)if(r=s[n])for(a=0,l=r.length;l>a;a++)h=r[a],(m>(c=this._sqDist(p[L.Util.stamp(h)],t))||m>=c&&null===f)&&(m=c,f=h)}return f},_getCoord:function(t){var e=Math.floor(t/this._cellSize);return isFinite(e)?e:t},_sqDist:function(t,e){var n=e.x-t.x,a=e.y-t.y;return n*n+a*a}},L.QuickHull={getDistant:function(t,e){var n=e[1].lat-e[0].lat;return(e[0].lng-e[1].lng)*(t.lat-e[0].lat)+n*(t.lng-e[0].lng)},findMostDistantPointFromBaseLine:function(t,e){var n,a,s,r=0,l=null,h=[];for(n=e.length-1;n>=0;n--)a=e[n],(s=this.getDistant(a,t))>0&&(h.push(a),s>r&&(r=s,l=a));return{maxPoint:l,newPoints:h}},buildConvexHull:function(t,e){var n=[],a=this.findMostDistantPointFromBaseLine(t,e);return a.maxPoint?n=(n=n.concat(this.buildConvexHull([t[0],a.maxPoint],a.newPoints))).concat(this.buildConvexHull([a.maxPoint,t[1]],a.newPoints)):[t[0]]},getConvexHull:function(t){var e,n=!1,a=!1,s=!1,r=!1,l=null,h=null,c=null,d=null,u=null,p=null;for(e=t.length-1;e>=0;e--){var m=t[e];(!1===n||m.lat>n)&&(l=m,n=m.lat),(!1===a||m.lats)&&(c=m,s=m.lng),(!1===r||m.lng=0;e--)t=n[e].getLatLng(),a.push(t);return L.QuickHull.getConvexHull(a)}}),L.MarkerCluster.include({_2PI:2*Math.PI,_circleFootSeparation:25,_circleStartAngle:0,_spiralFootSeparation:28,_spiralLengthStart:11,_spiralLengthFactor:5,_circleSpiralSwitchover:9,spiderfy:function(){if(this._group._spiderfied!==this&&!this._group._inZoomAnimation){var t,e=this.getAllChildMarkers(null,!0),n=this._group._map.latLngToLayerPoint(this._latlng);this._group._unspiderfy(),this._group._spiderfied=this,e.length>=this._circleSpiralSwitchover?t=this._generatePointsSpiral(e.length,n):(n.y+=10,t=this._generatePointsCircle(e.length,n)),this._animationSpiderfy(e,t)}},unspiderfy:function(t){this._group._inZoomAnimation||(this._animationUnspiderfy(t),this._group._spiderfied=null)},_generatePointsCircle:function(t,e){var n,a,s=this._group.options.spiderfyDistanceMultiplier*this._circleFootSeparation*(2+t)/this._2PI,r=this._2PI/t,l=[];for(s=Math.max(s,35),l.length=t,n=0;t>n;n++)a=this._circleStartAngle+n*r,l[n]=new L.Point(e.x+s*Math.cos(a),e.y+s*Math.sin(a))._round();return l},_generatePointsSpiral:function(t,e){var n,a=this._group.options.spiderfyDistanceMultiplier,s=a*this._spiralLengthStart,r=a*this._spiralFootSeparation,l=a*this._spiralLengthFactor*this._2PI,h=0,c=[];for(c.length=t,n=t;n>=0;n--)t>n&&(c[n]=new L.Point(e.x+s*Math.cos(h),e.y+s*Math.sin(h))._round()),h+=r/s+5e-4*n,s+=l/h;return c},_noanimationUnspiderfy:function(){var t,e,n=this._group,a=n._map,s=n._featureGroup,r=this.getAllChildMarkers(null,!0);for(n._ignoreMove=!0,this.setOpacity(1),e=r.length-1;e>=0;e--)t=r[e],s.removeLayer(t),t._preSpiderfyLatlng&&(t.setLatLng(t._preSpiderfyLatlng),delete t._preSpiderfyLatlng),t.setZIndexOffset&&t.setZIndexOffset(0),t._spiderLeg&&(a.removeLayer(t._spiderLeg),delete t._spiderLeg);n.fire("unspiderfied",{cluster:this,markers:r}),n._ignoreMove=!1,n._spiderfied=null}}),L.MarkerClusterNonAnimated=L.MarkerCluster.extend({_animationSpiderfy:function(t,e){var n,a,s,r,l=this._group,h=l._map,c=l._featureGroup,d=this._group.options.spiderLegPolylineOptions;for(l._ignoreMove=!0,n=0;n=0;n--)h=u.layerPointToLatLng(e[n]),(a=t[n])._preSpiderfyLatlng=a._latlng,a.setLatLng(h),a.clusterShow&&a.clusterShow(),g&&((r=(s=a._spiderLeg)._path).style.strokeDashoffset=0,s.setStyle({opacity:v}));this.setOpacity(.3),d._ignoreMove=!1,setTimeout(function(){d._animationEnd(),d.fire("spiderfied",{cluster:c,markers:t})},200)},_animationUnspiderfy:function(t){var e,n,a,s,r,l,h=this,c=this._group,d=c._map,u=c._featureGroup,p=t?d._latLngToNewLayerPoint(this._latlng,t.zoom,t.center):d.latLngToLayerPoint(this._latlng),m=this.getAllChildMarkers(null,!0),f=L.Path.SVG;for(c._ignoreMove=!0,c._animationStart(),this.setOpacity(1),n=m.length-1;n>=0;n--)(e=m[n])._preSpiderfyLatlng&&(e.closePopup(),e.setLatLng(e._preSpiderfyLatlng),delete e._preSpiderfyLatlng,l=!0,e._setPos&&(e._setPos(p),l=!1),e.clusterHide&&(e.clusterHide(),l=!1),l&&u.removeLayer(e),f&&(r=(s=(a=e._spiderLeg)._path).getTotalLength()+.1,s.style.strokeDashoffset=r,a.setStyle({opacity:0})));c._ignoreMove=!1,setTimeout(function(){var t=0;for(n=m.length-1;n>=0;n--)(e=m[n])._spiderLeg&&t++;for(n=m.length-1;n>=0;n--)(e=m[n])._spiderLeg&&(e.clusterShow&&e.clusterShow(),e.setZIndexOffset&&e.setZIndexOffset(0),t>1&&u.removeLayer(e),d.removeLayer(e._spiderLeg),delete e._spiderLeg);c._animationEnd(),c.fire("unspiderfied",{cluster:h,markers:m})},200)}}),L.MarkerClusterGroup.include({_spiderfied:null,unspiderfy:function(){this._unspiderfy.apply(this,arguments)},_spiderfierOnAdd:function(){this._map.on("click",this._unspiderfyWrapper,this),this._map.options.zoomAnimation&&this._map.on("zoomstart",this._unspiderfyZoomStart,this),this._map.on("zoomend",this._noanimationUnspiderfy,this),L.Browser.touch||this._map.getRenderer(this)},_spiderfierOnRemove:function(){this._map.off("click",this._unspiderfyWrapper,this),this._map.off("zoomstart",this._unspiderfyZoomStart,this),this._map.off("zoomanim",this._unspiderfyZoomAnim,this),this._map.off("zoomend",this._noanimationUnspiderfy,this),this._noanimationUnspiderfy()},_unspiderfyZoomStart:function(){this._map&&this._map.on("zoomanim",this._unspiderfyZoomAnim,this)},_unspiderfyZoomAnim:function(t){L.DomUtil.hasClass(this._map._mapPane,"leaflet-touching")||(this._map.off("zoomanim",this._unspiderfyZoomAnim,this),this._unspiderfy(t))},_unspiderfyWrapper:function(){this._unspiderfy()},_unspiderfy:function(t){this._spiderfied&&this._spiderfied.unspiderfy(t)},_noanimationUnspiderfy:function(){this._spiderfied&&this._spiderfied._noanimationUnspiderfy()},_unspiderfyLayer:function(t){t._spiderLeg&&(this._featureGroup.removeLayer(t),t.clusterShow&&t.clusterShow(),t.setZIndexOffset&&t.setZIndexOffset(0),this._map.removeLayer(t._spiderLeg),delete t._spiderLeg)}}),L.MarkerClusterGroup.include({refreshClusters:function(t){return t?t instanceof L.MarkerClusterGroup?t=t._topClusterLevel.getAllChildMarkers():t instanceof L.LayerGroup?t=t._layers:t instanceof L.MarkerCluster?t=t.getAllChildMarkers():t instanceof L.Marker&&(t=[t]):t=this._topClusterLevel.getAllChildMarkers(),this._flagParentsIconsNeedUpdate(t),this._refreshClustersIcons(),this.options.singleMarkerMode&&this._refreshSingleMarkerModeMarkers(t),this},_flagParentsIconsNeedUpdate:function(t){var e,n;for(e in t)for(n=t[e].__parent;n;)n._iconNeedsUpdate=!0,n=n.__parent},_refreshSingleMarkerModeMarkers:function(t){var e,n;for(e in t)n=t[e],this.hasLayer(n)&&n.setIcon(this._overrideMarkerIcon(n))}}),L.Marker.include({refreshIconOptions:function(t,e){var n=this.options.icon;return L.setOptions(n,t),this.setIcon(n),e&&this.__parent&&this.__parent._group.refreshClusters(this),this}}),t.MarkerClusterGroup=e,t.MarkerCluster=n}),function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(require("leaflet")):"function"==typeof define&&define.amd?define(["leaflet"],e):e(t.L)}(this,function(t){"use strict";t=t&&t.hasOwnProperty("default")?t.default:t;var e,n,a,s=function t(e,n){var a=e.value;return e.isInPixels?a/n:a};function r(t){if("string"==typeof t&&-1!==t.indexOf("%"))return{value:parseFloat(t)/100,isInPixels:!1};var e=t?parseFloat(t):0;return{value:e,isInPixels:e>0}}e=Waymark_L.Marker.prototype._initIcon,n=Waymark_L.Marker.prototype._setPos,a="msTransform"===Waymark_L.DomUtil.TRANSFORM,Waymark_L.Marker.addInitHook(function(){var t=this.options.icon&&this.options.icon.options&&this.options.icon.options.iconAnchor;t&&(t=t[0]+"px "+t[1]+"px"),this.options.rotationOrigin=this.options.rotationOrigin||t||"center bottom",this.options.rotationAngle=this.options.rotationAngle||0,this.on("drag",function(t){t.target._applyRotation()})}),Waymark_L.Marker.include({_initIcon:function(){e.call(this)},_setPos:function(t){n.call(this,t),this._applyRotation()},_applyRotation:function(){this.options.rotationAngle&&(this._icon.style[Waymark_L.DomUtil.TRANSFORM+"Origin"]=this.options.rotationOrigin,a?this._icon.style[Waymark_L.DomUtil.TRANSFORM]="rotate("+this.options.rotationAngle+"deg)":this._icon.style[Waymark_L.DomUtil.TRANSFORM]+=" rotateZ("+this.options.rotationAngle+"deg)")},setRotationAngle:function(t){return this.options.rotationAngle=t,this.update(),this},setRotationOrigin:function(t){return this.options.rotationOrigin=t,this.update(),this}}),t.Symbol=t.Symbol||{},t.Symbol.Dash=t.Class.extend({options:{pixelSize:10,pathOptions:{}},initialize:function e(n){t.Util.setOptions(this,n),this.options.pathOptions.clickable=!1},buildSymbol:function e(n,a,s,r,l){var h=this.options;if(h.pixelSize<=1)return t.polyline([n.latLng,n.latLng],h.pathOptions);var c=s.project(n.latLng),d=-(n.heading-90)*(Math.PI/180),u=t.point(c.x+h.pixelSize*Math.cos(d+Math.PI)/2,c.y+h.pixelSize*Math.sin(d)/2),p=c.add(c.subtract(u));return t.polyline([s.unproject(u),s.unproject(p)],h.pathOptions)}}),t.Symbol.dash=function(e){return new t.Symbol.Dash(e)},t.Symbol.ArrowHead=t.Class.extend({options:{polygon:!0,pixelSize:10,headAngle:60,pathOptions:{stroke:!1,weight:2}},initialize:function e(n){t.Util.setOptions(this,n),this.options.pathOptions.clickable=!1},buildSymbol:function e(n,a,s,r,l){return this.options.polygon?t.polygon(this._buildArrowPath(n,s),this.options.pathOptions):t.polyline(this._buildArrowPath(n,s),this.options.pathOptions)},_buildArrowPath:function e(n,a){var s=Math.PI/180,r=a.project(n.latLng),l=-(n.heading-90)*s,h=this.options.headAngle/2*s,c=l+h,d=l-h,u=t.point(r.x-this.options.pixelSize*Math.cos(c),r.y+this.options.pixelSize*Math.sin(c)),p=t.point(r.x-this.options.pixelSize*Math.cos(d),r.y+this.options.pixelSize*Math.sin(d));return[a.unproject(u),n.latLng,a.unproject(p)]}}),t.Symbol.arrowHead=function(e){return new t.Symbol.ArrowHead(e)},t.Symbol.Marker=t.Class.extend({options:{markerOptions:{},rotate:!1},initialize:function e(n){t.Util.setOptions(this,n),this.options.markerOptions.clickable=!1,this.options.markerOptions.draggable=!1},buildSymbol:function e(n,a,s,r,l){return this.options.rotate&&(this.options.markerOptions.rotationAngle=n.heading+(this.options.angleCorrection||0)),t.marker(n.latLng,this.options.markerOptions)}}),t.Symbol.marker=function(e){return new t.Symbol.Marker(e)};var l=function e(n){var a;return Array.isArray(n)&&((a=n[0])instanceof t.LatLng||Array.isArray(a)&&2===a.length&&"number"==typeof a[0])};t.PolylineDecorator=t.FeatureGroup.extend({options:{patterns:[]},initialize:function e(n,a){t.FeatureGroup.prototype.initialize.call(this),t.Util.setOptions(this,a),this._map=null,this._paths=this._initPaths(n),this._bounds=this._initBounds(),this._patterns=this._initPatterns(this.options.patterns)},_initPaths:function e(n,a){var s=this;return l(n)?[a?n.concat([n[0]]):n]:n instanceof t.Polyline?this._initPaths(n.getLatLngs(),n instanceof t.Polygon):Array.isArray(n)?n.reduce(function(t,e){return t.concat(s._initPaths(e,a))},[]):[]},_initPatterns:function t(e){return e.map(this._parsePatternDef)},setPatterns:function t(e){this.options.patterns=e,this._patterns=this._initPatterns(this.options.patterns),this.redraw()},setPaths:function t(e){this._paths=this._initPaths(e),this._bounds=this._initBounds(),this.redraw()},_parsePatternDef:function t(e,n){return{symbolFactory:e.symbol,offset:r(e.offset),endOffset:r(e.endOffset),repeat:r(e.repeat)}},onAdd:function t(e){this._map=e,this._draw(),this._map.on("moveend",this.redraw,this)},onRemove:function e(n){this._map.off("moveend",this.redraw,this),this._map=null,t.FeatureGroup.prototype.onRemove.call(this,n)},_initBounds:function e(){var n=this._paths.reduce(function(t,e){return t.concat(e)},[]);return t.latLngBounds(n)},getBounds:function t(){return this._bounds},_buildSymbols:function t(e,n,a){var s=this;return a.map(function(t,r){return n.buildSymbol(t,e,s._map,r,a.length)})},_getDirectionPoints:function e(n,a){var r=this;return n.length<2?[]:(function t(e,n){var a,r=(a=e).reduce(function(t,e,n,a){var s,r;if(n>0&&(s=e,r=a[n-1],s.x!==r.x||s.y!==r.y)){var l,h,c,d,u,p,m=a[n-1],f=t.length>0?t[t.length-1].distB:0,g=(l=m,c=(h=e).x-l.x,Math.sqrt(c*c+(d=h.y-l.y)*d));t.push({a:m,b:e,distA:f,distB:f+g,heading:(u=m,(180*Math.atan2((p=e).y-u.y,p.x-u.x)/Math.PI+90+360)%360)})}return t},[]),l=r.length;if(0===l)return[];var h=r[l-1].distB,c=s(n.offset,h),d=s(n.endOffset,h),u=s(n.repeat,h),p=h*u,m=d>0?h*d:0,f=[],g=c>0?h*c:0;do f.push(g),g+=p;while(p>0&&gv.distB&&y1&&"number"==typeof e?3&e:1;return function t(e,n,r,l){var d,u,p=s.length,m=e.hasChildNodes(),f=e.nodeType===e.ELEMENT_NODE&&e.hasAttributes(),g=Boolean(2&n),y=0,v="",k=g?{}:!!a.trueIsEmpty||"";if(m)for(var w,x=0;x0)&&v?k[a.valueKey]=b:!g&&0===y&&v&&(k=b),r&&(g||y>0)&&Object.freeze(k),s.length=p,k}(t,l,n||!1,arguments.length>3?r:3===l)},this.jsToXml=this.unbuild=function(n,s,r,l){var h=(t.document&&t.document.implementation||new t.DOMImplementation).createDocument(s||null,r||"",l||null);return function t(n,s,r){var l,h,c;if(r.constructor===String||r.constructor===Number||r.constructor===Boolean){if(s.appendChild(n.createTextNode(r.toString())),r===r.valueOf())return}else r.constructor===Date&&s.appendChild(n.createTextNode(r.toISOString()));for(var d in r){if(void 0!==(l=r[d])){if(null===l&&(l={}),!isFinite(d)&&!(l instanceof Function)){if(d===a.valueKey)null!==l&&!0!==l&&s.appendChild(n.createTextNode(l.constructor===Date?l.toISOString():String(l)));else if(d===a.attrKey)for(var u in l)s.setAttribute(u,l[u]);else if(d===a.attrPrefix+"xmlns")e&&s.setAttribute(d.slice(1),l);else if(d.charAt(0)===a.attrPrefix)s.setAttribute(d.slice(1),l);else if(l.constructor===Array)for(var p in l)l.hasOwnProperty(p)&&(h=(c=l[p]&&l[p][a.attrPrefix+"xmlns"]||s.namespaceURI)?n.createElementNS(c,d):n.createElement(d),t(n,h,l[p]||{}),s.appendChild(h));else h=(c=(l||{})[a.attrPrefix+"xmlns"]||s.namespaceURI)?n.createElementNS(c,d):n.createElement(d),l instanceof Object?t(n,h,l):null===l||!0===l&&a.trueIsEmpty||h.appendChild(n.createTextNode(l.toString())),s.appendChild(h)}}}}(h,h.documentElement||h,n),h},this.stringToXml=function(e){return n||(n=new t.DOMParser),n.parseFromString(e,"application/xml")},this.xmlToString=function(e){return void 0!==e.xml?e.xml:new t.XMLSerializer().serializeToString(e)},this.stringToJs=function(t){var e=this.stringToXml(t);return this.xmlToJs(e)},this.jsToString=this.stringify=function(t,e,n,a){return this.xmlToString(this.jsToXml(t,e,n,a))},this.each=function(t,e,n){t instanceof Array?t.forEach(e,n):[t].forEach(e,n)}}},"function"==typeof t&&t.amd?t([],r(window)):"object"==typeof a?"object"==typeof window&&window.DOMImplementation&&window.XMLSerializer&&window.DOMParser?n.exports=r(window):n.exports=r(e("xmldom"),!0):s.JXON=r(window)},{xmldom:3}],3:[function(t,e,n){},{}]},{},[1])(1)}),function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;(e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).tokml=t()}}(function(){return(function(){function t(e,n,a){function s(l,h){if(!n[l]){if(!e[l]){var c="function"==typeof require&&require;if(!h&&c)return c(l,!0);if(r)return r(l,!0);var d=Error("Cannot find module '"+l+"'");throw d.code="MODULE_NOT_FOUND",d}var u=n[l]={exports:{}};e[l][0].call(u.exports,function(t){return s(e[l][1][t]||t)},u,u.exports,t,e,n,a)}return n[l].exports}for(var r="function"==typeof require&&require,l=0;l'+s("kml",{xmlns:"http://www.opengis.net/kml/2.2"},s("Document",(a=n=n||{documentName:void 0,documentDescription:void 0,name:"name",description:"description",simplestyle:!1,timestamp:"timestamp"},(void 0!==a.documentName?s("name",a.documentName):"")+(l=n,void 0!==l.documentDescription?s("description",l.documentDescription):"")+function t(e,n){if(!e.type)return"";var a=[];switch(e.type){case"FeatureCollection":if(!e.features)return"";return e.features.map(r(n,a)).join("");case"Feature":return r(n,a)(e);default:return r(n,a)({type:"Feature",geometry:e,properties:{}})}}(e,n))))};var l={Point:function(t){return s("Point",s("coordinates",t.coordinates.join(",")))},LineString:function(t){return s("LineString",s("coordinates",h(t.coordinates)))},Polygon:function(t){if(!t.coordinates.length)return"";var e=t.coordinates[0],n=t.coordinates.slice(1),a=s("outerBoundaryIs",s("LinearRing",s("coordinates",h(e)))),r=n.map(function(t){return s("innerBoundaryIs",s("LinearRing",s("coordinates",h(t))))}).join("");return s("Polygon",a+r)},MultiPoint:function(t){return t.coordinates.length?s("MultiGeometry",t.coordinates.map(function(t){return l.Point({coordinates:t})}).join("")):""},MultiPolygon:function(t){return t.coordinates.length?s("MultiGeometry",t.coordinates.map(function(t){return l.Polygon({coordinates:t})}).join("")):""},MultiLineString:function(t){return t.coordinates.length?s("MultiGeometry",t.coordinates.map(function(t){return l.LineString({coordinates:t})}).join("")):""},GeometryCollection:function(t){return s("MultiGeometry",t.geometries.map(l.any).join(""))},valid:function(t){return t&&t.type&&(t.coordinates||"GeometryCollection"===t.type&&t.geometries&&t.geometries.every(l.valid))},any:function(t){return l[t.type]?l[t.type](t):""},isPoint:function(t){return"Point"===t.type||"MultiPoint"===t.type},isPolygon:function(t){return"Polygon"===t.type||"MultiPolygon"===t.type},isLine:function(t){return"LineString"===t.type||"MultiLineString"===t.type}};function h(t){return t.map(function(t){return t.join(",")}).join(" ")}function c(t){return s("Data",{name:t[0]},s("value",{},a(t[1]?t[1].toString():"")))}function d(t,e){if("string"!=typeof t)return"";if(3===(t=t.replace("#","").toLowerCase()).length)t=t[0]+t[0]+t[1]+t[1]+t[2]+t[2];else if(6!==t.length)return"";var n=t[0]+t[1],a=t[2]+t[3],s=t[4]+t[5],r="ff";return"number"==typeof e&&e>=0&&e<=1&&((r=(255*e).toString(16)).indexOf(".")>-1&&(r=r.substr(0,r.indexOf("."))),r.length<2&&(r="0"+r)),r+s+a+n}},{strxml:2,"xml-escape":3}],2:[function(t,e,n){var a=t("xml-escape");function s(t){return Object.keys(t).length?" "+Object.keys(t).map(function(e){return e+'="'+a(t[e])+'"'}).join(" "):""}e.exports.attr=s,e.exports.tagClose=function t(e,n){return"<"+e+s(n)+"/>"},e.exports.tag=function t(e,n,a){return(Array.isArray(n)||"string"==typeof n)&&(a=n,n={}),Array.isArray(a)&&(a="\n"+a.map(function(t){return" "+t}).join("\n")+"\n"),"<"+e+s(n)+">"+a+""+e+">"}},{"xml-escape":3}],3:[function(t,e,n){(e.exports=function t(e,n){var a;if(null!=e)return e=e.toString(),n=(n||"").replace(/[^&"<>\']/g,""),a="([&\"<>'])".replace(RegExp("["+n+"]","g"),""),e.replace(RegExp(a,"g"),function(e,n){return t.map[n]})}).map={">":">","<":"<","'":"'",'"':""","&":"&"}},{}]},{},[1])(1)});var waymark_js_localize={action_fullscreen_activate:"View Fullscreen",action_fullscreen_deactivate:"Exit Fullscreen",action_locate_activate:"Show me where I am",action_zoom_in:"Zoom in",action_zoom_out:"Zoom out",label_total_length:"Total Length: ",label_max_elevation:"Max. Elevation: ",label_min_elevation:"Min. Elevation: ",label_ascent:"Total Ascent: ",label_descent:"Total Descent: ",add_line_title:"Draw a Line",add_photo_title:"Upload an Image",add_marker_title:"Place a Marker",add_rectangle_title:"Draw a Rectangle",add_polygon_title:"Draw a Polygon",add_circle_title:"Draw a Circle",upload_file_title:"Read Lines and Markers from file (GPX/KML/GeoJSON supported, which most apps should Export to)",action_duplicate:"Duplicate",action_delete:"Delete",action_edit:"Edit",action_edit_done:"Finish editing",action_upload_image:"Upload Image",object_title_placeholder:"Title",object_image_placeholder:"Image URL",object_description_placeholder:"Description",object_type_label:"Type",marker_latlng_label:"Lat,Lng",action_delete_confirm:"Are you sure you want to delete this",action_search_placeholder:"Search...",object_label_marker:"Marker",object_label_line:"Line",object_label_shape:"Shape",object_label_marker_plural:"Markers",object_label_line_plural:"Lines",object_label_shape_plural:"Shapes",error_message_prefix:"Waymark Error",info_message_prefix:"Waymark Info",error_file_type:"This file type is not supported.",error_file_conversion:"Could not convert this file to GeoJSON.",error_file_upload:"File upload error.",error_photo_meta:"Could not retrieve Image metadata.",info_exif_yes:"Image location metadata (EXIF) detected!",info_exif_no:"Image location metadata (EXIF) NOT detected.",error_no_wpmedia:"WordPress Media Library not found",no_direction:"No Direction",show_direction:"Show Direction",reverse_direction:"Reverse Direction"};if(void 0===waymark_js)var waymark_js={lang:{}};for(key in waymark_js_localize)void 0===waymark_js.lang[key]&&(waymark_js.lang[key]=waymark_js_localize[key]);function Waymark_Map(){this.fallback_latlng=[51.38436,-68.74923],this.fallback_zoom=9,this.init=function(t){for(config_key in Waymark=this,Waymark.jq_map_container=null,Waymark.config={map_div_id:"waymark-map",map_options:{show_type_labels:1,button_position:"bottomright",max_zoom:0},map_height:400,map_width:null,map_init_zoom:void 0,map_init_latlng:void 0,map_init_basemap:void 0,show_gallery:0,show_filter:0,show_elevation:0,show_cluster:1,elevation_div_id:"waymark-elevation",elevation_units:"metric",elevation_initial:1,tile_layers:{},line_types:{},shape_types:{},marker_types:{},marker_data_defaults:{title:void 0,type:void 0,image_thumbnail_url:void 0,image_medium_url:void 0,image_large_url:void 0,description:void 0},line_data_defaults:{type:void 0,title:void 0,image_thumbnail_url:void 0,image_medium_url:void 0,image_large_url:void 0,description:void 0,direction:void 0},shape_data_defaults:{type:void 0,title:void 0,image_thumbnail_url:void 0,image_medium_url:void 0,image_large_url:void 0,description:void 0},editor_options:{confirm_delete:1},handle_content_callback:void 0,handle_delete_callback:void 0,handle_edit_callback:void 0,handle_custom_type_callback:void 0,media_library_sizes:["thumbnail","medium","large","full"]},Waymark.config)void 0!==t[config_key]&&(Waymark.config[config_key]=t[config_key]);var e=Waymark.get_type("line"),n=Waymark.make_key(e.line_title);Waymark.config.line_data_defaults.type=n;var a=Waymark.get_type("shape"),s=Waymark.make_key(a.shape_title);Waymark.config.shape_data_defaults.type=s;var r=Waymark.get_type("marker"),l=Waymark.make_key(r.marker_title);Waymark.config.marker_data_defaults.type=l,Waymark.marker_parent_group=Waymark_L.layerGroup(),Waymark.marker_sub_groups={},Waymark.line_parent_group=Waymark_L.layerGroup(),Waymark.line_sub_groups={},Waymark.shape_parent_group=Waymark_L.layerGroup(),Waymark.shape_sub_groups={},Waymark.pre_map_setup(),Waymark.setup_map(),Waymark.handle_resize(),Waymark.init_done()},this.get_property=function(t,...e){return e.reduce((t,e)=>t&&t[e],t)},this.debug=function(t){!0==this.get_property(waymark_settings,"misc","advanced","debug_mode")&&("string"==typeof t?console.log("["+waymark_js.lang.info_message_prefix+"] "+t):(console.log("["+waymark_js.lang.info_message_prefix+"] ..."),console.log(t)))},this.message=function(t=null,e="info",n="console"){if(t){var a="";(a="error"===e?waymark_js.lang.error_message_prefix:waymark_js.lang.info_message_prefix)&&(a="["+a+"] "),"console"==n?console.log(a+t):alert(a+t)}},this.title_case=function(t){return t.replace(/(?:^|\s)\w/g,function(t){return t.toUpperCase()})},this.transliterate=function(t){var e={Ё:"YO",Й:"I",Ц:"TS",У:"U",К:"K",Е:"E",Н:"N",Г:"G",Ш:"SH",Щ:"SCH",З:"Z",Х:"H",Ъ:"'",ё:"yo",й:"i",ц:"ts",у:"u",к:"k",е:"e",н:"n",г:"g",ш:"sh",щ:"sch",з:"z",х:"h",ъ:"'",Ф:"F",Ы:"I",В:"V",А:"a",П:"P",Р:"R",О:"O",Л:"L",Д:"D",Ж:"ZH",Э:"E",ф:"f",ы:"i",в:"v",а:"a",п:"p",р:"r",о:"o",л:"l",д:"d",ж:"zh",э:"e",Я:"Ya",Ч:"CH",С:"S",М:"M",И:"I",Т:"T",Ь:"'",Б:"B",Ю:"YU",я:"ya",ч:"ch",с:"s",м:"m",и:"i",т:"t",ь:"'",б:"b",ю:"yu"};return t.split("").map(function(t){return e[t]||t}).join("")},this.make_key=function(t){return t?t=(t=(t=this.transliterate(t)).replace(/[^a-z0-9+]+/gi,"")).toLowerCase():t},this.get_feature_overlay_type=function(t){if(void 0===t.geometry.type)return!1;switch(t.geometry.type){case"Point":if(t.properties.radius)return"shape";return"marker";case"LineString":case"MultiLineString":return"line";case"Polygon":return"shape"}return!1},this.setup_map=function(){Waymark=this,Waymark.jq_map_container=jQuery("#"+Waymark.config.map_div_id),Waymark.jq_map_container.addClass("waymark-map-container"),Waymark.jq_map_container.css("height",Waymark.config.map_height+"px");var t={fullscreenControl:!1,attributionControl:!1,editable:!0,zoomControl:!1,sleep:!1};"view"==Waymark.mode?(t.dragging=!1,t.sleep=!0,t.wakeTime=1e3*this.get_property(waymark_settings,"misc","interaction_options","delay_seconds"),"1"===this.get_property(waymark_settings,"misc","interaction_options","do_message")?(t.sleepNote=!0,t.wakeMessage=this.get_property(waymark_settings,"misc","interaction_options","wake_message")):(t.sleepNote=!1,t.wakeMessage=!1),t.sleepOpacity=1,(max_zoom=Waymark.config.map_options.max_zoom)&&(t.maxZoom=max_zoom)):t.dragging=!0,Waymark.map=Waymark_L.map(Waymark.config.map_div_id,t),Waymark_L.control.attribution({prefix:'Waymark | Leaflet'}).addTo(Waymark.map),!0==this.get_property(waymark_settings,"misc","map_options","show_scale")&&Waymark_L.control.scale().addTo(Waymark.map),Waymark.jq_map_container.data("Waymark",Waymark),void 0!==Waymark.config.map_init_latlng?Waymark.map.setView(Waymark.config.map_init_latlng):Waymark.map.setView(Waymark.fallback_latlng),void 0!==Waymark.config.map_init_zoom?Waymark.map.setZoom(Waymark.config.map_init_zoom):Waymark.map.setZoom(Waymark.fallback_zoom),Waymark_L.Path.mergeOptions({color:"#b42714"}),Waymark_L.control.zoom({position:Waymark.config.map_options.button_position,zoomInTitle:waymark_js.lang.action_zoom_in,zoomOutTitle:waymark_js.lang.action_zoom_out}).addTo(Waymark.map),Waymark_L.control.locate({position:"bottomright",icon:"ion ion-android-locate",drawCircle:!1,strings:{title:waymark_js.lang.action_locate_activate},locateOptions:{enableHighAccuracy:!0}}).addTo(Waymark.map),Waymark_L.control.fullscreen({position:Waymark.config.map_options.button_position,title:{false:waymark_js.lang.action_fullscreen_activate,true:waymark_js.lang.action_fullscreen_deactivate}}).addTo(Waymark.map),Waymark.marker_parent_group.addTo(Waymark.map),Waymark.line_parent_group.addTo(Waymark.map),Waymark.shape_parent_group.addTo(Waymark.map),Waymark.setup_layers(),Waymark.create_data_layer(),Waymark.create_buttons()},this.create_data_layer=function(){Waymark=this,Waymark.map_data=Waymark_L.geoJSON(null,{pointToLayer:function(t,e){return void 0!==t.properties&&t.properties.radius?new Waymark_L.Circle(e,parseFloat(t.properties.radius)):Waymark.create_marker(e)},onEachFeature:function(t,e){switch(t.geometry.type){case"Point":if(t.properties.radius){t.properties=Waymark.parse_layer_data("shape",t.properties);var n=Waymark.get_type("shape",t.properties.type);e.setStyle({color:n.shape_colour,fillOpacity:n.fill_opacity}),Waymark.info_window("shape",t,e),Waymark.tooltip("shape",t,e),Waymark.add_to_group("shape",e)}else{t.properties=Waymark.parse_layer_data("marker",t.properties);var n=Waymark.get_type("marker",t.properties.type);e.setIcon(Waymark_L.divIcon(Waymark.build_icon_data(n))),void 0!==Waymark.gallery_images&&Waymark.add_to_gallery(e),Waymark.info_window("marker",t,e),Waymark.tooltip("marker",t,e),Waymark.add_to_group("marker",e)}break;case"LineString":case"MultiLineString":t.properties=Waymark.parse_layer_data("line",t.properties);var n=Waymark.get_type("line",t.properties.type);e.setStyle({color:n.line_colour,weight:n.line_weight,opacity:n.line_opacity}),Waymark.info_window("line",t,e),Waymark.tooltip("line",t,e);var a=parseInt(n.line_display);Waymark.draw_line_direction(e,a),Waymark.add_to_group("line",e);break;case"Polygon":t.properties=Waymark.parse_layer_data("shape",t.properties),t.properties.rectangle;var n=Waymark.get_type("shape",t.properties.type);e.setStyle({color:n.shape_colour,fillOpacity:n.fill_opacity}),Waymark.info_window("shape",t,e),Waymark.tooltip("shape",t,e),Waymark.add_to_group("shape",e)}}})},this.draw_line_direction=function(t,e=!0){var n=t.feature,a=n.properties.direction,s=Waymark.get_type("line",n.properties.type);if("object"==typeof t.direction_layer&&Waymark.map.removeLayer(t.direction_layer),"string"==typeof a&&("default"==a||"reverse"==a)){var r=45;"reverse"==a&&(r=360-r);var l=Waymark_L.polylineDecorator(t,{patterns:[{repeat:100,symbol:L.Symbol.arrowHead({pixelSize:15,headAngle:r,polygon:!0,pathOptions:{color:"#fff",fillColor:s.line_colour,opacity:"0.7",stroke:!0,fillOpacity:.7,weight:2}})},]});e&&l.addTo(Waymark.map),t.direction_layer=l}},this.setup_layers=function(){Waymark=this,Waymark.layer_control=Waymark_L.control.layers();var t,e=[],n=0;if(void 0!==Waymark.config.map_init_basemap)for(var a in Waymark.config.tile_layers){Waymark.config.map_init_basemap.toUpperCase()===Waymark.config.tile_layers[a].layer_name.toUpperCase()&&(n=a)}for(var a in Waymark.config.tile_layers){void 0!==Waymark.config.tile_layers[a].append&&(Waymark.config.tile_layers[a].layer_url+=Waymark.config.tile_layers[a].append);var s={id:Waymark.config.tile_layers[a].layer_name.replace(/ /g,""),attribution:Waymark.config.tile_layers[a].layer_attribution},r=parseInt(Waymark.config.tile_layers[a].layer_max_zoom);r&&(s.maxZoom=r);var l=Waymark_L.tileLayer(Waymark.config.tile_layers[a].layer_url,s);e[Waymark.config.tile_layers[a].layer_name]=l,a==n&&l.addTo(Waymark.map)}if(a>=1)for(basemap_name in Waymark.layer_control.addTo(Waymark.map),e)Waymark.layer_control.addBaseLayer(e[basemap_name],basemap_name)},this.get_type=function(t,e){Waymark=this;var n=null;for(var a in Waymark.config[t+"_types"]){0==a&&(n=Waymark.config[t+"_types"][a]);var s=Waymark.config[t+"_types"][a][t+"_title"];s&&Waymark.make_key(e)==Waymark.make_key(s)&&(n=Waymark.config[t+"_types"][a])}return Waymark.parse_type(n,t)},this.parse_type=function(t,e){if(Waymark=this,"object"!=typeof t)return t;if("line"===e){var n=[{key:"line_colour",default:"#b42714"},{key:"line_weight",default:"3"},{key:"line_opacity",default:"0.7"},];for(var a in n)"string"!=typeof t[n[a].key]&&(t[n[a].key]=n[a].default)}return t.type_key=Waymark.make_key(t[e+"_title"]),t},this.handle_resize=function(){Waymark=this,jQuery(window).on("resize",function(){Waymark.config.map_height=Waymark.jq_map_container.height(),Waymark.config.map_width=Waymark.jq_map_container.width(),"function"==typeof Waymark.size_gallery&&Waymark.size_gallery()})},this.tooltip=function(t,e,n){Waymark=this;var a="";if("1"==Waymark.config.map_options.show_type_labels){var s=Waymark.get_type(t,e.properties.type);if(s){var r=s[t+"_title"];r&&(a="["+r+"] ")}}e.properties.title&&(a+=e.properties.title),a&&(n.bindTooltip(a),n.on("mouseover",function(t){var e=t.target.getTooltip();e.setLatLng(t.latlng),e.openTooltip()}),n.on("mousemove",function(t){t.target.getTooltip().setLatLng(t.latlng)}))},this.get_data_defaults=function(t){return Object.assign({},Waymark.config[t+"_data_defaults"])},this.parse_layer_data=function(t,e){Waymark=this;var n=Waymark.get_data_defaults(t);if("object"==typeof e)for(r in n)void 0!==e[r]&&e[r]&&(n[r]=e[r]);for(r in e)if(e[r])switch(r){case"name":n.title=e[r];break;case"desc":case"notes":n.description=e[r];break;case"radius":n[r]=parseFloat(e[r])}var a=this.get_property(waymark_settings,"overlay","properties");if(Object.keys(a).length){var s="";for(i in a){var r=a[i].property_key,l=a[i].property_title,h=e[r];void 0!==h&&(s+=''+l+"
"+h+"
",Waymark.debug("Importing "+l+" ("+r+") ==> "+h))}s&&(void 0===n.description&&(n.description=""),n.description+=s)}return n},this.add_to_group=function(t,e){var n=e.feature;if(void 0!==n.properties.type){var a=n.properties.type,s=Waymark.get_type(t,a);if(void 0===Waymark[t+"_sub_groups"][s.type_key]){var r=Waymark_L.featureGroup.subGroup(Waymark[t+"_parent_group"]);Waymark[t+"_sub_groups"][s.type_key]=r,"view"==Waymark.mode&&void 0!==s[t+"_display"]?"1"==s[t+"_display"]&&r.addTo(Waymark.map):r.addTo(Waymark.map)}if(e.addTo(Waymark[t+"_sub_groups"][s.type_key]),"line"==t&&"object"==typeof e.direction_layer&&e.direction_layer.addTo(Waymark[t+"_sub_groups"][s.type_key]),Waymark.config.show_filter&&"view"==Waymark.mode)for(key in Waymark.layer_control.addTo(Waymark.map),Waymark.layer_control.removeLayer(Waymark[t+"_parent_group"]),Waymark.layer_control.addOverlay(Waymark[t+"_parent_group"],""+waymark_js_localize["object_label_"+t+"_plural"]+""),Waymark_L.stamp(Waymark[t+"_parent_group"]),Waymark[t+"_sub_groups"]){var l=Waymark.get_type(t,key),r=Waymark[t+"_sub_groups"][key];Waymark.layer_control.removeLayer(r),Waymark.layer_control.addOverlay(r,Waymark.type_to_text(t,l))}}else e.addTo(Waymark[t+"_parent_group"])},this.type_to_text=function(t,e,n="span"){var a="";switch(t){case"marker":a+="color:"+e.icon_colour+";",a+="background:"+Waymark.get_marker_background(e.marker_colour);break;case"line":a+="color:"+e.line_colour+";box-shadow:inset 0 0 0 1px "+e.line_colour;break;case"shape":a+="background:"+e.shape_colour}return"<"+n+' class="waymark-type-text waymark-'+t+'-type" style="'+a+'">'+e[t+"_title"]+""+n+">"},this.create_marker=function(t){return Waymark_L.marker(t)},this.build_icon_data=function(t){var e={className:"waymark-marker waymark-marker-"+t.type_key};if(void 0!==t.marker_shape&&void 0!==t.marker_size){switch(e.className+=" waymark-marker-"+t.marker_shape,e.className+=" waymark-marker-"+t.marker_size,t.marker_shape){case"rectangle":case"circle":case"marker":switch(t.marker_size){case"small":e.iconSize=[16,16];break;case"medium":e.iconSize=[25,25];break;default:e.iconSize=[32,32]}}"marker"==t.marker_shape&&(e.iconAnchor=[e.iconSize[0]/2,1.25*e.iconSize[1],])}var n="background:"+Waymark.get_marker_background(t.marker_colour)+";",a="color:"+t.icon_colour+";";e.html='';var s="waymark-marker-icon";switch(t.icon_type){case"text":s+=" waymark-icon-text",e.html+=''+t.marker_icon+"
";break;case"html":s+=" waymark-icon-html";var r=jQuery("").html(t.marker_icon).text();e.html+=''+r+"
";break;default:s+=" waymark-icon-icon",0===t.marker_icon.indexOf("ion-")?(s+=" ion ",s+=" "+t.marker_icon):0===t.marker_icon.indexOf("fa-")?(s+=" fa",s+=" "+t.marker_icon):(s+=" ion",s+=" ion-"+t.marker_icon),e.html+=''}return e},this.get_marker_background=function(t){if(["red","darkred","orange","green","darkgreen","blue","purple","darkpurple","cadetblue","white","black",].includes(t))switch(t){case"red":return"#da3d20";case"darkred":return"#a43233";case"orange":return"#f9960a";case"green":return"#70af00";case"darkgreen":return"#72820d";case"blue":return"#2aabe1";case"purple":return"#d553bd";case"darkpurple":return"#5c3a6e";case"cadetblue":return"#416979";case"white":return"#fbfbfb";case"black":return"#303030"}return t},this.create_marker_json=function(t,e={}){Waymark.debug(Waymark.config.marker_data_defaults);var n=Object.assign({},Waymark.config.marker_data_defaults,e),a={geometry:{type:"Point",coordinates:[t.lng,t.lat]},type:"Feature",properties:n};return Waymark.debug(a),a},this.get_exif_latlng=function(t){return t.GPSLatitudeNum&&!isNaN(t.GPSLatitudeNum)&&t.GPSLongitudeNum&&!isNaN(t.GPSLongitudeNum)?(Waymark.debug(waymark_js.lang.info_exif_yes),L.latLng(t.GPSLatitudeNum,t.GPSLongitudeNum)):(Waymark.debug(waymark_js.lang.info_exif_no),!1)},this.get_image_sizes=function(t,e){Waymark=this;var n={};for(var a in Waymark.config.media_library_sizes)n["image_"+Waymark.config.media_library_sizes[a]+"_url"]=e,void 0!==t[Waymark.config.media_library_sizes[a]]&&void 0!==t[Waymark.config.media_library_sizes[a]].url&&(n["image_"+Waymark.config.media_library_sizes[a]+"_url"]=t[Waymark.config.media_library_sizes[a]].url);return n},this.pre_map_setup=function(){},this.init_done=function(){},this.info_window=function(t,e,n){},this.build_content=function(t,e){}}function Waymark_Map_Viewer(){this.gallery_images=[],this.pre_map_setup=function(){Waymark=this,Waymark.mode="view"},this.init_done=function(){Waymark=this,Waymark.jq_map_container.show(),Waymark.map.invalidateSize(),Waymark.config.map_width=Waymark.jq_map_container.width(),Waymark.setup_gallery(),Waymark.setup_elevation(),Waymark.setupCluster(),jQuery(Waymark.map.getContainer()).addClass("waymark-is-viewer"),Waymark.setup_hidden_checker()},this.setupCluster=()=>{Waymark.config.show_cluster&&(Waymark.jq_map_container.addClass("waymark-has-cluster"),Waymark.map._layersMaxZoom=18,Waymark.marker_cluster=L.markerClusterGroup({animate:!1,showCoverageOnHover:!1,removeOutsideVisibleBounds:!0,iconCreateFunction:this.clusterIconFunction,spiderfyOnMaxZoom:!1,disableClusteringAtZoom:Waymark.get_property(waymark_settings,"misc","cluster_options","cluster_threshold"),maxClusterRadius:Waymark.get_property(waymark_settings,"misc","cluster_options","cluster_radius")}),Waymark.marker_parent_group=Waymark.marker_cluster,Waymark.map.addLayer(Waymark.marker_cluster))},this.clusterIconFunction=t=>{let e=new Map([]);t.getAllChildMarkers().forEach(t=>{let n=t.feature.properties.type,a=Waymark.get_type("marker",n);a.iconData=Waymark.build_icon_data(a),e.has(n)?a.typeCount++:a.typeCount=1,e.set(n,a)});let n="",a=0,s=0,r=0;return[...e.entries()].sort((t,e)=>e[1].typeCount-t[1].typeCount).forEach(([t,l])=>{let h=l.typeCount,c=l.iconData,d=e.size-a;s=c.iconSize[0]>s?c.iconSize[0]:s,r=c.iconSize[0]>r?c.iconSize[0]:r,h>1&&(c.html+=`${h}
`);let u=8*a;n+=`
+
+ ${c.html}
+
+ `,a++}),L.divIcon({className:"waymark-cluster",html:n,iconSize:[s,r]})},this.setup_hidden_checker=function(){let t=setInterval(function(){(is_hidden=Waymark.jq_map_container.is(":hidden"))||(Waymark.reset_map_view(),clearInterval(t))},100)},this.create_buttons=function(){},this.load_json=function(t){Waymark=this,"object"==typeof t&&void 0!==t.features&&(Waymark.map_data.addData(t),Waymark.reset_map_view())},this.reset_map_view=function(){if(Waymark=this,void 0===Waymark.config.map_init_latlng&&void 0===Waymark.config.map_init_zoom){var t=Waymark.map_data.getBounds();"object"==typeof t&&t.isValid()&&(Waymark.map.invalidateSize(),Waymark.map.fitBounds(t))}else void 0!==Waymark.config.map_init_latlng&&void 0!==Waymark.config.map_init_zoom?Waymark.map.setView(Waymark.config.map_init_latlng,Waymark.config.map_init_zoom):(void 0!==Waymark.config.map_init_latlng&&(Waymark.map.setView(Waymark.config.map_init_latlng),Waymark.map.setZoom(Waymark.map.getBoundsZoom(Waymark.map_data.getBounds()))),void 0!==Waymark.config.map_init_zoom&&(Waymark.map.setZoom(Waymark.config.map_init_zoom),Waymark.map.setView(Waymark.map_data.getBounds().getCenter())))},this.build_content=function(t,e){Waymark=this;var n=jQuery(""),a=jQuery("").addClass("waymark-info waymark-"+t+"-info");for(key in Waymark.config[t+"_data_defaults"]){var s=null;switch(key){case"title":e.properties.title?s=jQuery("").html(e.properties.title):(s=jQuery("").html(" "),a.addClass("waymark-no-title"));break;case"type":if("1"!=Waymark.config.map_options.show_type_labels)break;var r=Waymark.get_type(t,e.properties.type);r&&(s=Waymark.type_to_text(t,r,"small"));break;case"description":var l=e.properties.description;l?s=0===l.indexOf("<")?l:jQuery("").html(l):a.addClass("waymark-no-description");break;case"image_large_url":if(void 0!==e.properties.image_large_url){var h=e.properties.image_large_url;if(void 0!==e.properties.image_medium_url)var h=e.properties.image_medium_url;s=jQuery("").attr({href:e.properties.image_large_url,target:"_blank",style:"background-image:url("+h+")"})}else a.addClass("waymark-no-image")}s&&a.append(jQuery("").addClass("waymark-info-"+key+" waymark-"+t+"-info-"+key).append(s))}return a.children().length&&n.append(a),n},this.info_window=function(t,e,n){if(Waymark=this,Waymark.config.show_elevation&&"line"==t&&(Waymark.config.elevation_initial&&Waymark.line_has_elevation_data(e)&&!Waymark.elevation_container.is(":visible")&&(Waymark.elevation_container.show(),Waymark.elevation_control.loadData(e)),n.on("click",function(t){var e=t.target.feature;Waymark.elevation_control.clear(),void 0!==Waymark.elevation_control.layer&&Waymark.elevation_control.layer.removeFrom(Waymark.map),Waymark.elevation_container.hide(),Waymark.line_has_elevation_data(e)&&(Waymark.elevation_container.show(),Waymark.elevation_control.loadData(e))})),void 0!==e.properties.description||void 0!==e.properties.image_large_url){var a=Waymark.build_content(t,e,n),s=e.properties.title;"function"==typeof Waymark.config.handle_content_callback?n.on("click",function(){Waymark.config.handle_content_callback(a.get(0),s,Waymark.mode)}):n.bindPopup(a.get(0)).openPopup()}},this.line_has_elevation_data=function(t){if("MultiLineString"==t.geometry.type){for(var e in t.geometry.coordinates)for(var n in t.geometry.coordinates[e])if(3==t.geometry.coordinates[e][n].length)return!0}else for(var n in t.geometry.coordinates)if(3==t.geometry.coordinates[n].length)return!0;return!1},this.setup_elevation=function(){if(Waymark=this,Waymark.config.show_elevation){Waymark_L.registerLocale("waymark",{"Total Length: ":waymark_js.lang.label_total_length,"Max Elevation: ":waymark_js.lang.label_max_elevation,"Min Elevation: ":waymark_js.lang.label_min_elevation,"Total Ascent: ":waymark_js.lang.label_ascent,"Total Descent: ":waymark_js.lang.label_descent}),Waymark_L.setLocale("waymark");var t={theme:"magenta-theme",detached:!0,followMarker:!1,width:Waymark.config.map_width};if(void 0!==Waymark.config.elevation_div_id){t.elevationDiv="#"+Waymark.config.elevation_div_id,Waymark.elevation_container=jQuery(t.elevationDiv),Waymark.elevation_container.hide();var e=jQuery("").addClass("waymark-elevation-close").text("x").on("click",{W:Waymark},function(t){var e=t.data.W;e.elevation_control.clear(),e.elevation_control.layer.removeFrom(e.map),e.elevation_container.hide()});Waymark.elevation_container.append(e)}void 0!==Waymark.config.elevation_units&&"imperial"==Waymark.config.elevation_units&&(t.imperial=!0),Waymark.elevation_control=Waymark_L.control.elevation(t).addTo(Waymark.map),Waymark.map.on("overlayremove",function(t){if(void 0!==Waymark.elevation_control.layer){var e=null;Waymark.elevation_control.layer.eachLayer(function(t){e=JSON.stringify(t.getLatLngs())}),e&&t.layer.eachLayer(function(t){void 0!==t.getLatLngs&&e==JSON.stringify(t.getLatLngs())&&(Waymark.elevation_control.clear(),Waymark.elevation_control.layer.removeFrom(Waymark.map),Waymark.elevation_container.hide())})}})}},this.setup_gallery=function(){if(Waymark=this,Waymark.config.show_gallery){Waymark.gallery=jQuery("").attr("id",Waymark.config.gallery_div_id).css("width",Waymark.config.map_width).addClass("waymark-gallery-container").html(""),Waymark_L.DomEvent.disableClickPropagation(Waymark.gallery.get(0)),jQuery(Waymark.map.getContainer()).append(Waymark.gallery),Waymark.size_gallery();var t=Waymark;Waymark.map.on("moveend",function(){t.render_gallery()},{W:t}),Waymark.map.on("layerremove layeradd",function(){t.render_gallery()},{W:t})}},this.size_gallery=function(){if(Waymark=this,void 0!==Waymark.gallery&&Waymark.gallery.length){gallery_padding=parseInt(gallery_padding=(gallery_padding=Waymark.gallery.css("paddingRight")).replace("px",""));var t=Waymark.config.map_width-2*gallery_padding;Waymark.gallery.css("width",t)}},this.add_to_gallery=function(t){if(Waymark=this,void 0===t.feature.properties.image_thumbnail_url||void 0===t.feature.properties.image_large_url)return!1;var e=Object.assign({},t.feature.properties);e.latlng=t.feature.geometry.coordinates,e.marker=t,Waymark.gallery_images.push(e)},this.render_gallery=function(){Waymark=this;var t=0;if(void 0!==Waymark.gallery&&Waymark.gallery.length&&(Waymark.gallery.html(""),Waymark.gallery.hide(),jQuery(Waymark.map.getContainer()).removeClass("waymark-has-gallery"),Waymark.gallery_images.length)){for(i=0;i").addClass("waymark-image").on("click",{marker:e.marker},function(t){t.data.marker.openPopup()}),s=jQuery("
").attr({src:e.image_thumbnail_url});a.append(s),Waymark.gallery.append(a)}}t&&(Waymark.gallery.show(),jQuery(Waymark.map.getContainer()).addClass("waymark-has-gallery"))}}}function Waymark_Map_Editor(){this.pre_map_setup=function(){Waymark=this,Waymark.mode="edit"},this.init_done=function(){Waymark=this,jQuery(Waymark.map.getContainer()).addClass("waymark-is-editor"),Waymark.jq_map_container.append(jQuery("").attr({id:"waymark-loading"}).html('')),Waymark.map.on("editable:drawing:commit",function(t){switch(void 0===(layer=t.layer).feature&&(layer.feature={type:"Feature",properties:{}}),!0){case layer instanceof Waymark_L.Circle:layer.feature.properties=Waymark.config.shape_data_defaults,layer.feature.properties.radius=layer.getRadius();break;case layer instanceof Waymark_L.Rectangle:layer.feature.properties=Waymark.config.shape_data_defaults,layer.feature.properties.rectangle=!0;break;case layer instanceof Waymark_L.Polygon:layer.feature.properties=Waymark.config.shape_data_defaults;break;case layer instanceof Waymark_L.Polyline:layer.feature.properties=Waymark.config.line_data_defaults}Waymark.map_data.addData(layer.toGeoJSON()),Waymark.map.removeLayer(layer),Waymark.save_data_layer(),Waymark.map_was_edited()}),Waymark.map.on("editable:editing",function(t){void 0!==(layer=t.layer).feature&&layer.feature.properties.radius&&(layer.feature.properties.radius=layer.getRadius()),Waymark.save_data_layer(),Waymark.map_was_edited()}),Waymark.map.on("popupopen",function(t){var e=t.popup._source.feature;setTimeout(function(){wp.editor.initialize("waymark-info-description",{tinymce:{toolbar1:"styleselect | bullist numlist | link image",setup:function(t){t.on("change",function(t){e.properties.description=wp.editor.getContent("waymark-info-description"),Waymark.save_data_layer(),Waymark.map_was_edited()})}}})},250)}),Waymark.map.on("popupclose",function(t){wp.editor.remove("waymark-info-description"),jQuery("#waymark-info-description").show()})},this.create_marker=function(t){Waymark=this;var e=Waymark_L.marker(t,{draggable:!0});return e.on("moveend",function(t){var e=t.target,n=e.feature;n.geometry.coordinates=[e._latlng.lng.toFixed(6),e._latlng.lat.toFixed(6),],Waymark.info_window("marker",n,e),Waymark.save_data_layer(),Waymark.map_was_edited()}),e},this.save_data_layer=function(){Waymark=this;var t=jQuery(".waymark-input-map_data").first(),e=JSON.stringify(Waymark.map_data.toGeoJSON());t.html(e)},this.map_was_edited=function(){},this.loading_start=function(){Waymark=this,Waymark.jq_map_container.addClass("waymark-loading")},this.loading_stop=function(){Waymark=this,Waymark.jq_map_container.removeClass("waymark-loading")},this.create_buttons=function(){Waymark=this;var t=Waymark_L.Control.geocoder({position:"bottomright",defaultMarkGeocode:!1,placeholder:waymark_js.lang.action_search_placeholder});t.on("markgeocode",function(t){Waymark.map.fitBounds(t.geocode.bbox)}),t.addTo(Waymark.map);var e=Waymark_L.Control.extend({options:{position:"bottomleft"},onAdd:function(t){var e=Waymark_L.DomUtil.create("div","leaflet-bar leaflet-control waymark-leaflet-control waymark-edit-toolbar"),n=Waymark_L.DomUtil.create("a","waymark-icon waymark-edit-button waymark-edit-line",e);n.setAttribute("title",waymark_js.lang.add_line_title),n.onclick=function(){Waymark.map.editTools.startPolyline()};var n=Waymark_L.DomUtil.create("a","waymark-edit-button waymark-edit-image",e);n.innerHTML='',n.setAttribute("title",waymark_js.lang.add_photo_title),n.onclick=function(){if(void 0!==wp.media)return wp.media.editor.send.attachment=function(t,e){if(Waymark.debug(e),void 0===e.url)return!1;var n=new FormData;n.append("waymark_security",waymark_security),n.append("action","waymark_get_attatchment_meta"),n.append("attachment_id",e.id),jQuery.ajax({type:"POST",url:waymark_js.ajaxurl,data:n,dataType:"json",processData:!1,contentType:!1,success:function(t){if(Waymark.debug(t),null===t){Waymark.message(waymark_js.lang.error_photo_meta,"error");return}var n=Waymark.map.getCenter();(latlng=Waymark.get_exif_latlng(t))&&(n=latlng,Waymark.map.setView(n));var a=Waymark.get_image_sizes(e.sizes,e.url),s=Waymark.create_marker_json(n,a);Waymark.map_data.addData(s),Waymark.save_data_layer(),Waymark.map_was_edited()}})},wp.media.editor.open(),!1;var t=jQuery("").attr({type:"file",name:"add_photo"}).css("display","none").change(function(){Waymark.handle_file_upload(jQuery(this))});jQuery("#waymark-edit-toolbar").append(t),t.trigger("click")};var n=Waymark_L.DomUtil.create("a","waymark-edit-button waymark-edit-marker",e);n.innerHTML='',n.setAttribute("title",waymark_js.lang.add_marker_title),n.onclick=function(){var t=Waymark.create_marker_json(Waymark.map.getCenter());Waymark.map_data.addData(t),Waymark.save_data_layer(),Waymark.map_was_edited()};var n=Waymark_L.DomUtil.create("a","waymark-edit-button waymark-edit-rectangle",e);n.innerHTML='',n.setAttribute("title",waymark_js.lang.add_rectangle_title),n.onclick=function(){Waymark.map.editTools.startRectangle()};var n=Waymark_L.DomUtil.create("a","waymark-edit-button waymark-edit-polygon",e);n.innerHTML='',n.setAttribute("title",waymark_js.lang.add_polygon_title),n.onclick=function(){Waymark.map.editTools.startPolygon()};var n=Waymark_L.DomUtil.create("a","waymark-edit-button waymark-edit-circle",e);if(n.innerHTML='',n.setAttribute("title",waymark_js.lang.add_circle_title),n.onclick=function(){Waymark.map.editTools.startCircle()},void 0!==wp.media&&!0==Waymark.get_property(waymark_settings,"misc","editor_options","media_library_uploads")){var n=Waymark_L.DomUtil.create("a","waymark-edit-button waymark-edit-upload",e);n.innerHTML='',n.setAttribute("title",waymark_js.lang.upload_file_title),n.onclick=function(){return wp.media.editor.send.attachment=function(t,e){Waymark.debug(e),jQuery.ajax({type:"GET",url:e.url,dataType:"text",success:function(t){switch(e.mime){case"application/gpx+xml":Waymark.load_file_contents(t,"gpx");break;case"application/vnd.google-earth.kml+xml":Waymark.load_file_contents(t,"kml");break;case"application/geo+json":Waymark.load_file_contents(t,"geojson");break;default:Waymark.message(waymark_js.lang.error_file_upload)}}})},wp.media.editor.open(),!1}}else{var a=jQuery("").attr({type:"file",name:"add_file"}).css("display","none").change(function(){Waymark.handle_file_upload(jQuery(this))}),n=Waymark_L.DomUtil.create("a","waymark-edit-button waymark-edit-upload",e);jQuery("#waymark-edit-toolbar").append(a),n.innerHTML='',n.setAttribute("title",waymark_js.lang.upload_file_title),n.onclick=function(){a.trigger("click"),Waymark.map.editTools.stopDrawing()}}return e}});Waymark.map.addControl(new e)},this.handle_file_upload=function(t,e={}){Waymark=this,Waymark.loading_start();var n=new FormData;n.append("waymark_security",waymark_security),n.append("action","waymark_read_file"),n.append(t.attr("name"),t[0].files[0]),jQuery.ajax({type:"POST",url:waymark_js.ajaxurl,data:n,dataType:"json",processData:!1,contentType:!1,success:function(n){if(Waymark.debug(n),null===n)return Waymark.message(waymark_js.lang.error_file_upload,"error"),Waymark.loading_stop(),!1;if(n.error)return Waymark.message(n.error,"error"),Waymark.loading_stop(),!1;switch(t.attr("name")){case"add_file":Waymark.load_file_contents(n.file_contents,n.file_type);break;case"add_photo":if(void 0===n.url)return!1;var a=Waymark.map.getCenter();(latlng=Waymark.get_exif_latlng(n))&&(a=latlng,Waymark.map.setView(a));var s=Waymark.get_image_sizes(n.sizes,n.url),r=Waymark.create_marker_json(a,s);Waymark.map_data.addData(r),//!!! To-do - move this into Waymark.map_was_edited()
+Waymark.save_data_layer();break;case"marker_photo":if(void 0===n.url)return!1;var s=Waymark.get_image_sizes(n.sizes,n.url);e.feature.properties=Object.assign({},e.feature.properties,s),e.img_view.attr("href",e.feature.properties.image_large_url),jQuery("img",e.img_view).attr("src",e.feature.properties.image_thumbnail_url),e.img_input.val(e.feature.properties.image_large_url),//!!! To-do - move this into Waymark.map_was_edited()
+Waymark.save_data_layer()}Waymark.map_was_edited(),Waymark.loading_stop()}})},this.build_content=function(t,e,n){Waymark=this;var a=jQuery(""),s=jQuery("").addClass("waymark-info");if("line"==t||"shape"==t){var r=jQuery("").html('').addClass("button").attr("title",waymark_js.lang.action_edit+" "+Waymark.title_case(waymark_js.lang["object_label_"+t])).on("click",function(e){e.preventDefault();var a=jQuery(this),s=jQuery("i",a);return n.editEnabled()?(n.disableEdit(),a.attr("title",waymark_js.lang.action_edit+" "+Waymark.title_case(waymark_js.lang["object_label_"+t])),s.attr("class","ion-edit"),"function"==typeof Waymark.config.handle_edit_callback&&Waymark.config.handle_edit_callback(!1)):(n.enableEdit(),n.closePopup(),a.attr("title",waymark_js.lang.action_edit_done),s.attr("class","ion-android-done"),"function"==typeof Waymark.config.handle_edit_callback&&Waymark.config.handle_edit_callback(!0)),!1});s.append(jQuery("").addClass("waymark-info-button waymark-info-edit waymark-"+t+"-edit").append(r))}var r=jQuery("").html('').addClass("button").attr("title",waymark_js.lang.action_duplicate+" "+Waymark.title_case(waymark_js.lang["object_label_"+t])).on("click",function(t){return t.preventDefault(),Waymark.load_json(Object.assign({},n.feature)),Waymark.map_was_edited(),!1});s.append(jQuery("").addClass("waymark-info-button waymark-info-duplicate waymark-"+t+"-duplicate").append(r));var r=jQuery("").html('').addClass("button").attr("title",waymark_js.lang.action_delete+" "+Waymark.title_case(waymark_js.lang["object_label_"+t])).on("click",function(a){return a.preventDefault(),!!("1"!=Waymark.config.editor_options.confirm_delete||confirm(waymark_js.lang.action_delete_confirm+" "+Waymark.title_case(waymark_js.lang["object_label_"+t])+"?"))&&(Waymark.map.removeLayer(n),Waymark.map_data.removeLayer(n),Waymark.save_data_layer(),Waymark.map_was_edited(),"function"==typeof Waymark.config.handle_delete_callback&&Waymark.config.handle_delete_callback(e),!1)});s.append(jQuery("").addClass("waymark-info-button waymark-info-delete waymark-"+t+"-delete").append(r));var l=Waymark.config[t+"_types"];if("line"==t){var h=jQuery("");h.append(jQuery("").val("").text(Waymark.title_case(waymark_js.lang.no_direction)),jQuery("").val("default").text(Waymark.title_case(waymark_js.lang.show_direction)),jQuery("").val("reverse").text(Waymark.title_case(waymark_js.lang.reverse_direction))),h.change(function(){jQuery("option:selected",jQuery(this));var t=jQuery(this).val();e.properties.direction=t,Waymark.draw_line_direction(n),Waymark.save_data_layer(),Waymark.map_was_edited()}),s.append(jQuery("").addClass("waymark-info-direction waymark-line-direction").append(h)),"string"==typeof e.properties.direction&&jQuery("option",h).filter(function(){return jQuery(this).val()==Waymark.make_key(e.properties.direction)}).attr("selected","selected")}var c=jQuery("");for(var d in c.append(jQuery("").attr({disabled:"disabled"}).text(Waymark.title_case(waymark_js.lang["object_label_"+t])+" "+waymark_js.lang.object_type_label+":")),l){var u=Waymark.make_key(l[d][t+"_title"]);c.append(jQuery("").val(u).text(l[d][t+"_title"]))}c.change(function(){jQuery("option:selected",jQuery(this));var a=jQuery(this).val();if(e.properties.type=a,"object"!=typeof a)var s=Waymark.get_type(t,e.properties.type);switch(t){case"line":n.setStyle({color:s.line_colour,weight:s.line_weight,opacity:s.line_opacity});break;case"shape":n.setStyle({color:s.shape_colour,fillOpacity:s.fill_opacity});break;case"marker":n.setIcon(Waymark_L.divIcon(Waymark.build_icon_data(s)))}Waymark.save_data_layer(),Waymark.map_was_edited()}),s.append(jQuery("").addClass("waymark-info-type waymark-"+t+"-type").append(c)),jQuery("option",c).filter(function(){return jQuery(this).val()==Waymark.make_key(e.properties.type)}).attr("selected","selected");var p=jQuery("").addClass("waymark-overlay-preview waymark-"+t+"-preview");for(var d in l){var m=l[d][t+"_title"],u=Waymark.make_key(m),f=Waymark.get_type(t,u),g=jQuery("").addClass("waymark-type").data("type_key",u).attr("title",m);switch(t){case"marker":var y=Waymark.build_icon_data(f);g.addClass(y.className).html(y.html).css({width:y.iconSize[0],height:y.iconSize[1]});break;case"line":g.addClass("waymark-line").append(jQuery("").css({margin:"15px 0",height:"1px",borderTop:f.line_weight+"px solid "+f.line_colour}));break;case"shape":g.addClass("waymark-shape").css({border:"3px solid "+f.shape_colour}).append(jQuery("").css({height:"20px",background:f.shape_colour,opacity:f.fill_opacity}))}var v=jQuery("").addClass("waymark-overlay-wrap waymark-"+t+"-wrap");"1"==Waymark.config.map_options.show_type_labels&&v.append(jQuery("").addClass("waymark-type-title").text(m)),v.append(g),v.on("click",function(){var e=(g=jQuery(".waymark-type",jQuery(this))).data("type_key");jQuery("option",c).each(function(){g.val()==e?g.attr("selected","selected"):g.removeAttr("selected")}),c.val(e),c.trigger("change"),jQuery(".waymark-"+t+"-wrap",p).each(function(){g.removeClass("waymark-active")}),g.parent(".waymark-"+t+"-wrap").addClass("waymark-active")}),u==Waymark.make_key(e.properties.type)?(v.addClass("waymark-active"),p.prepend(v)):p.append(v)}for(key in s.append(p),Waymark.config[t+"_data_defaults"]){var r=null;switch(key){case"title":var r=jQuery("").attr({type:"text",value:e.properties.title,placeholder:Waymark.title_case(waymark_js.lang["object_label_"+t])+" "+waymark_js.lang.object_title_placeholder}).on("change",function(){e.properties.title=jQuery(this).val(),Waymark.save_data_layer(),Waymark.map_was_edited()});break;case"description":var r=jQuery("").attr({id:"waymark-info-description",class:"wp-editor",placeholder:Waymark.title_case(waymark_js.lang["object_label_"+t])+" "+waymark_js.lang.object_description_placeholder}).val(e.properties.description).on("change",function(){e.properties.description=jQuery(this).val(),Waymark.save_data_layer(),Waymark.map_was_edited()});break;case"image_large_url":var k=jQuery("").attr({value:e.properties.image_large_url,placeholder:waymark_js.lang.object_image_placeholder}).on("change",function(){e.properties.image_large_url=jQuery(this).val(),Waymark.save_data_layer(),Waymark.map_was_edited()});if(void 0!==e.properties.image_thumbnail_url)var w=e.properties.image_thumbnail_url;else var w=e.properties.image_large_url;var x=jQuery("
").attr({src:w,width:160});k.on("change",function(){x.attr("src",jQuery(this).val())});var $=jQuery("").attr({href:e.properties.image_large_url,target:"_blank"}).append(x).hover(function(){jQuery(this).addClass("waymark-hover")},function(){jQuery(this).removeClass("waymark-hover")}),b=jQuery("").text(waymark_js.lang.action_upload_image).attr({type:"submit",name:"add_photo",class:"waymark-input button button-small",id:"add_photo"}).on("click",function(t){if(t.preventDefault(),void 0!==wp.media)return wp.media.editor.send.attachment=function(t,n){if(Waymark.debug(n),void 0===n.url)return!1;var a=Waymark.get_image_sizes(n.sizes,n.url);e.properties=Object.assign({},e.properties,a),$.attr("href",e.properties.image_large_url),jQuery("img",$).attr("src",e.properties.image_thumbnail_url),k.val(e.properties.image_large_url),Waymark.save_data_layer(),Waymark.map_was_edited()},wp.media.editor.open(),!1;var n=jQuery("").attr({type:"file",name:"marker_photo"}).css("display","none").change(function(){Waymark.handle_file_upload(jQuery(this),{feature:e,img_view:$,img_input:k})});jQuery("#waymark-edit-toolbar").append(n),n.trigger("click")}),r=jQuery("").append($,k,b)}r&&s.append(jQuery("").addClass("waymark-info-"+key+" waymark-"+t+"-info-"+key).append(r))}if("marker"==t&&void 0!==n.feature.geometry.coordinates){n.feature.geometry.coordinates;var C=n.feature.geometry.coordinates[1],P=n.feature.geometry.coordinates[0];"number"==typeof C&&(P=P.toFixed(6),C=C.toFixed(6)),r=jQuery("").html(""+waymark_js.lang.marker_latlng_label+": "+C+","+P),s.append(jQuery("").addClass("waymark-info-latlng waymark-marker-info-latlng").append(r))}return s.children().length&&a.append(s),a},this.info_window=function(t,e,n){Waymark=this;var a=Waymark.title_case(waymark_js.lang.action_edit+" "+t);if("function"==typeof Waymark.config.handle_content_callback)n.on("click",function(){var s=Waymark.build_content(t,e,n);Waymark.config.handle_content_callback(s.get(0),a,Waymark.mode)});else{var s=Waymark.build_content(t,e,n).get(0);n.bindPopup(s,{}).openPopup().on("click",function(){})}},this.load_file_contents=function(t,e){switch(Waymark=this,t=t.trim(),e=e.toLowerCase()){case"gpx":var n=new DOMParser().parseFromString(t,"text/xml"),a=toGeoJSON.gpx(n);break;case"kml":var s=new DOMParser().parseFromString(t,"text/xml"),a=toGeoJSON.kml(s);break;case"json":case"geojson":var a=JSON.parse(t);break;default:Waymark.message(waymark_js.lang.error_file_type,"error")}void 0!==a?this.load_json(a):Waymark.message(waymark_js.lang.error_file_conversion,"error")},this.load_json=function(t){if(Waymark=this,"object"==typeof t){Waymark.map_data.addData(t),Waymark.save_data_layer();var e=Waymark.map_data.getBounds();e.isValid()&&Waymark.map.fitBounds(e)}}}function Waymark_Map_Factory(){this.instances=[],this.viewer=function(){var t=Object.assign(new Waymark_Map,new Waymark_Map_Viewer);return this.instances.push(t),t},this.editor=function(){var t=Object.assign(new Waymark_Map,new Waymark_Map_Editor);return this.instances.push(t),t}}window.Waymark_Map_Factory=new Waymark_Map_Factory;
\ No newline at end of file
diff --git a/waymark-js/libs/js/leaflet-elevation.js b/waymark-js/libs/js/leaflet-elevation.js
index f8b1fbca..87cbcddf 100755
--- a/waymark-js/libs/js/leaflet-elevation.js
+++ b/waymark-js/libs/js/leaflet-elevation.js
@@ -200,7 +200,9 @@
this.track_info = L.extend({}, this.track_info, {
distance: this._distance,
elevation_max: this._maxElevation,
- elevation_min: this._minElevation
+ elevation_min: this._minElevation,
+ ascent : this._ascent,
+ descent : this._descent
});
this._layers = this._layers || {};
@@ -666,6 +668,19 @@
if (!isNaN(z)) {
eleMax = eleMax < z ? z : eleMax;
eleMin = eleMin > z ? z : eleMin;
+
+ // calculate new ascent or descent
+ let dz = z - this._lastValidZ ;
+ if (dz > 0){
+ this.track_info.ascent = (this.track_info.ascent || 0) + dz; // Total Ascent
+ this._ascent = this.track_info.ascent;
+ }
+ else if (dz < 0){
+ this.track_info.descent = (this.track_info.descent || 0) - dz; // Total Descent
+ this._descent = this.track_info.descent;
+ }
+
+ // set up last valid z value
this._lastValidZ = z;
}
@@ -1787,9 +1802,11 @@
this.track_info.distance = this._distance || 0;
this.track_info.elevation_max = this._maxElevation || 0;
this.track_info.elevation_min = this._minElevation || 0;
+ this.track_info.ascent = this._ascent || 0;
+ this.track_info.descent = this._descent || 0;
if (this.options.summary) {
- this.summaryDiv.innerHTML += '' + L._("Total Length: ") + '' + this.track_info.distance.toFixed(2) + ' ' + this._xLabel + '' + L._("Max Elevation: ") + '' + this.track_info.elevation_max.toFixed(2) + ' ' + this._yLabel + '' + L._("Min Elevation: ") + '' + this.track_info.elevation_min.toFixed(2) + ' ' + this._yLabel + '';
+ this.summaryDiv.innerHTML += '' + L._("Total Length: ") + '' + this.track_info.distance.toFixed(2) + ' ' + this._xLabel + '' + L._("Max Elevation: ") + '' + this.track_info.elevation_max.toFixed(2) + ' ' + this._yLabel + '' + L._("Min Elevation: ") + '' + this.track_info.elevation_min.toFixed(2) + ' ' + this._yLabel + '' + L._("Total Ascent: ") + '' + this.track_info.ascent.toFixed(0) + ' ' + this._yLabel + '' + L._("Total Descent: ") + '' + this.track_info.descent.toFixed(0) + ' ' + this._yLabel + '';
}
if (this.options.downloadLink && this._downloadURL) { // TODO: generate dynamically file content instead of using static file urls.
this.summaryDiv.innerHTML += '' + L._('Download') + '';
diff --git a/waymark-js/src/js/Waymark_Map.js b/waymark-js/src/js/Waymark_Map.js
index b88c4911..cc688d5a 100644
--- a/waymark-js/src/js/Waymark_Map.js
+++ b/waymark-js/src/js/Waymark_Map.js
@@ -14,6 +14,8 @@ var waymark_js_localize = {
label_total_length: "Total Length: ",
label_max_elevation: "Max. Elevation: ",
label_min_elevation: "Min. Elevation: ",
+ label_ascent: "Total Ascent: ",
+ label_descent: "Total Descent: ",
//Editor
add_line_title: "Draw a Line",
add_photo_title: "Upload an Image",
diff --git a/waymark-js/src/js/Waymark_Map_Viewer.js b/waymark-js/src/js/Waymark_Map_Viewer.js
index f4f10319..9a9fb104 100644
--- a/waymark-js/src/js/Waymark_Map_Viewer.js
+++ b/waymark-js/src/js/Waymark_Map_Viewer.js
@@ -422,6 +422,8 @@ function Waymark_Map_Viewer() {
"Total Length: ": waymark_js.lang.label_total_length,
"Max Elevation: ": waymark_js.lang.label_max_elevation,
"Min Elevation: ": waymark_js.lang.label_min_elevation,
+ "Total Ascent: ": waymark_js.lang.label_ascent,
+ "Total Descent: ": waymark_js.lang.label_descent,
});
Waymark_L.setLocale("waymark");