1
0
This repository has been archived on 2023-11-30. You can view files and clone it, but cannot push or open issues or pull requests.
dtux__avion-poeme/dist/leaflet-pixi-overlay/L.PixiOverlay.min.js
2021-10-21 00:07:26 +02:00

1 line
6.7 KiB
JavaScript

!function(e){if("function"==typeof define&&define.amd)define(["leaflet","pixi.js"],e);else if("undefined"!=typeof module)module.exports=e(require("leaflet"),require("pixi.js"));else{if(void 0===window.L)throw new Error("Leaflet must be loaded first");if(void 0===window.PIXI)throw new Error("Pixi.js must be loaded first");e(window.L,window.PIXI)}}(function(_,r){function e(){return this}var t=_.Point.prototype._round;function i(e,t,i){t?e.destroy():i||(e.autoPreventDefault=!1)}var n={options:{padding:.1,forceCanvas:!1,doubleBuffering:!1,resolution:_.Browser.retina?2:1,projectionZoom:function(e){return(e.getMaxZoom()+e.getMinZoom())/2},destroyInteractionManager:!1,autoPreventDefault:!0,preserveDrawingBuffer:!1,clearBeforeRender:!0,shouldRedrawOnMove:function(){return!1}},initialize:function(e,t,i){_.setOptions(this,i),_.stamp(this),this._drawCallback=e,this._pixiContainer=t,this._rendererOptions={transparent:!0,resolution:this.options.resolution,antialias:!0,forceCanvas:this.options.forceCanvas,preserveDrawingBuffer:this.options.preserveDrawingBuffer,clearBeforeRender:this.options.clearBeforeRender},this._doubleBuffering=r.utils.isWebGLSupported()&&!this.options.forceCanvas&&this.options.doubleBuffering},_setMap:function(){},_setContainerStyle:function(){},_addContainer:function(){this.getPane().appendChild(this._container)},_setEvents:function(){},onAdd:function(e){if(this._setMap(e),!this._container){var t=this._container=_.DomUtil.create("div","leaflet-pixi-overlay");t.style.position="absolute",this._renderer=r.autoDetectRenderer(this._rendererOptions),i(this._renderer.plugins.interaction,this.options.destroyInteractionManager,this.options.autoPreventDefault),t.appendChild(this._renderer.view),this._zoomAnimated&&(_.DomUtil.addClass(t,"leaflet-zoom-animated"),this._setContainerStyle()),this._doubleBuffering&&(this._auxRenderer=r.autoDetectRenderer(this._rendererOptions),i(this._auxRenderer.plugins.interaction,this.options.destroyInteractionManager,this.options.autoPreventDefault),t.appendChild(this._auxRenderer.view),this._renderer.view.style.position="absolute",this._auxRenderer.view.style.position="absolute")}this._addContainer(),this._setEvents();var n=this._map;this._initialZoom=this.options.projectionZoom(n),this._wgsOrigin=_.latLng([0,0]),this._wgsInitialShift=n.project(this._wgsOrigin,this._initialZoom),this._mapInitialZoom=n.getZoom();var o=this;this.utils={latLngToLayerPoint:function(e,t){return t=void 0===t?o._initialZoom:t,n.project(_.latLng(e),t)},layerPointToLatLng:function(e,t){t=void 0===t?o._initialZoom:t;var i=_.point(e);return n.unproject(i,t)},getScale:function(e){return void 0===e?n.getZoomScale(n.getZoom(),o._initialZoom):n.getZoomScale(e,o._initialZoom)},getRenderer:function(){return o._renderer},getContainer:function(){return o._pixiContainer},getMap:function(){return o._map}},this._update({type:"add"})},onRemove:function(){_.DomUtil.remove(this._container)},getEvents:function(){var e={zoom:this._onZoom,move:this._onMove,moveend:this._update};return this._zoomAnimated&&(e.zoomanim=this._onAnimZoom),e},_onZoom:function(){this._updateTransform(this._map.getCenter(),this._map.getZoom())},_onAnimZoom:function(e){this._updateTransform(e.center,e.zoom)},_onMove:function(e){this.options.shouldRedrawOnMove(e)&&this._update(e)},_updateTransform:function(e,t){var i=this._map.getZoomScale(t,this._zoom),n=this._map.getSize().multiplyBy(.5+this.options.padding),o=this._map.project(this._center,t),r=n.multiplyBy(-i).add(o).subtract(this._map._getNewPixelOrigin(e,t));_.Browser.any3d?_.DomUtil.setTransform(this._container,r,i):_.DomUtil.setPosition(this._container,r)},_redraw:function(e,t){this._disableLeafletRounding();var i=this._map.getZoomScale(this._zoom,this._initialZoom),n=this._map.latLngToLayerPoint(this._wgsOrigin)._subtract(this._wgsInitialShift.multiplyBy(i))._subtract(e);this._pixiContainer.scale.set(i),this._pixiContainer.position.set(n.x,n.y),this._drawCallback(this.utils,t),this._enableLeafletRounding()},_update:function(e){if(!this._map._animatingZoom||!this._bounds){var t=this.options.padding,i=this._map.getSize(),n=this._map.containerPointToLayerPoint(i.multiplyBy(-t)).round();if(this._bounds=new _.Bounds(n,n.add(i.multiplyBy(1+2*t)).round()),this._center=this._map.getCenter(),this._zoom=this._map.getZoom(),this._doubleBuffering){var o=this._renderer;this._renderer=this._auxRenderer,this._auxRenderer=o}var r=this._renderer.view,s=this._bounds,a=this._container,d=s.getSize();if(!this._renderer.size||this._renderer.size.x!==d.x||this._renderer.size.y!==d.y){if(this._renderer.gl&&(this._renderer.resolution=this.options.resolution,this._renderer.rootRenderTarget&&(this._renderer.rootRenderTarget.resolution=this.options.resolution)),this._renderer.resize(d.x,d.y),r.style.width=d.x+"px",r.style.height=d.y+"px",this._renderer.gl){var h=this._renderer.gl;if(h.drawingBufferWidth!==this._renderer.width){var l=this.options.resolution*h.drawingBufferWidth/this._renderer.width;this._renderer.resolution=l,this._renderer.rootRenderTarget&&(this._renderer.rootRenderTarget.resolution=l),this._renderer.resize(d.x,d.y)}}this._renderer.size=d}if(this._doubleBuffering){var u=this;requestAnimationFrame(function(){u._redraw(s.min,e),u._renderer.gl.finish(),r.style.visibility="visible",u._auxRenderer.view.style.visibility="hidden",_.DomUtil.setPosition(a,s.min)})}else this._redraw(s.min,e),_.DomUtil.setPosition(a,s.min)}},_disableLeafletRounding:function(){_.Point.prototype._round=e},_enableLeafletRounding:function(){_.Point.prototype._round=t},redraw:function(e){return this._map&&(this._disableLeafletRounding(),this._drawCallback(this.utils,e),this._enableLeafletRounding()),this}};"1"<=_.version?_.PixiOverlay=_.Layer.extend(n):(_.Map.prototype.getZoomScale=function(e,t){var i=this.options.crs;return t=void 0===t?this._zoom:t,i.scale(e)/i.scale(t)},_.DomUtil.setTransform=function(e,t,i){var n=t||new _.Point(0,0);e.style[_.DomUtil.TRANSFORM]=(_.Browser.ie3d?"translate("+n.x+"px,"+n.y+"px)":"translate3d("+n.x+"px,"+n.y+"px,0)")+(i?" scale("+i+")":"")},n.includes=_.Mixin.Events,n.addTo=function(e){return e.addLayer(this),this},n._setMap=function(e){this._map=e,this._zoomAnimated=e._zoomAnimated},n._setContainerStyle=function(){var t=this;["-webkit-transform-origin","-ms-transform-origin","transform-origin"].forEach(function(e){t._container.style[e]="0 0"})},n._addContainer=function(){this._map.getPanes()[this.options.pane||"overlayPane"].appendChild(this._container)},n._setEvents=function(){var e=this.getEvents();for(var t in e)this._map.on(t,e[t],this)},n.onRemove=function(){this._map.getPanes()[this.options.pane||"overlayPane"].removeChild(this._container);var e=this.getEvents();for(var t in e)this._map.off(t,e[t],this)},_.PixiOverlay=_.Class.extend(n)),_.pixiOverlay=function(e,t,i){return _.Browser.canvas?new _.PixiOverlay(e,t,i):null}});