leaflet-ui
Version:
Leaflet presets for common user interface customizations
17 lines (16 loc) • 147 kB
JavaScript
!function(t){"function"==typeof define&&define.amd?define(t):t()}((function(){"use strict";const t=L.extend({},L.DomUtil);L.extend(L.DomUtil,{setTransform:function(e,i,o,n,a){var s=i||new L.Point(0,0);if(!n)return i=s._round(),t.setTransform.call(this,e,i,o);s=s.rotateFrom(n,a),e.style[L.DomUtil.TRANSFORM]="translate3d("+s.x+"px,"+s.y+"px,0)"+(o?" scale("+o+")":"")+" rotate("+n+"rad)"},setPosition:function(e,i,o,n){if(!o)return t.setPosition.call(this,e,i);e._leaflet_pos=i,L.Browser.any3d?L.DomUtil.setTransform(e,i,void 0,o,n):(e.style.left=i.x+"px",e.style.top=i.y+"px")},DEG_TO_RAD:Math.PI/180,RAD_TO_DEG:180/Math.PI}),L.Draggable.include({updateMapBearing:function(t){this._mapBearing=t}}),L.extend(L.Point.prototype,{rotate:function(t){if(!t)return this;var e=Math.sin(t),i=Math.cos(t);return new L.Point(this.x*i-this.y*e,this.x*e+this.y*i)},rotateFrom:function(t,e){if(!t)return this;var i=Math.sin(t),o=Math.cos(t),n=e.x,a=e.y,s=this.x-n,r=this.y-a;return new L.Point(s*o-r*i+n,s*i+r*o+a)}});const e=L.extend({},L.DivOverlay.prototype);L.DivOverlay.include({getEvents:function(){return L.extend(e.getEvents.call(this),{rotate:this._updatePosition})},_updatePosition:function(){if(this._map){var t=this._map.latLngToLayerPoint(this._latlng),e=L.point(this.options.offset),i=this._getAnchor();this._zoomAnimated?(this._map._rotate&&(t=this._map.rotatedPointToMapPanePoint(t)),L.DomUtil.setPosition(this._container,t.add(i))):e=e.add(t).add(i);var o=this._containerBottom=-e.y,n=this._containerLeft=-Math.round(this._containerWidth/2)+e.x;this._container.style.bottom=o+"px",this._container.style.left=n+"px"}}});const o=L.extend({},L.Popup.prototype);L.Popup.include({_animateZoom:function(t){this._map._rotate||o._animateZoom.call(this,t);var e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center),i=this._getAnchor();e=this._map.rotatedPointToMapPanePoint(e),L.DomUtil.setPosition(this._container,e.add(i))},_adjustPan:function(){if(!(!this.options.autoPan||this._map._panAnim&&this._map._panAnim._inProgress)){var t=this._map,e=parseInt(L.DomUtil.getStyle(this._container,"marginBottom"),10)||0,i=this._container.offsetHeight+e,o=this._containerWidth,n=new L.Point(this._containerLeft,-i-this._containerBottom);n._add(L.DomUtil.getPosition(this._container));var a=n._add(this._map._getMapPanePos()),s=L.point(this.options.autoPanPadding),r=L.point(this.options.autoPanPaddingTopLeft||s),l=L.point(this.options.autoPanPaddingBottomRight||s),h=t.getSize(),c=0,p=0;a.x+o+l.x>h.x&&(c=a.x+o-h.x+l.x),a.x-c-r.x<0&&(c=a.x-r.x),a.y+i+l.y>h.y&&(p=a.y+i-h.y+l.y),a.y-p-r.y<0&&(p=a.y-r.y),(c||p)&&t.fire("autopanstart").panBy([c,p])}}});const n=L.extend({},L.Tooltip.prototype);L.Tooltip.include({_updatePosition:function(){if(!this._map._rotate)return n._updatePosition.call(this);var t=this._map.latLngToLayerPoint(this._latlng);t=this._map.rotatedPointToMapPanePoint(t),this._setPosition(t)},_animateZoom:function(t){if(!this._map._rotate)return n._animateZoom.call(this,t);var e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center);e=this._map.rotatedPointToMapPanePoint(e),this._setPosition(e)}});L.extend({},L.Icon.prototype);var a;L.Icon.include({_setIconStyles:function(t,e){var i=this.options,o=i[e+"Size"];"number"==typeof o&&(o=[o,o]);var n=L.point(o),a=L.point("shadow"===e&&i.shadowAnchor||i.iconAnchor||n&&n.divideBy(2,!0));t.className="leaflet-marker-"+e+" "+(i.className||""),a&&(t.style.marginLeft=-a.x+"px",t.style.marginTop=-a.y+"px",t.style[L.DomUtil.TRANSFORM+"Origin"]=a.x+"px "+a.y+"px 0px"),n&&(t.style.width=n.x+"px",t.style.height=n.y+"px")}});var s={_onDragStart:function(){if(!this._marker._map._rotate)return a._onDragStart.call(this);this._draggable.updateMapBearing(this._marker._map._bearing)},_onDrag:function(t){var e=this._marker,i=e.options.rotation||e.options.rotateWithView,o=e._shadow,n=L.DomUtil.getPosition(e._icon);!i&&o&&L.DomUtil.setPosition(o,n),e._map._rotate&&(n=e._map.mapPanePointToRotatedPoint(n));var a=e._map.layerPointToLatLng(n);e._latlng=a,t.latlng=a,t.oldLatLng=this._oldLatLng,i?e.setLatLng(a):e.fire("move",t),e.fire("drag",t)},_onDragEnd:function(t){this._marker._map._rotate&&this._marker.update(),a._onDragEnd.call(this,t)}};const r=L.extend({},L.Marker.prototype);L.Marker.mergeOptions({rotation:0,rotateWithView:!1}),L.Marker.include({getEvents:function(){return L.extend(r.getEvents.call(this),{rotate:this.update})},onAdd:function(t){r.onAdd.call(this,t),t.on("rotate",this.update,this)},_initInteraction:function(){var t=r._initInteraction.call(this);return this.dragging&&this._map&&this._map._rotate&&(a=a||Object.getPrototypeOf(this.dragging),this.dragging._onDragStart=s._onDragStart.bind(this.dragging),this.dragging._onDrag=s._onDrag.bind(this.dragging),this.dragging._onDragEnd=s._onDragEnd.bind(this.dragging),this.dragging.disable(),this.dragging.enable()),t},_setPos:function(t){this._map._rotate&&(t=this._map.rotatedPointToMapPanePoint(t));var e=this.options.rotation||0;this.options.rotateWithView&&(e+=this._map._bearing),L.DomUtil.setPosition(this._icon,t,e,t),this._shadow&&L.DomUtil.setPosition(this._shadow,t,e,t),this._zIndex=t.y+this.options.zIndexOffset,this._resetZIndex()},_updateZIndex:function(t){if(!this._map._rotate)return r._updateZIndex.call(this,t);this._icon.style.zIndex=Math.round(this._zIndex+t)},setRotation:function(t){this.options.rotation=t,this.update()}});const l=L.extend({},L.GridLayer.prototype);L.GridLayer.include({getEvents:function(){var t=l.getEvents.call(this);return this._map._rotate&&!this.options.updateWhenIdle&&(this._onRotate||(this._onRotate=L.Util.throttle(this._onMoveEnd,this.options.updateInterval,this)),t.rotate=this._onRotate),t},_getTiledPixelBounds:function(t){if(!this._map._rotate)return l._getTiledPixelBounds.call(this,t);var e=this._map,i=e._animatingZoom?Math.max(e._animateToZoom,e.getZoom()):e.getZoom(),o=e.getZoomScale(i,this._tileZoom),n=e.project(t,this._tileZoom).floor(),a=e.getSize(),s=new L.Bounds([e.containerPointToLayerPoint([0,0]).floor(),e.containerPointToLayerPoint([a.x,0]).floor(),e.containerPointToLayerPoint([0,a.y]).floor(),e.containerPointToLayerPoint([a.x,a.y]).floor()]).getSize().divideBy(2*o);return new L.Bounds(n.subtract(s),n.add(s))}});const h=L.extend({},L.Canvas.prototype);L.Canvas.include({onAdd:function(){h.onAdd.call(this),this._map.on("rotate",this._redraw,this)},onRemove:function(){h.onRemove.call(this),this._map.off("rotate",this._redraw,this)},_update:function(){h._update.call(this),this.fire("update")}});const c=L.extend({},L.Renderer.prototype);L.Renderer.include({onAdd:function(){c.onAdd.call(this)},onRemove:function(){c.onRemove.call(this)},_updateTransform:function(t,e){if(!this._map._rotate)return c._updateTransform.call(this,t,e);var i=this._map.getZoomScale(e,this._zoom),o=this._map._latLngToNewLayerPoint(this._topLeft,e,t);L.Browser.any3d?L.DomUtil.setTransform(this._container,o,i):L.DomUtil.setPosition(this._container,o)},_update:function(){if(!this._map._rotate)return c._update.call(this);var t=this.options.padding,e=this._map,i=this._map.getSize(),o=i.multiplyBy(-t),n=i.multiplyBy(1+t),a=new L.Bounds([e.containerPointToLayerPoint([o.x,o.y]).floor(),e.containerPointToLayerPoint([o.x,n.y]).floor(),e.containerPointToLayerPoint([n.x,o.y]).floor(),e.containerPointToLayerPoint([n.x,n.y]).floor()]);this._bounds=a,this._topLeft=this._map.layerPointToLatLng(a.min),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}});const p=L.extend({},L.SVG.prototype);L.SVG.include({_update:function(){p._update.call(this),this._map._rotate&&this.fire("update")}});const d=L.extend({},L.Map.prototype);L.Map.mergeOptions({rotate:!1,bearing:0}),L.Map.include({initialize:function(t,e){e.rotate&&(this._rotate=!0,this._bearing=0),d.initialize.call(this,t,e),this.options.rotate&&this.setBearing(this.options.bearing)},containerPointToLayerPoint:function(t){return this._rotate?L.point(t).subtract(this._getMapPanePos()).rotateFrom(-this._bearing,this._getRotatePanePos()).subtract(this._getRotatePanePos()):d.containerPointToLayerPoint.call(this,t)},getBounds:function(){if(!this._rotate)return d.getBounds.call(this);var t=this.getSize(),e=this.layerPointToLatLng(this.containerPointToLayerPoint([0,0])),i=this.layerPointToLatLng(this.containerPointToLayerPoint([t.x,0])),o=this.layerPointToLatLng(this.containerPointToLayerPoint([t.x,t.y])),n=this.layerPointToLatLng(this.containerPointToLayerPoint([0,t.y]));return new L.LatLngBounds([e,i,o,n])},layerPointToContainerPoint:function(t){return this._rotate?L.point(t).add(this._getRotatePanePos()).rotateFrom(this._bearing,this._getRotatePanePos()).add(this._getMapPanePos()):d.layerPointToContainerPoint.call(this,t)},setBearing:function(t){if(L.Browser.any3d&&this._rotate){var e=this._getRotatePanePos(),i=this.getSize().divideBy(2);this._pivot=this._getMapPanePos().clone().multiplyBy(-1).add(i),e=e.rotateFrom(-this._bearing,this._pivot),this._bearing=t*L.DomUtil.DEG_TO_RAD,this._rotatePanePos=e.rotateFrom(this._bearing,this._pivot),L.DomUtil.setPosition(this._rotatePane,e,this._bearing,this._pivot),this.fire("rotate")}},getBearing:function(){return this._bearing*L.DomUtil.RAD_TO_DEG},_initPanes:function(){var t=this._panes={};this._paneRenderers={},this._mapPane=this.createPane("mapPane",this._container),L.DomUtil.setPosition(this._mapPane,new L.Point(0,0)),this._rotate?(this._rotatePane=this.createPane("rotatePane",this._mapPane),this._norotatePane=this.createPane("norotatePane",this._mapPane),this.createPane("tilePane",this._rotatePane),this.createPane("overlayPane",this._rotatePane),this.createPane("shadowPane",this._norotatePane),this.createPane("markerPane",this._norotatePane),this.createPane("tooltipPane",this._norotatePane),this.createPane("popupPane",this._norotatePane)):(this.createPane("tilePane"),this.createPane("overlayPane"),this.createPane("shadowPane"),this.createPane("markerPane"),this.createPane("tooltipPane"),this.createPane("popupPane")),this.options.markerZoomAnimation||(L.DomUtil.addClass(t.markerPane,"leaflet-zoom-hide"),L.DomUtil.addClass(t.shadowPane,"leaflet-zoom-hide"))},rotatedPointToMapPanePoint:function(t){return L.point(t).rotate(this._bearing)._add(this._getRotatePanePos())},mapPanePointToRotatedPoint:function(t){return L.point(t)._subtract(this._getRotatePanePos()).rotate(-this._bearing)},_getCenterOffset:function(t){var e=d._getCenterOffset.call(this,t);return this._rotate&&(e=e.rotate(this._bearing)),e},_getRotatePanePos:function(){return this._rotatePanePos||new L.Point(0,0)},_getNewPixelOrigin:function(t,e){var i=this.getSize()._divideBy(2);return this._rotate||d._getNewPixelOrigin.call(this,t,e),this.project(t,e).rotate(this._bearing)._subtract(i)._add(this._getMapPanePos())._add(this._getRotatePanePos()).rotate(-this._bearing)._round()},_handleGeolocationResponse:function(t){var e=t.coords.latitude,i=t.coords.longitude,o=t.coords.heading,n=new L.LatLng(e,i),a=n.toBounds(t.coords.accuracy),s=this._locateOptions;if(s.setView){var r=this.getBoundsZoom(a);this.setView(n,s.maxZoom?Math.min(r,s.maxZoom):r)}var l={latlng:n,bounds:a,timestamp:t.timestamp,heading:o};for(var h in t.coords)"number"==typeof t.coords[h]&&(l[h]=t.coords[h]);this.fire("locationfound",l)}}),L.Map.CompassBearing=L.Handler.extend({initialize:function(t){window.DeviceOrientationEvent?(this._capable=!0,this._map=t,this._throttled=L.Util.throttle(this._onDeviceOrientation,1e3,this)):this._capable=!1},addHooks:function(){this._capable&&this._map._rotate&&L.DomEvent.on(window,"deviceorientation",this._throttled,this)},removeHooks:function(){this._capable&&this._map._rotate&&L.DomEvent.off(window,"deviceorientation",this._throttled,this)},_onDeviceOrientation:function(t){null!==t.alpha&&this._map.setBearing(t.alpha-window.orientation)}}),L.Map.addInitHook("addHandler","compassBearing",L.Map.CompassBearing),L.Map.mergeOptions({trackContainerMutation:!1}),L.Map.ContainerMutation=L.Handler.extend({addHooks:function(){L.Browser.mutation&&(this._observer||(this._observer=new MutationObserver(L.Util.bind(this._onMutation,this))),this._observer.observe(this._map.getContainer(),{childList:!1,attributes:!0,characterData:!1,subtree:!1,attributeFilter:["style"]}))},removeHooks:function(){L.Browser.mutation&&this._observer.disconnect()},_onMutation:function(){this._map.invalidateSize()}}),L.Map.addInitHook("addHandler","trackContainerMutation",L.Map.ContainerMutation),L.Map.mergeOptions({bounceAtZoomLimits:!0}),L.Map.TouchGestures=L.Handler.extend({initialize:function(t){this._map=t,this.rotate=!!this._map.options.touchRotate,this.zoom=!!this._map.options.touchZoom},addHooks:function(){L.DomEvent.on(this._map._container,"touchstart",this._onTouchStart,this)},removeHooks:function(){L.DomEvent.off(this._map._container,"touchstart",this._onTouchStart,this)},_onTouchStart:function(t){var e=this._map;if(t.touches&&2===t.touches.length&&!e._animatingZoom&&!this._zooming&&!this._rotating){var i=e.mouseEventToContainerPoint(t.touches[0]),o=e.mouseEventToContainerPoint(t.touches[1]),n=i.subtract(o);this._centerPoint=e.getSize()._divideBy(2),this._startLatLng=e.containerPointToLatLng(this._centerPoint),this.zoom?("center"!==e.options.touchZoom&&(this._pinchStartLatLng=e.containerPointToLatLng(i.add(o)._divideBy(2))),this._startDist=i.distanceTo(o),this._startZoom=e.getZoom(),this._zooming=!0):this._zooming=!1,this.rotate?(this._startTheta=Math.atan(n.x/n.y),this._startBearing=e.getBearing(),n.y<0&&(this._startBearing+=180),this._rotating=!0):this._rotating=!1,this._moved=!1,e.stop(),L.DomEvent.on(document,"touchmove",this._onTouchMove,this).on(document,"touchend",this._onTouchEnd,this),L.DomEvent.preventDefault(t)}},_onTouchMove:function(t){if(t.touches&&2===t.touches.length&&(this._zooming||this._rotating)){var e,i=this._map,o=i.mouseEventToContainerPoint(t.touches[0]),n=i.mouseEventToContainerPoint(t.touches[1]),a=o.subtract(n),s=o.distanceTo(n)/this._startDist;if(this._rotating){var r=(Math.atan(a.x/a.y)-this._startTheta)*L.DomUtil.RAD_TO_DEG;a.y<0&&(r+=180),r&&i.setBearing(this._startBearing-r)}if(this._zooming)if(this._zoom=i.getScaleZoom(s,this._startZoom),!i.options.bounceAtZoomLimits&&(this._zoom<i.getMinZoom()&&s<1||this._zoom>i.getMaxZoom()&&s>1)&&(this._zoom=i._limitZoom(this._zoom)),"center"===i.options.touchZoom){if(this._center=this._startLatLng,1===s)return}else{if(e=o._add(n)._divideBy(2)._subtract(this._centerPoint),1===s&&0===e.x&&0===e.y)return;var l=-i.getBearing()*L.DomUtil.DEG_TO_RAD;this._center=i.unproject(i.project(this._pinchStartLatLng).subtract(e.rotate(l)))}this._moved||(i._moveStart(!0),this._moved=!0),L.Util.cancelAnimFrame(this._animRequest);var h=L.bind(i._move,i,this._center,this._zoom,{pinch:!0,round:!1});this._animRequest=L.Util.requestAnimFrame(h,this,!0),L.DomEvent.preventDefault(t)}},_onTouchEnd:function(){this._moved&&this._zooming?(this._zooming=!1,this._rotating=!1,L.Util.cancelAnimFrame(this._animRequest),L.DomEvent.off(document,"touchmove",this._onTouchMove).off(document,"touchend",this._onTouchEnd),this.zoom&&(this._map.options.zoomAnimation?this._map._animateZoom(this._center,this._map._limitZoom(this._zoom),!0,this._map.options.snapZoom):this._map._resetView(this._center,this._map._limitZoom(this._zoom)))):this._zooming=!1}}),L.Map.addInitHook("addHandler","touchGestures",L.Map.TouchGestures),L.Map.mergeOptions({touchRotate:!1}),L.Map.TouchRotate=L.Handler.extend({addHooks:function(){this._map.touchGestures.enable(),this._map.touchGestures.rotate=!0},removeHooks:function(){this._map.touchGestures.rotate=!1}}),L.Map.addInitHook("addHandler","touchRotate",L.Map.TouchRotate),L.Map.mergeOptions({shiftKeyRotate:!0}),L.Map.ShiftKeyRotate=L.Handler.extend({addHooks:function(){L.DomEvent.on(this._map._container,"wheel",this._handleShiftScroll,this),this._map.shiftKeyRotate.rotate=!0},removeHooks:function(){L.DomEvent.off(this._map._container,"wheel",this._handleShiftScroll,this),this._map.shiftKeyRotate.rotate=!1},_handleShiftScroll:function(t){t.shiftKey?(t.preventDefault(),this._map.scrollWheelZoom.disable(),this._map.setBearing(this._map._bearing*L.DomUtil.RAD_TO_DEG+t.deltaY)):this._map.scrollWheelZoom.enable()}}),L.Map.addInitHook("addHandler","shiftKeyRotate",L.Map.ShiftKeyRotate),L.Map.addInitHook((function(){this.scrollWheelZoom.enabled()&&this.shiftKeyRotate.enabled()&&(this.scrollWheelZoom.disable(),this.scrollWheelZoom.enable())})),L.Map.mergeOptions({touchZoom:L.Browser.touch&&!L.Browser.android23,bounceAtZoomLimits:!1}),L.Map.TouchZoom=L.Handler.extend({addHooks:function(){L.DomUtil.addClass(this._map._container,"leaflet-touch-zoom"),this._map.touchGestures.enable(),this._map.touchGestures.zoom=!0},removeHooks:function(){L.DomUtil.removeClass(this._map._container,"leaflet-touch-zoom"),this._map.touchGestures.zoom=!1}}),L.Map.addInitHook("addHandler","touchZoom",L.Map.TouchZoom),L.Control.Rotate=L.Control.extend({options:{position:"topleft",closeOnZeroBearing:!0},onAdd:function(t){this._onDeviceOrientation=L.Util.throttle(this._unthrottledOnDeviceOrientation,100,this);var e=this._container=L.DomUtil.create("div","leaflet-control-rotate leaflet-bar"),i=this._arrow=L.DomUtil.create("span","leaflet-control-rotate-arrow");i.style.backgroundImage="url(\"data:image/svg+xml;charset=utf-8,%3Csvg width='29' height='29' viewBox='0 0 29 29' xmlns='http://www.w3.org/2000/svg' fill='%23333'%3E%3Cpath d='M10.5 14l4-8 4 8h-8z'/%3E%3Cpath d='M10.5 16l4 8 4-8h-8z' fill='%23ccc'/%3E%3C/svg%3E\")",i.style.cursor="grab",i.style.display="block",i.style.width="100%",i.style.height="100%",i.style.backgroundRepeat="no-repeat",i.style.backgroundPosition="50%";var o=this._link=L.DomUtil.create("a","leaflet-control-rotate-toggle",e);return o.appendChild(i),o.href="#",o.title="Rotate map",L.DomEvent.on(o,"dblclick",L.DomEvent.stopPropagation).on(o,"mousedown",this._handleMouseDown,this).on(o,"click",L.DomEvent.stop).on(o,"click",this._cycleState,this).on(o,"click",this._refocusOnMap,this),L.Browser.any3d||L.DomUtil.addClass(o,"leaflet-disabled"),this._restyle(),t.on("rotate",this._restyle.bind(this)),this._follow=!1,this._canFollow=!1,this.options.closeOnZeroBearing&&0===t.getBearing()&&(e.style.display="none"),e},_handleMouseDown:function(t){L.DomEvent.stopPropagation(t),this.dragging=!0,this.dragstartX=t.pageX,this.dragstartY=t.pageY,L.DomEvent.on(document,"mousemove",this._handleMouseDrag,this).on(document,"mouseup",this._handleMouseUp,this)},_handleMouseUp:function(t){L.DomEvent.stopPropagation(t),this.dragging=!1,L.DomEvent.off(document,"mousemove",this._handleMouseDrag,this).off(document,"mouseup",this._handleMouseUp,this)},_handleMouseDrag:function(t){if(this.dragging){var e=t.clientX-this.dragstartX;this._map.setBearing(e)}},_cycleState:function(t){var e=this._map;e&&(e.touchRotate.enabled()||e.compassBearing.enabled()?e.compassBearing.enabled()?(e.compassBearing.disable(),e.setBearing(0),this.options.closeOnZeroBearing&&e.touchRotate.enable()):(e.touchRotate.disable(),e.compassBearing.enable()):e.touchRotate.enable(),this._restyle())},_restyle:function(){if(this._map.options.rotate){var t=this._map,e=t.getBearing();this.options.closeOnZeroBearing&&e&&(this._container.style.display="block");var i="rotate("+e+"deg)";this._arrow.style.transform=i,t.compassBearing.enabled()?this._link.style.backgroundColor="orange":t.touchRotate.enabled()?this._link.style.backgroundColor=null:(this._link.style.backgroundColor="grey",this.options.closeOnZeroBearing&&0===t.getBearing()&&(this._container.style.display="none"))}else L.DomUtil.addClass(this._link,"leaflet-disabled")}}),L.control.rotate=function(t){return new L.Control.Rotate(t)},L.Map.mergeOptions({rotateControl:!0}),L.Map.addInitHook((function(){if(this.options.rotateControl){var t="object"==typeof this.options.rotateControl?this.options.rotateControl:{};this.rotateControl=L.control.rotate(t),this.addControl(this.rotateControl)}})),
/*!
Copyright (c) 2016 Dominik Moritz
This file is part of the leaflet locate control. It is licensed under the MIT license.
You can find the project at: https://github.com/domoritz/leaflet-locatecontrol
*/
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.L.Control.Locate=t(L))}((function(t){var e=function(e,i,o){(o=o.split(" ")).forEach((function(o){t.DomUtil[e].call(this,i,o)}))},i=function(t,i){e("addClass",t,i)},o=function(t,i){e("removeClass",t,i)},n=t.Marker.extend({initialize:function(e,i){t.Util.setOptions(this,i),this._latlng=e,this.createIcon()},createIcon:function(){var e=this.options,i="";void 0!==e.color&&(i+="stroke:"+e.color+";"),void 0!==e.weight&&(i+="stroke-width:"+e.weight+";"),void 0!==e.fillColor&&(i+="fill:"+e.fillColor+";"),void 0!==e.fillOpacity&&(i+="fill-opacity:"+e.fillOpacity+";"),void 0!==e.opacity&&(i+="opacity:"+e.opacity+";");var o=this._getIconSVG(e,i);this._locationIcon=t.divIcon({className:o.className,html:o.svg,iconSize:[o.w,o.h]}),this.setIcon(this._locationIcon)},_getIconSVG:function(t,e){var i=t.radius,o=i+t.weight,n=2*o;return{className:"leaflet-control-locate-location",svg:'<svg xmlns="http://www.w3.org/2000/svg" width="'+n+'" height="'+n+'" version="1.1" viewBox="-'+o+" -"+o+" "+n+" "+n+'"><circle r="'+i+'" style="'+e+'" /></svg>',w:n,h:n}},setStyle:function(e){t.Util.setOptions(this,e),this.createIcon()}}),a=n.extend({initialize:function(e,i,o){t.Util.setOptions(this,o),this._latlng=e,this._heading=i,this.createIcon()},setHeading:function(t){this._heading=t},_getIconSVG:function(t,e){var i=t.radius,o=t.width+t.weight,n=2*(i+t.depth+t.weight),a="M0,0 l"+t.width/2+","+t.depth+" l-"+o+",0 z";return{className:"leaflet-control-locate-heading",svg:'<svg xmlns="http://www.w3.org/2000/svg" width="'+o+'" height="'+n+'" version="1.1" viewBox="-'+o/2+" 0 "+o+" "+n+'" style="'+("transform: rotate("+this._heading+"deg)")+'"><path d="'+a+'" style="'+e+'" /></svg>',w:o,h:n}}}),s=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:n,compassClass:a,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,i){var o=t.DomUtil.create("a","leaflet-bar-part leaflet-bar-part-single",e);return o.title=i.strings.title,{link:o,icon:t.DomUtil.create(i.iconElementTag,i.icon,o)}},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 i in e)"object"==typeof this.options[i]?t.extend(this.options[i],e[i]):this.options[i]=e[i];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 i=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 o=this.options.createButtonCallback(i,this.options);return this._link=o.link,this._icon=o.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),i},_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,i=e.outOfView;switch(this._map.getBounds().contains(this._event.latlng)&&(i=t?e.inView:e.inViewNotFollowing),e[i]&&(i=e[i]),i){case"setView":this.setView();break;case"stop":if(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(){if(!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)){var e="ondeviceorientationabsolute"in window;if(e||"ondeviceorientation"in window){var i=this,o=function(){t.DomEvent.on(window,e?"deviceorientationabsolute":"deviceorientation",i._onDeviceOrientation,i)};DeviceOrientationEvent&&"function"==typeof DeviceOrientationEvent.requestPermission?DeviceOrientationEvent.requestPermission().then((function(t){"granted"===t&&o()})):o()}}},_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,i,o=this._event.accuracy,n=this._event.latlng;if(this.options.drawCircle){var a=this._isFollowing()?this.options.followCircleStyle:this.options.circleStyle;this._circle?this._circle.setLatLng(n).setRadius(o).setStyle(a):this._circle=t.circle(n,o,a).addTo(this._layer)}if(this.options.metric?(e=o.toFixed(0),i=this.options.strings.metersUnit):(e=(3.2808399*o).toFixed(0),i=this.options.strings.feetUnit),this.options.drawMarker){var s=this._isFollowing()?this.options.followMarkerStyle:this.options.markerStyle;this._marker?(this._marker.setLatLng(n),this._marker.setStyle&&this._marker.setStyle(s)):this._marker=new this.options.markerClass(n,s).addTo(this._layer)}this._drawCompass();var r=this.options.strings.popup;function l(){return"string"==typeof r?t.Util.template(r,{distance:e,unit:i}):"function"==typeof r?r({distance:e,unit:i}):r}this.options.showPopup&&r&&this._marker&&this._marker.bindPopup(l())._popup.setLatLng(n),this.options.showPopup&&r&&this._compass&&this._compass.bindPopup(l())._popup.setLatLng(n)},_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?(o(this._container,"active following"),i(this._container,"requesting"),o(this._icon,this.options.icon),i(this._icon,this.options.iconLoading)):"active"==t?(o(this._container,"requesting following"),i(this._container,"active"),o(this._icon,this.options.iconLoading),i(this._icon,this.options.icon)):"following"==t&&(o(this._container,"requesting"),i(this._container,"active following"),o(this._icon,this.options.iconLoading),i(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"),o(this._icon,this.options.iconLoading),i(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)},s}),window),function(){L.Control.FullScreen=L.Control.extend({options:{position:"topleft",title:"Full Screen",titleCancel:"Exit Full Screen",forceSeparateButton:!1,forcePseudoFullscreen:!1,fullscreenElement:!1},onAdd:function(t){var e,i="leaflet-control-zoom-fullscreen",o="";return e=t.zoomControl&&!this.options.forceSeparateButton?t.zoomControl._container:L.DomUtil.create("div","leaflet-bar"),this.options.content?o=this.options.content:i+=" fullscreen-icon",this._createButton(this.options.title,i,o,e,this.toggleFullScreen,this),this._map.fullscreenControl=this,this._map.on("enterFullscreen exitFullscreen",this._toggleTitle,this),e},onRemove:function(e){L.DomEvent.off(this.link,"click",L.DomEvent.stopPropagation).off(this.link,"click",L.DomEvent.preventDefault).off(this.link,"click",this.toggleFullScreen,this),L.DomEvent.off(this._container,t.fullScreenEventName,L.DomEvent.stopPropagation).off(this._container,t.fullScreenEventName,L.DomEvent.preventDefault).off(this._container,t.fullScreenEventName,this._handleFullscreenChange,this),L.DomEvent.off(document,t.fullScreenEventName,L.DomEvent.stopPropagation).off(document,t.fullScreenEventName,L.DomEvent.preventDefault).off(document,t.fullScreenEventName,this._handleFullscreenChange,this)},_createButton:function(e,i,o,n,a,s){return this.link=L.DomUtil.create("a",i,n),this.link.href="#",this.link.title=e,this.link.innerHTML=o,this.link.setAttribute("role","button"),this.link.setAttribute("aria-label",e),L.DomEvent.on(this.link,"click",L.DomEvent.stopPropagation).on(this.link,"click",L.DomEvent.preventDefault).on(this.link,"click",a,s),L.DomEvent.on(n,t.fullScreenEventName,L.DomEvent.stopPropagation).on(n,t.fullScreenEventName,L.DomEvent.preventDefault).on(n,t.fullScreenEventName,this._handleFullscreenChange,s),L.DomEvent.on(document,t.fullScreenEventName,L.DomEvent.stopPropagation).on(document,t.fullScreenEventName,L.DomEvent.preventDefault).on(document,t.fullScreenEventName,this._handleFullscreenChange,s),this.link},toggleFullScreen:function(){var e=this._map;e._exitFired=!1,e._isFullscreen?(t.supportsFullScreen&&!this.options.forcePseudoFullscreen?t.cancelFullScreen():L.DomUtil.removeClass(this.options.fullscreenElement?this.options.fullscreenElement:e._container,"leaflet-pseudo-fullscreen"),e.fire("exitFullscreen"),e._exitFired=!0,e._isFullscreen=!1):(t.supportsFullScreen&&!this.options.forcePseudoFullscreen?t.requestFullScreen(this.options.fullscreenElement?this.options.fullscreenElement:e._container):L.DomUtil.addClass(this.options.fullscreenElement?this.options.fullscreenElement:e._container,"leaflet-pseudo-fullscreen"),e.fire("enterFullscreen"),e._isFullscreen=!0)},_toggleTitle:function(){this.link.title=this._map._isFullscreen?this.options.title:this.options.titleCancel},_handleFullscreenChange:function(){var e=this._map;e.invalidateSize(),t.isFullScreen()||e._exitFired||(e.fire("exitFullscreen"),e._exitFired=!0,e._isFullscreen=!1)}}),L.Map.include({toggleFullscreen:function(){this.fullscreenControl.toggleFullScreen()}}),L.Map.addInitHook((function(){this.options.fullscreenControl&&this.addControl(L.control.fullscreen(this.options.fullscreenControlOptions))})),L.control.fullscreen=function(t){return new L.Control.FullScreen(t)};var t={supportsFullScreen:!1,isFullScreen:function(){return!1},requestFullScreen:function(){},cancelFullScreen:function(){},fullScreenEventName:"",prefix:""},e="webkit moz o ms khtml".split(" ");if(void 0!==document.exitFullscreen)t.supportsFullScreen=!0;else{for(var i=0,o=e.length;i<o;i++)if(t.prefix=e[i],void 0!==document[t.prefix+"CancelFullScreen"]){t.supportsFullScreen=!0;break}void 0!==document.msExitFullscreen&&(t.prefix="ms",t.supportsFullScreen=!0)}t.supportsFullScreen&&("ms"===t.prefix?t.fullScreenEventName="MSFullscreenChange":t.fullScreenEventName=t.prefix+"fullscreenchange",t.isFullScreen=function(){switch(this.prefix){case"":return document.fullscreen;case"webkit":return document.webkitIsFullScreen;case"ms":return document.msFullscreenElement;default:return document[this.prefix+"FullScreen"]}},t.requestFullScreen=function(t){switch(this.prefix){case"":return t.requestFullscreen();case"ms":return t.msRequestFullscreen();default:return t[this.prefix+"RequestFullScreen"]()}},t.cancelFullScreen=function(){switch(this.prefix){case"":return document.exitFullscreen();case"ms":return document.msExitFullscreen();default:return document[this.prefix+"CancelFullScreen"]()}}),"undefined"!=typeof jQuery&&(jQuery.fn.requestFullScreen=function(){return this.each((function(){var e=jQuery(this);t.supportsFullScreen&&t.requestFullScreen(e)}))}),window.fullScreenApi=t}(),
/**
* leaflet-pegman
*
* @author Raruto
* @license GPL-3.0+
* @link https://github.com/Raruto/leaflet-pegman
* @desc Leaflet plugin that allows an easy integration with the Google StreetView Service API
*/
L.Control.Pegman=L.Control.extend({includes:L.Evented?L.Evented.prototype:L.Mixin.Events,options:{position:"bottomright",theme:"leaflet-pegman-v3-default",debug:!1,apiKey:"",libraries:"",mutant:{attribution:'Map data: © <a href="https://www.google.com/intl/en/help/terms_maps.html">Google</a>',pane:"overlayPane",type:null},pano:{enableCloseButton:!0}},__interactURL:"https://unpkg.com/interactjs@1.2.9/dist/interact.min.js",__gmapsURL:"https://maps.googleapis.com/maps/api/js?v=3",__mutantURL:"https://unpkg.com/leaflet.gridlayer.googlemutant@0.8.0/Leaflet.GoogleMutant.js",initialize:function(t){void 0!==t.logging&&(t.debug=t.logging),L.Util.setOptions(this,t),this._mousePos={direction:{},old:{}},this._pegmanMarkerCoords=null,this._streetViewCoords=null,this._streetViewLayerEnabled=!1,this._dropzoneMapOpts={accept:".draggable",overlap:.75,ondropactivate:L.bind(this.onDropZoneActivated,this),ondragenter:L.bind(this.onDropZoneDragEntered,this),ondragleave:L.bind(this.onDropZoneDragLeaved,this),ondrop:L.bind(this.onDropZoneDropped,this),ondropdeactivate:L.bind(this.onDropZoneDeactivated,this)},this._draggableMarkerOpts={inertia:!1,onmove:L.bind(this.onDraggableMove,this),onend:L.bind(this.onDraggableEnd,this)},this._pegmanMarkerOpts={draggable:!0,icon:L.icon({className:"pegman-marker",iconSize:[52,52],iconAnchor:[26,13],iconUrl:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAFElEQVR4XgXAAQ0AAABAMP1L30IDCPwC/o5WcS4AAAAASUVORK5CYII="})},this._lazyLoaderAdded=!1},onAdd:function(t){return this._map=t,this._container=L.DomUtil.create("div","leaflet-pegman pegman-control leaflet-bar"),this._pegman=L.DomUtil.create("div","pegman draggable drag-drop",this._container),this._pegmanButton=L.DomUtil.create("div","pegman-button",this._container),this._pegmanMarker=L.marker([0,0],this._pegmanMarkerOpts),this._panoDiv=this.options.panoDiv?document.querySelector(this.options.panoDiv):L.DomUtil.create("div","",this._map._container),L.DomUtil.addClass(this._panoDiv,"pano-canvas"),L.DomUtil.addClass(this._map._container,this.options.theme),L.DomEvent.disableClickPropagation(this._panoDiv),L.DomEvent.on(this._container,"click mousedown dblclick",this._disableClickPropagation,this),this._container.addEventListener("touchstart",this._loadScripts.bind(this,!L.Browser.touch),{once:!0}),this._container.addEventListener("mousedown",this._loadScripts.bind(this,!0),{once:!0}),this._container.addEventListener("mouseover",this._loadScripts.bind(this,!1),{once:!0}),this._loadInteractHandlers(),this._loadGoogleHandlers(),L.DomEvent.on(document,"mousemove",this.mouseMoveTracking,this),L.DomEvent.on(document,"keyup",this.keyUpTracking,this),this._pegmanMarker.on("dragend",this.onPegmanMarkerDragged,this),this._map.on("click",this.onMapClick,this),this._map.on("layeradd",this.onMapLayerAdd,this),this._container},onRemove:function(t){this._googleStreetViewLayer&&this._googleStreetViewLayer.remove(),this._pegmanMarker&&this._pegmanMarker.remove(),L.DomUtil.remove(this._panoDiv),L.DomEvent.off(document,"mousemove",this.mouseMoveTracking,this),L.DomEvent.off(document,"keyup",this.keyUpTracking,this),t.off("mousemove",this._setMouseCursor,this)},_log:function(t){this.options.debug&&console.log(t)},_addClasses:function(t,e){for(var i in e=e.split(" "))L.DomUtil.addClass(t,e[i])},_removeClasses:function(t,e){for(var i in e=e.split(" "))L.DomUtil.removeClass(t,e[i])},_removeAttributes:function(t,e){for(var i in e)t.removeAttribute(e[i])},_insertAfter:function(t,e){t.parentNode.insertBefore(e,t.nextSibling)},_translateElement:function(t,e,i){!1===e&&!1===i&&this._removeAttributes(this._pegman,["style","data-x","data-y"]);var o=(parseFloat(t.getAttribute("data-x"))||0)+e,n=(parseFloat(t.getAttribute("data-y"))||0)+i;t.style.webkitTransform=t.style.transform="translate("+o+"px, "+n+"px)",t.setAttribute("data-x",o),t.setAttribute("data-y",n)},_updateClasses:function(t){switch(t){case"pegman-dragging":this._removeClasses(this._pegman,"dropped"),this._addClasses(this._container,"dragging");break;case"pegman-dragged":this._removeClasses(this._pegman,"can-drop dragged left right active dropped"),this._removeAttributes(this._pegman,["style","data-x","data-y"]);break;case"dropzone-actived":this._addClasses(this._map._container,"drop-active");break;case"dropzone-drag-entered":this._addClasses(this._pegman,"active can-drop"),this._addClasses(this._map._container,"drop-target");break;case"dropzone-drag-leaved":this._removeClasses(this._map._container,"drop-target"),this._removeClasses(this._pegman,"can-drop");break;case"dropzone-drop":this._removeClasses(this._container,"dragging"),this._removeClasses(this._pegman,"active left right"),this._addClasses(this._pegman,"dropped"),this._removeClasses(this._pegman,"can-drop dragged left right active dropped");break;case"dropzone-deactivated":this._removeClasses(this._pegman,"active left right"),this._removeClasses(this._map._container,"drop-active drop-target");break;case"mousemove-top":this._addClasses(this._pegman,"top"),this._removeClasses(this._pegman,"bottom right left");break;case"mousemove-bottom":this._addClasses(this._pegman,"bottom"),this._removeClasses(this._pegman,"top right left");break;case"mousemove-left":this._addClasses(this._pegman,"left"),this._removeClasses(this._pegman,"right top bottom");break;case"mousemove-right":this._addClasses(this._pegman,"right"),this._removeClasses(this._pegman,"left top bottom");break;case"pegman-added":this._addClasses(this._container,"active");break;case"pegman-removed":this._removeClasses(this._container,"active");break;case"streetview-shown":this._addClasses(this._container,"streetview-layer-active");break;case"streetview-hidden":this._removeClasses(this._container,"streetview-layer-active");break;default:throw"Unhandled event:"+t}this.fire("svpc_"+t)},onDraggableMove:function(t){this.mouseMoveTracking(t),this.pegmanRemove(),this._updateClasses("pegman-dragging"),this._translateElement(this._pegman,t.dx,t.dy)},onDraggableEnd:function(t){this._pegmanMarkerCoords=this._map.mouseEventToLatLng(t),this.pegmanAdd(),this._updateClasses("pegman-dragged")},onDropZoneActivated:function(t){this._updateClasses("dropzone-actived")},onDropZoneDragEntered:function(t){this.showStreetViewLayer(),this._updateClasses("dropzone-drag-entered")},onDropZoneDragLeaved:function(t){this._updateClasses("dropzone-drag-leaved")},onDropZoneDropped:function(t){this._updateClasses("dropzone-drop"),this._translateElement(this._pegman,!1,!1)},onDropZoneDeactivated:function(t){this._updateClasses("dropzone-deactivated")},onPegmanMarkerDragged:function(t){this._pegmanMarkerCoords=this._pegmanMarker.getLatLng(),this.findStreetViewData(this._pegmanMarkerCoords.lat,this._pegmanMarkerCoords.lng)},onMapClick:function(t){this._streetViewLayerEnabled&&this.findStreetViewData(t.latlng.lat,t.latlng.lng)},onMapLayerAdd:function(t){this._googleStreetViewLayer&&this._googleStreetViewLayer.bringToFront()},onStreetViewPanoramaClose:function(){this.clear()},clear:function(){this.pegmanRemove(),this.hideStreetViewLayer(),this.closeStreetViewPanorama()},toggleStreetViewLayer:function(t){this._streetViewLayerEnabled?this.clear():this.showStreetViewLayer(),this._log("streetview-layer-toggled")},pegmanAdd:function(){this._pegmanMarker.addTo(this._map),this._pegmanMarker.setLatLng(this._pegmanMarkerCoords),this.findStreetViewData(this._pegmanMarkerCoords.lat,this._pegmanMarkerCoords.lng),this._updateClasses("pegman-added")},pegmanRemove:function(){this._pegmanMarker.removeFrom(this._map),this._updateClasses("pegman-removed")},closeStreetViewPanorama:function(){this._panoDiv.style.display="none"},openStreetViewPanorama:function(){this._panoDiv.style.display="block"},hideStreetViewLayer:function(){this._googleStreetViewLayer&&(this._googleStreetViewLayer.removeFrom(this._map),this._streetViewLayerEnabled=!1,this._updateClasses("streetview-hidden"))},showStreetViewLayer:function(){this._googleStreetViewLayer&&(this._googleStreetViewLayer.addTo(this._map),this._streetViewLayerEnabled=!0,this._updateClasses("streetview-shown"))},findStreetViewData:function(t,e){this._streetViewCoords=new google.maps.LatLng(t,e);var i=this._map.getZoom(),o=100;o=i<6?5e3:i<10?500:i<15?250:i>=17?50:100,this._streetViewService.getPanoramaByLocation(this._streetViewCoords,o,L.bind(this.processStreetViewServiceData,this))},processStreetViewServiceData:function(t,e){e==google.maps.StreetViewStatus.OK?(this.openStreetViewPanorama(),this._panorama.setPano(t.location.pano),this._panorama.setPov({heading:google.maps.geometry.spherical.computeHeading(t.location.latLng,this._streetViewCoords),pitch:0,zoom:0}),this._panorama.setVisible(!0)):console.warn("Street View data not found for this location.")},mouseMoveTracking:function(t){var e=this._mousePos;t.pageY<e.old.y?(e.direction.y="top",this._updateClasses("mousemove-top")):t.pageY>e.old.y&&(e.direction.y="bottom",this._updateClasses("mousemove-bottom")),t.pageX<e.old.x?(e.direction.x="left",this._updateClasses("mousemove-left")):t.pageX>e.old.x&&(e.direction.x="right",this._updateClasses("mousemove-right")),e.old.x=t.pageX,e.old.y=t.pageY},keyUpTracking:function(t){27==t.keyCode&&(this._log("escape pressed"),this.clear())},_disableClickPropagation:function(t){L.DomEvent.stopPropagation(t),L.DomEvent.preventDefault(t)},_loadGoogleHandlers:function(t){"object"==typeof google&&"object"==typeof google.maps&&"function"==typeof L.GridLayer.GoogleMutant&&(this._initGoogleMaps(t),this._initMouseTracker())},_initGoogleMaps:function(t){this._googleStreetViewLayer=L.gridLayer.googleMutant(this.options.mutant),this._googleStreetViewLayer.addGoogleLayer("StreetViewCoverageLayer"),this._panorama=new google.maps.StreetViewPanorama(this._panoDiv,this.options.pano),this._streetViewService=new google.maps.StreetViewService,google.maps.event.addListener(this._panorama,"closeclick",L.bind(this.onStreetViewPanoramaClose,this)),t&&this.showStreetViewLayer()},_initMouseTracker:function(){if(this._googleStreetViewLayer){var t=this._googleStreetViewLayer.getTileSize();this.tileWidth=t.x,this.tileHeight=t.y,this.defaultDraggableCursor=this._map._container.style.cursor,this._map.on("mousemove",this._setMouseCursor,this)}},_setMouseCursor:function(t){var e=this._getTileCoords(t.latlng.lat,t.latlng.lng,this._map.getZoom()),i=this._getTileImage(e),o=this._getTilePixelPoint(i,t.originalEvent),n=this._hasTileData(i,o);this._map._container.style.cursor=n?"pointer":this.defaultDraggableCursor},_getTileCoords:function(t,e,i){return{x:parseInt(Math.floor((e+180)/360*(1<<i))),y:parseInt(Math.floor((1-Math.log(Math.tan(this._toRad(t))+1/Math.cos(this._toRad(t)))/Math.PI)/2*(1<<i))),z:i}},_getTileImage:function(t){if(this._googleStreetViewLayer&&this._googleStreetViewLayer._tiles){var e=this._googleStreetViewLayer._tileCoordsToKey(t),i=this._googleStreetViewLayer._tiles[e];if(i){var o=i.el.querySelector("img");if(o)return this._downloadTile(o.src,this._tileLoaded),o}}},_getTilePixelPoint:function(t,e){if(t){var i=t.getBoundingClientRect(),o=(i.top+window.scrollY).toFixed(0),n=(i.left+window.scrollX).toFixed(0);return{x:e.pageX-n,y:e.pageY-o}}},_hasTileData:function(t,e){if(this.tileContext&&e)return 0!=this.tileContext.getImageData(e.x,e.y,1,1).data[3]},_toRad:function(t){return t*Math.PI/180},_downloadTile:function(t,e){if(t){var i=new Image;i.crossOrigin="Anonymous",i.addEventListener("load",e.bind(this,i),!1),i.src=t}},_tileLoaded:function(t){this.tileCanvas=document.createElement("canvas"),this.tileContext=this.tileCanvas.getContext("2d"),this.tileCanvas.width=this.tileWidth,this.tileCanvas.height=this.tileHeight,this.tileContext.drawImage(t,0,0)},_loadInteractHandlers:function(){"function"==typeof interact&&(this._draggable=interact(this._pegman).draggable(this._draggableMarkerOpts),this._dropzone=interact(this._map._container).dropzone(this._dropzoneMapOpts),this._draggable.styleCursor(!1),interact(this._container).on("tap",L.bind(this.toggleStreetViewLayer,this)),L.DomEvent.on(this._container,"touchstart",(function(t){this._map.dragging.disable()}),this),L.DomEvent.on(this._container,"touchend",(function(t){this._map.dragging.enable()}),this))},_loadScripts:function(t){this._lazyLoaderAdded||(this._lazyLoaderAdded=!0,this._loadJS(this.__interactURL,this._loadInteractHandlers.bind(this),"function"!=typeof interact),this._loadJS(this.__gmapsURL+"&key="+this.options.apiKey+"&libraries="+this.options.libraries+"&callback=?",this._loadGoogleHandlers.bind(this,t),"object"!=typeof google||"object"!=typeof google.maps),this._loadJS(this.__mutantURL,this._loadGoogleHandlers.bind(this,t),"function"!=typeof L.GridLayer.GoogleMutant))},_loadJS:function(t,e,i){if(i)if(-1!==t.indexOf("callback=?"))this._jsonp(t,e);else{var