Cesium-Examples/libs/leaflet/plugins/Leaflet.PixiOverlay/1.9.4/L.PixiOverlay.min.js

1 line
7.0 KiB
JavaScript
Raw Normal View History

2025-03-11 08:25:45 +00:00
!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(d,o){function e(){return this}var t=d.Point.prototype._round;function r(e,t,i){e=o.VERSION<"7"?e.plugins.interaction:e.events;t?e.destroy():i||(e.autoPreventDefault=!1)}var i={options:{padding:.1,forceCanvas:!1,doubleBuffering:!1,resolution:d.Browser.retina?2:1,projectionZoom:function(e){var t=e.getMaxZoom(),e=e.getMinZoom();return t===1/0?e+8:(t+e)/2},destroyInteractionManager:!1,autoPreventDefault:!0,preserveDrawingBuffer:!1,clearBeforeRender:!0,shouldRedrawOnMove:function(){return!1}},initialize:function(e,t,i){d.setOptions(this,i),d.stamp(this),this._drawCallback=e,this._pixiContainer=t,this._rendererOptions={resolution:this.options.resolution,antialias:!0,forceCanvas:this.options.forceCanvas,preserveDrawingBuffer:this.options.preserveDrawingBuffer,clearBeforeRender:this.options.clearBeforeRender},o.VERSION<"6"?this._rendererOptions.transparent=!0:this._rendererOptions.backgroundAlpha=0,this._doubleBuffering=o.utils.isWebGLSupported()&&!this.options.forceCanvas&&this.options.doubleBuffering},_setMap:function(){},_setContainerStyle:function(){},_addContainer:function(){this.getPane().appendChild(this._container)},_setEvents:function(){},onAdd:function(e){this._setMap(e),this._container||((e=this._container=d.DomUtil.create("div","leaflet-pixi-overlay")).style.position="absolute",this._renderer=o.autoDetectRenderer(this._rendererOptions),r(this._renderer,this.options.destroyInteractionManager,this.options.autoPreventDefault),e.appendChild(this._renderer.view),this._zoomAnimated&&(d.DomUtil.addClass(e,"leaflet-zoom-animated"),this._setContainerStyle()),this._doubleBuffering&&(this._auxRenderer=o.autoDetectRenderer(this._rendererOptions),r(this._auxRenderer,this.options.destroyInteractionManager,this.options.autoPreventDefault),e.appendChild(this._auxRenderer.view),this._renderer.view.style.position="absolute",this._auxRenderer.view.style.position="absolute")),this._addContainer(),this._setEvents();var i=this._map,n=(this._initialZoom=this.options.projectionZoom(i),this._wgsOrigin=d.latLng([0,0]),this._wgsInitialShift=i.project(this._wgsOrigin,this._initialZoom),this._mapInitialZoom=i.getZoom(),this);this.utils={latLngToLayerPoint:function(e,t){return t=void 0===t?n._initialZoom:t,i.project(d.latLng(e),t)},layerPointToLatLng:function(e,t){t=void 0===t?n._initialZoom:t;e=d.point(e);return i.unproject(e,t)},getScale:function(e){return void 0===e?i.getZoomScale(i.getZoom(),n._initialZoom):i.getZoomScale(e,n._initialZoom)},getRenderer:function(){return n._renderer},getContainer:function(){return n._pixiContainer},getMap:function(){return n._map}},this._update({type:"add"})},onRemove:function(){d.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),n=n.multiplyBy(-i).add(o).subtract(this._map._getNewPixelOrigin(e,t));d.Browser.any3d?d.DomUtil.setTransform(this._container,n,i):d.DomUtil.setPosition(this._container,n)},_redraw:function(e,t){this._disableLeafletRounding();var i=this._map.getZoomScale(this._zoom,this._initialZoom),e=this._map.latLngToLayerPoint(this._wgsOrigin)._subtract(this._wgsInitialShift.multiplyBy(i))._subtract(e);this._pixiContainer.scale.set(i),this._pixiContainer.position.set(e.x,e.y),this._drawCallback(this.utils,t),this._enableLeafletRounding()