leaflet-ui
Version:
Leaflet presets for common user interface customizations
29 lines (28 loc) • 137 kB
JavaScript
!function(t){"function"==typeof define&&define.amd?define(t):t()}((function(){"use strict";!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){return t.locales={},t.locale=null,t.registerLocale=function(e,i){t.locales[e]=t.Util.extend({},t.locales[e],i)},t.setLocale=function(e){t.locale=e},t.i18n=t._=function(e,i){t.locale&&t.locales[t.locale]&&t.locales[t.locale][e]&&(e=t.locales[t.locale][e]);try{e=t.Util.template(e,i)}catch(t){}return e}}),window);const t=L.extend({},L.DomUtil);L.extend(L.DomUtil,{setTransform:function(e,i,o,n,s){var a=i||new L.Point(0,0);if(!n)return i=a._round(),t.setTransform.call(this,e,i,o);a=a.rotateFrom(n,s),e.style[L.DomUtil.TRANSFORM]="translate3d("+a.x+"px,"+a.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,s=e.y,a=this.x-n,r=this.y-s;return new L.Point(a*o-r*i+n,a*i+r*o+s)}});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 i=L.extend({},L.Popup.prototype);L.Popup.include({_animateZoom:function(t){this._map._rotate||i._animateZoom.call(this,t);var e=this._map._latLngToNewLayerPoint(this._latlng,t.zoom,t.center),o=this._getAnchor();e=this._map.rotatedPointToMapPanePoint(e),L.DomUtil.setPosition(this._container,e.add(o))},_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 s=n._add(this._map._getMapPanePos()),a=L.point(this.options.autoPanPadding),r=L.point(this.options.autoPanPaddingTopLeft||a),l=L.point(this.options.autoPanPaddingBottomRight||a),h=t.getSize(),c=0,p=0;s.x+o+l.x>h.x&&(c=s.x+o-h.x+l.x),s.x-c-r.x<0&&(c=s.x-r.x),s.y+i+l.y>h.y&&(p=s.y+i-h.y+l.y),s.y-p-r.y<0&&(p=s.y-r.y),(c||p)&&t.fire("autopanstart").panBy([c,p])}}});const o=L.extend({},L.Tooltip.prototype);L.Tooltip.include({_updatePosition:function(){if(!this._map._rotate)return o._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 o._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 n;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),s=L.point("shadow"===e&&i.shadowAnchor||i.iconAnchor||n&&n.divideBy(2,!0));t.className="leaflet-marker-"+e+" "+(i.className||""),s&&(t.style.marginLeft=-s.x+"px",t.style.marginTop=-s.y+"px",t.style[L.DomUtil.TRANSFORM+"Origin"]=s.x+"px "+s.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 n._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 s=e._map.layerPointToLatLng(n);e._latlng=s,t.latlng=s,t.oldLatLng=this._oldLatLng,i?e.setLatLng(s):e.fire("move",t),e.fire("drag",t)},_onDragEnd:function(t){this._marker._map._rotate&&this._marker.update(),n._onDragEnd.call(this,t)}};const a=L.extend({},L.Marker.prototype);L.Marker.mergeOptions({rotation:0,rotateWithView:!1}),L.Marker.include({getEvents:function(){return L.extend(a.getEvents.call(this),{rotate:this.update})},onAdd:function(t){a.onAdd.call(this,t),t.on("rotate",this.update,this)},_initInteraction:function(){var t=a._initInteraction.call(this);return this.dragging&&this.dragging.enabled()&&this._map&&this._map._rotate&&(n=n||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 a._updateZIndex.call(this,t);this._icon.style.zIndex=Math.round(this._zIndex+t)},setRotation:function(t){this.options.rotation=t,this.update()}});const r=L.extend({},L.GridLayer.prototype);L.GridLayer.include({getEvents:function(){var t=r.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 r._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(),s=e.getSize(),a=new L.Bounds([e.containerPointToLayerPoint([0,0]).floor(),e.containerPointToLayerPoint([s.x,0]).floor(),e.containerPointToLayerPoint([0,s.y]).floor(),e.containerPointToLayerPoint([s.x,s.y]).floor()]).getSize().divideBy(2*o);return new L.Bounds(n.subtract(a),n.add(a))}});const l=L.extend({},L.Canvas.prototype);L.Canvas.include({onAdd:function(){l.onAdd.call(this),this._map.on("rotate",this._redraw,this)},onRemove:function(){l.onRemove.call(this),this._map.off("rotate",this._redraw,this)},_update:function(){l._update.call(this),this.fire("update")}});const h=L.extend({},L.Renderer.prototype);L.Renderer.include({onAdd:function(){h.onAdd.call(this)},onRemove:function(){h.onRemove.call(this)},_updateTransform:function(t,e){if(!this._map._rotate)return h._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 h._update.call(this);var t=this.options.padding,e=this._map,i=this._map.getSize(),o=i.multiplyBy(-t),n=i.multiplyBy(1+t),s=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=s,this._topLeft=this._map.layerPointToLatLng(s.min),this._center=this._map.getCenter(),this._zoom=this._map.getZoom()}});const c=L.extend({},L.SVG.prototype);L.SVG.include({_update:function(){c._update.call(this),this._map._rotate&&this.fire("update")}});const p=L.extend({},L.Map.prototype);
/*!
* Based on package 'screenfull'
* v5.2.0 - 2021-11-03
* (c) Sindre Sorhus; MIT License
* Added definition for using screenfull as an amd module
* Must be placed before the definition of leaflet.fullscreen
* as it is required by that
*/var d,u;L.Map.mergeOptions({rotate:!1,bearing:0}),L.Map.include({initialize:function(t,e){e.rotate&&(this._rotate=!0,this._bearing=0),p.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()):p.containerPointToLayerPoint.call(this,t)},getBounds:function(){if(!this._rotate)return p.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()):p.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=p._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||p._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),s=n.toBounds(t.coords.accuracy),a=this._locateOptions;if(a.setView){var r=this.getBoundsZoom(s);this.setView(n,a.maxZoom?Math.min(r,a.maxZoom):r)}var l={latlng:n,bounds:s,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]),s=o.subtract(n),a=o.distanceTo(n)/this._startDist;if(this._rotating){var r=(Math.atan(s.x/s.y)-this._startTheta)*L.DomUtil.RAD_TO_DEG;s.y<0&&(r+=180),r&&i.setBearing(this._startBearing-r)}if(this._zooming)if(this._zoom=i.getScaleZoom(a,this._startZoom),!i.options.bounceAtZoomLimits&&(this._zoom<i.getMinZoom()&&a<1||this._zoom>i.getMaxZoom()&&a>1)&&(this._zoom=i._limitZoom(this._zoom)),"center"===i.options.touchZoom){if(this._center=this._startLatLng,1===a)return}else{if(e=o._add(n)._divideBy(2)._subtract(this._centerPoint),1===a&&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+5*Math.sign(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){const e=(e,i,o)=>{(o=o.split(" ")).forEach((function(o){t.DomUtil[e].call(this,i,o)}))},i=(t,i)=>e("addClass",t,i),o=(t,i)=>e("removeClass",t,i),n=t.Marker.extend({initialize(e,i){t.Util.setOptions(this,i),this._latlng=e,this.createIcon()},createIcon(){const e=this.options;let 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};`);const 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(t,e){const 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(e){t.Util.setOptions(this,e),this.createIcon()}}),s=n.extend({initialize(e,i,o){t.Util.setOptions(this,o),this._latlng=e,this._heading=i,this.createIcon()},setHeading(t){this._heading=t},_getIconSVG(t,e){const i=t.radius,o=t.width+t.weight,n=2*(i+t.depth+t.weight),s=`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="`+s+'" style="'+e+'" /></svg>',w:o,h:n}}}),a=t.Control.extend({options:{position:"topleft",layer:void 0,setView:"untilPanOrZoom",keepCurrentZoomLevel:!1,initialZoomLevel:!1,getLocationBounds:t=>t.bounds,flyTo:!1,clickBehavior:{inView:"stop",outOfView:"setView",inViewNotFollowing:"inView"},returnToPrevBounds:!1,cacheLocation:!0,drawCircle:!0,drawMarker:!0,showCompass:!0,markerClass:n,compassClass:s,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:"leaflet-control-locate-location-arrow",iconLoading:"leaflet-control-locate-spinner",iconElementTag:"span",textElementTag:"small",circlePadding:[0,0],metric:!0,createButtonCallback(e,i){const o=t.DomUtil.create("a","leaflet-bar-part leaflet-bar-part-single",e);o.title=i.strings.title,o.href="#",o.setAttribute("role","button");const n=t.DomUtil.create(i.iconElementTag,i.icon,o);if(void 0!==i.strings.text){t.DomUtil.create(i.textElementTag,"leaflet-locate-text",o).textContent=i.strings.text,o.classList.add("leaflet-locate-text-active"),o.parentNode.style.display="flex",i.icon.length>0&&n.classList.add("leaflet-locate-icon")}return{link:o,icon:n}},onLocationError(t,e){alert(t.message)},onLocationOutsideMapBounds(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(e){for(const 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(e){const i=t.DomUtil.create("div","leaflet-control-locate leaflet-bar leaflet-control");this._container=i,this._map=e,this._layer=this.options.layer||new t.LayerGroup,this._layer.addTo(e),this._event=void 0,this._compassHeading=null,this._prevBounds=null;const o=this.options.createButtonCallback(i,this.options);return this._link=o.link,this._icon=o.icon,t.DomEvent.on(this._link,"click",(function(e){t.DomEvent.stopPropagation(e),t.DomEvent.preventDefault(e),this._onClick()}),this).on(this._link,"dblclick",t.DomEvent.stopPropagation),this._resetVariables(),this._map.on("unload",this._unload,this),i},_onClick(){this._justClicked=!0;const t=this._isFollowing();if(this._userPanned=!1,this._userZoomed=!1,this._active&&!this._event)this.stop();else if(this._active){const e=this.options.clickBehavior;let 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(){this._activate(),this._event&&(this._drawMarker(this._map),this.options.setView&&this.setView()),this._updateContainerStyle()},stop(){this._deactivate(),this._cleanClasses(),this._resetVariables(),this._removeMarker()},stopFollowing(){this._userPanned=!0,this._updateContainerStyle(),this._drawMarker()},_activate(){if(!this._active&&(this._map.locate(this.options.locateOptions),this._map.fire("locateactivate",this),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)){const e="ondeviceorientationabsolute"in window;if(e||"ondeviceorientation"in window){const 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(){this._map.stopLocate(),this._map.fire("locatedeactivate",this),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(){if(this._drawMarker(),this._isOutsideMapBounds())this._event=void 0,this.options.onLocationOutsideMapBounds(this);else if(this._justClicked&&!1!==this.options.initialZoomLevel)(e=this.options.flyTo?this._map.flyTo:this._map.setView).bind(this._map)([this._event.latitude,this._event.longitude],this.options.initialZoomLevel);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.initialZoomLevel||this.options.locateOptions.maxZoom}),t.Util.requestAnimFrame((function(){this._ignoreEvent=!1}),this)}},_drawCompass(){if(!this._event)return;const t=this._event.latlng;if(this.options.showCompass&&t&&null!==this._compassHeading){const 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(){void 0===this._event.accuracy&&(this._event.accuracy=0);const e=this._event.accuracy,i=this._event.latlng;if(this.options.drawCircle){const o=this._isFollowing()?this.options.followCircleStyle:this.options.circleStyle;this._circle?this._circle.setLatLng(i).setRadius(e).setStyle(o):this._circle=t.circle(i,e,o).addTo(this._layer)}let o,n;if(this.options.metric?(o=e.toFixed(0),n=this.options.strings.metersUnit):(o=(3.2808399*e).toFixed(0),n=this.options.strings.feetUnit),this.options.drawMarker){const t=this._isFollowing()?this.options.followMarkerStyle:this.options.markerStyle;this._marker?(this._marker.setLatLng(i),this._marker.setStyle&&this._marker.setStyle(t)):this._marker=new this.options.markerClass(i,t).addTo(this._layer)}this._drawCompass();const s=this.options.strings.popup;function a(){return"string"==typeof s?t.Util.template(s,{distance:o,unit:n}):"function"==typeof s?s({distance:o,unit:n}):s}this.options.showPopup&&s&&this._marker&&this._marker.bindPopup(a())._popup.setLatLng(i),this.options.showPopup&&s&&this._compass&&this._compass.bindPopup(a())._popup.setLatLng(i)},_removeMarker(){this._layer.clearLayers(),this._marker=void 0,this._circle=void 0},_unload(){this.stop(),this._map.off("unload",this._unload,this)},_setCompassHeading(e){!isNaN(parseFloat(e))&&isFinite(e)?(e=Math.round(e),this._compassHeading=e,t.Util.requestAnimFrame(this._drawCompass,this)):this._compassHeading=null},_onCompassNeedsCalibration(){this._setCompassHeading()},_onDeviceOrientation(t){this._active&&(t.webkitCompassHeading?this._setCompassHeading(t.webkitCompassHeading):t.absolute&&t.alpha&&this._setCompassHeading(360-t.alpha))},_onLocationError(t){3==t.code&&this.options.locateOptions.watch||(this.stop(),this.options.onLocationError(t,this))},_onLocationFound(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(){this._event&&!this._ignoreEvent&&(this._userPanned=!0,this._updateContainerStyle(),this._drawMarker())},_onZoom(){this._event&&!this._ignoreEvent&&(this._userZoomed=!0,this._updateContainerStyle(),this._drawMarker())},_onZoomEnd(){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(){return!!this._active&&("always"===this.options.setView||("untilPan"===this.options.setView?!this._userPanned:"untilPanOrZoom"===this.options.setView?!this._userPanned&&!this._userZoomed:void 0))},_isOutsideMapBounds(){return void 0!==this._event&&(this._map.options.maxBounds&&!this._map.options.maxBounds.contains(this._event.latlng))},_updateContainerStyle(){this._container&&(this._active&&!this._event?this._setClasses("requesting"):this._isFollowing()?this._setClasses("following"):this._active?this._setClasses("active"):this._cleanClasses())},_setClasses(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(){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(){this._active=!1,this._justClicked=!1,this._userPanned=!1,this._userZoomed=!1}});return t.control.locate=e=>new t.Control.Locate(e),a}),window),d="undefined"!=typeof self?self:window,u=function(){var t="undefined"!=typeof window&&void 0!==window.document?window.document:{},e=function(){for(var e,i=[["requestFullscreen","exitFullscreen","fullscreenElement","fullscreenEnabled","fullscreenchange","fullscreenerror"],["webkitRequestFullscreen","webkitExitFullscreen","webkitFullscreenElement","webkitFullscreenEnabled","webkitfullscreenchange","webkitfullscreenerror"],["webkitRequestFullScreen","webkitCancelFullScreen","webkitCurrentFullScreenElement","webkitCancelFullScreen","webkitfullscreenchange","webkitfullscreenerror"],["mozRequestFullScreen","mozCancelFullScreen","mozFullScreenElement","mozFullScreenEnabled","mozfullscreenchange","mozfullscreenerror"],["msRequestFullscreen","msExitFullscreen","msFullscreenElement","msFullscreenEnabled","MSFullscreenChange","MSFullscreenError"]],o=0,n=i.length,s={};o<n;o++)if((e=i[o])&&e[1]in t){for(o=0;o<e.length;o++)s[i[0][o]]=e[o];return s}return!1}(),i={change:e.fullscreenchange,error:e.fullscreenerror},o={request:function(i,o){return new Promise(function(n,s){var a=function(){this.off("change",a),n()}.bind(this);this.on("change",a);var r=(i=i||t.documentElement)[e.requestFullscreen](o);r instanceof Promise&&r.then(a).catch(s)}.bind(this))},exit:function(){return new Promise(function(i,o){if(this.isFullscreen){var n=function(){this.off("change",n),i()}.bind(this);this.on("change",n);var s=t[e.exitFullscreen]();s instanceof Promise&&s.then(n).catch(o)}else i()}.bind(this))},toggle:function(t,e){return this.isFullscreen?this.exit():this.request(t,e)},onchange:function(t){this.on("change",t)},onerror:function(t){this.on("error",t)},on:function(e,o){var n=i[e];n&&t.addEventListener(n,o,!1)},off:function(e,o){var n=i[e];n&&t.removeEventListener(n,o,!1)},raw:e};return e?(Object.defineProperties(o,{isFullscreen:{get:function(){return Boolean(t[e.fullscreenElement])}},element:{enumerable:!0,get:function(){return t[e.fullscreenElement]}},isEnabled:{enumerable:!0,get:function(){return Boolean(t[e.fullscreenEnabled])}}}),o):{isEnabled:!1}},"function"==typeof define&&define.amd?define("screenfull",u):"object"==typeof module&&module.exports?module.exports.screenfull=u():d.screenfull=u(),
/*!
* leaflet.fullscreen
*/
function(t,e){"function"==typeof define&&define.amd?define("leafletFullScreen",["leaflet","screenfull"],e):"object"==typeof module&&module.exports?module.exports=e(require("leaflet"),require("screenfull")):e(t.L,t.screenfull)}("undefined"!=typeof self?self:window,(function(t,e){return t.Control.FullScreen=t.Control.extend({options:{position:"topleft",title:"Full Screen",titleCancel:"Exit Full Screen",forceSeparateButton:!1,forcePseudoFullscreen:!1,fullscreenElement:!1},_screenfull:e,onAdd:function(e){var i,o="leaflet-control-zoom-fullscreen",n="";return i=e.zoomControl&&!this.options.forceSeparateButton?e.zoomControl._container:t.DomUtil.create("div","leaflet-bar"),this.options.content?n=this.options.content:o+=" fullscreen-icon",this._createButton(this.options.title,o,n,i,this.toggleFullScreen,this),this._map.fullscreenControl=this,this._map.on("enterFullscreen exitFullscreen",this._toggleState,this),i},onRemove:function(){t.DomEvent.off(this.link,"click",t.DomEvent.stop).off(this.link,"click",this.toggleFullScreen,this),this._screenfull.isEnabled&&(t.DomEvent.off(this._container,this._screenfull.raw.fullscreenchange,t.DomEvent.stop).off(this._container,this._screenfull.raw.fullscreenchange,this._handleFullscreenChange,this),t.DomEvent.off(document,this._screenfull.raw.fullscreenchange,t.DomEvent.stop).off(document,this._screenfull.raw.fullscreenchange,this._handleFullscreenChange,this))},_createButton:function(e,i,o,n,s,a){return this.link=t.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.disableClickPropagation(n),t.DomEvent.on(this.link,"click",t.DomEvent.stop).on(this.link,"click",s,a),this._screenfull.isEnabled&&(t.DomEvent.on(n,this._screenfull.raw.fullscreenchange,t.DomEvent.stop).on(n,this._screenfull.raw.fullscreenchange,this._handleFullscreenChange,a),t.DomEvent.on(document,this._screenfull.raw.fullscreenchange,t.DomEvent.stop).on(document,this._screenfull.raw.fullscreenchange,this._handleFullscreenChange,a)),this.link},toggleFullScreen:function(){var e=this._map;e._exitFired=!1,e._isFullscreen?(this._screenfull.isEnabled&&!this.options.forcePseudoFullscreen?this._screenfull.exit():(t.DomUtil.removeClass(this.options.fullscreenElement?this.options.fullscreenElement:e._container,"leaflet-pseudo-fullscreen"),e.invalidateSize()),e.fire("exitFullscreen"),e._exitFired=!0,e._isFullscreen=!1):(this._screenfull.isEnabled&&!this.options.forcePseudoFullscreen?this._screenfull.request(this.options.fullscreenElement?this.options.fullscreenElement:e._container):(t.DomUtil.addClass(this.options.fullscreenElement?this.options.fullscreenElement:e._container,"leaflet-pseudo-fullscreen"),e.invalidateSize()),e.fire("enterFullscreen"),e._isFullscreen=!0)},_toggleState:function(){this.link.title=this._map._isFullscreen?this.options.title:this.options.titleCancel,this._map._isFullscreen?L.DomUtil.removeClass(this.link,"leaflet-fullscreen-on"):L.DomUtil.addClass(this.link,"leaflet-fullscreen-on")},_handleFullscreenChange:function(){var t=this._map;t.invalidateSize(),this._screenfull.isFullscreen||t._exitFired||(t.fire("exitFullscreen"),t._exitFired=!0,t._isFullscreen=!1)}}),t.Map.include({toggleFullscreen:function(){this.fullscreenControl.toggleFullScreen()}}),t.Map.addInitHook((function(){this.options.fullscreenControl&&this.addControl(t.control.fullscreen(this.options.fullscreenControlOptions))})),t.control.fullscreen=function(e){return new t.Control.FullScreen(e)},{leaflet:t,screenfull:e}})),
/**
* 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,fullscreenControl:!1,imageDateControl:!0},marker:{draggable:!0,icon:L.icon({className:"pegman-marker",iconSize:[52,52],iconAnchor:[24,33],iconUrl:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAFElEQVR4XgXAAQ0AAABAMP1L30IDCPwC/o5WcS4AAAAASUVORK5CYII="})}},__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.10.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._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.options.marker),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.findStreetViewData(this._pegmanMarkerCoords.lat,this._pegmanMarkerCoords.lng),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()},onPanoramaPositionChanged:function(){var t=this._panorama.getPosition();t=L.latLng(t.lat(),t.lng()),this._map&&!this._map.getBounds().pad(-.05).contains(t)&&this._map.panTo(t),this._pegmanMarker.setLatLng(t)},onPanoramaPovChanged:function(){var t=this._panorama.getPov();this._pegmanMarker.getElement().style.backgroundPosition="0 "+-Math.abs(Math.round(t.heading/22.5)%16*Math.round(835/16))+"px"},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){if("undefined"==typeof google)return this._loadScripts(!0),this.once("svpc_streetview-shown",L.bind(this.findStreetViewData,this,t,e));if(!this._pegmanMarker._map&&this._map)return this._pegmanMarkerCoords=L.latLng(t,e),this.pegmanAdd();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=n