vendor: 9,296 bytes, lines 1-234
1/* jshint esversion: 6, -W008, -W030, -W083 */ 2// Generated from src/leaflet-maplibre-gl.mjs. Run `npm run build` to update. 3(function(global, factory) { 4 typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("leaflet"), require("maplibre-gl")) : typeof define === "function" && define.amd ? define([ 5 "exports", 6 "leaflet", 7 "maplibre-gl" 8 ], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.MaplibreGLLeaflet = {}, global.L, global.maplibregl)); 9})(this, function(exports, leaflet, maplibre_gl) { 10 Object.defineProperty(exports, "__esModule", { value: true }); 11 //#region \0rolldown/runtime.js 12 var __create = Object.create; 13 var __defProp = Object.defineProperty; 14 var __getOwnPropDesc = Object.getOwnPropertyDescriptor; 15 var __getOwnPropNames = Object.getOwnPropertyNames; 16 var __getProtoOf = Object.getPrototypeOf; 17 var __hasOwnProp = Object.prototype.hasOwnProperty; 18 var __copyProps = (to, from, except, desc) => { 19 if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { 20 key = keys[i]; 21 if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { 22 get: ((k) => from[k]).bind(null, key), 23 enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable 24 }); 25 } 26 return to; 27 }; 28 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", { 29 value: mod, 30 enumerable: true 31 }) : target, mod)); 32 //#endregion 33 leaflet = __toESM(leaflet, 1); 34 maplibre_gl = __toESM(maplibre_gl, 1); 35 //#region src/leaflet-maplibre-gl.mjs 36 var L = leaflet.default || leaflet; 37 var MaplibreGL = L.Layer.extend({ 38 options: { 39 updateInterval: 32, 40 padding: .1, 41 interactive: false, 42 pane: "tilePane" 43 }, 44 initialize: function(options) { 45 L.setOptions(this, options); 46 this._throttledUpdate = L.Util.throttle(this._update, this.options.updateInterval, this); 47 }, 48 onAdd: function(map) { 49 if (!this._container) this._initContainer(); 50 var paneName = this.getPaneName(); 51 map.getPane(paneName).appendChild(this._container); 52 this._initGL(); 53 this._offset = this._map.containerPointToLayerPoint([0, 0]); 54 if (map.options.zoomAnimation) L.DomEvent.on(map._proxy, L.DomUtil.TRANSITION_END, this._transitionEnd, this); 55 }, 56 onRemove: function(map) { 57 if (this._map._proxy && this._map.options.zoomAnimation) L.DomEvent.off(this._map._proxy, L.DomUtil.TRANSITION_END, this._transitionEnd, this); 58 var paneName = this.getPaneName(); 59 map.getPane(paneName).removeChild(this._container); 60 this._glMap.remove(); 61 this._glMap = null; 62 }, 63 getEvents: function() { 64 return { 65 move: this._throttledUpdate, 66 zoomanim: this._animateZoom, 67 zoom: this._pinchZoom, 68 zoomstart: this._zoomStart, 69 zoomend: this._zoomEnd, 70 resize: this._resize 71 }; 72 }, 73 getAttribution: function() { 74 if (this.options.attributionControl) return this.options.attributionControl.customAttribution; 75 var map = this._glMap; 76 if (map && this.options.attributionControl !== false) { 77 var style = map.getStyle(); 78 if (style && style.sources) return Object.keys(style.sources).map(function(sourceId) { 79 var source = map.getSource(sourceId); 80 return source && typeof source.attribution === "string" ? source.attribution.trim() : null; 81 }).filter(Boolean).join(", "); 82 } 83 return ""; 84 }, 85 getMaplibreMap: function() { 86 return this._glMap; 87 }, 88 getCanvas: function() { 89 return this._glMap.getCanvas(); 90 }, 91 getSize: function() { 92 return this._map.getSize().multiplyBy(1 + this.options.padding * 2); 93 }, 94 getBounds: function() { 95 var halfSize = this.getSize().multiplyBy(.5); 96 var center = this._map.latLngToContainerPoint(this._map.getCenter()); 97 return L.latLngBounds(this._map.containerPointToLatLng(center.subtract(halfSize)), this._map.containerPointToLatLng(center.add(halfSize))); 98 }, 99 getContainer: function() { 100 return this._container; 101 }, 102 getPaneName: function() { 103 return this._map.getPane(this.options.pane) ? this.options.pane : "tilePane"; 104 }, 105 _roundPoint: function(p) { 106 return { 107 x: Math.round(p.x), 108 y: Math.round(p.y) 109 }; 110 }, 111 _initContainer: function() { 112 var container = this._container = L.DomUtil.create("div", "leaflet-gl-layer"); 113 this._resizeContainer(); 114 var offset = this._map.getSize().multiplyBy(this.options.padding); 115 var topLeft = this._map.containerPointToLayerPoint([0, 0]).subtract(offset); 116 L.DomUtil.setPosition(container, this._roundPoint(topLeft)); 117 }, 118 _resizeContainer: function() { 119 var size = this.getSize(); 120 this._container.style.width = size.x + "px"; 121 this._container.style.height = size.y + "px"; 122 }, 123 _initGL: function() { 124 var center = this._map.getCenter(); 125 var options = L.extend({}, this.options, { 126 container: this._container, 127 center: [center.lng, center.lat], 128 zoom: this._map.getZoom() - 1, 129 attributionControl: false 130 }); 131 this._glMap = new maplibre_gl.Map(options); 132 var _map = this._map; 133 var _currentAttribution = this.getAttribution(); 134 var _getAttribution = this.getAttribution.bind(this); 135 this._glMap.on("load", function() { 136 if (_map && _map.attributionControl) { 137 _map.attributionControl.removeAttribution(_currentAttribution); 138 _map.attributionControl.addAttribution(_getAttribution()); 139 } 140 }); 141 if (this._glMap.setTransformConstrain) this._glMap.setTransformConstrain(function(center, zoom) { 142 return { 143 center, 144 zoom 145 }; 146 }); 147 else { 148 var transform = this._glMap.transform; 149 var transformProto = Object.getPrototypeOf(transform); 150 var latRangeDescriptor = Object.getOwnPropertyDescriptor(transformProto, "latRange"); 151 if (!latRangeDescriptor || latRangeDescriptor.set || latRangeDescriptor.writable) transform.latRange = null; 152 var maxValidLatitudeDescriptor = Object.getOwnPropertyDescriptor(transformProto, "maxValidLatitude"); 153 if (!maxValidLatitudeDescriptor || maxValidLatitudeDescriptor.set || maxValidLatitudeDescriptor.writable) transform.maxValidLatitude = Infinity; 154 if (transform._helper && transform._helper._latRange) transform._helper._latRange = [-Infinity, Infinity]; 155 } 156 this._transformGL(this._glMap); 157 if (this._glMap._canvas.canvas) this._glMap._actualCanvas = this._glMap._canvas.canvas; 158 else this._glMap._actualCanvas = this._glMap._canvas; 159 var canvas = this._glMap._actualCanvas; 160 L.DomUtil.addClass(canvas, "leaflet-image-layer"); 161 L.DomUtil.addClass(canvas, "leaflet-zoom-animated"); 162 if (this.options.interactive) L.DomUtil.addClass(canvas, "leaflet-interactive"); 163 if (this.options.className) L.DomUtil.addClass(canvas, this.options.className); 164 }, 165 _update: function(e) { 166 if (!this._map) return; 167 this._offset = this._map.containerPointToLayerPoint([0, 0]); 168 if (this._zooming) return; 169 var container = this._container, gl = this._glMap, offset = this._map.getSize().multiplyBy(this.options.padding), topLeft = this._map.containerPointToLayerPoint([0, 0]).subtract(offset); 170 L.DomUtil.setPosition(container, this._roundPoint(topLeft)); 171 this._transformGL(gl); 172 }, 173 _transformGL: function(gl) { 174 var center = this._map.getCenter(); 175 gl.jumpTo({ 176 center: [center.lng, center.lat], 177 zoom: this._map.getZoom() - 1 178 }); 179 }, 180 _pinchZoom: function(e) { 181 this._glMap.jumpTo({ 182 zoom: this._map.getZoom() - 1, 183 center: this._map.getCenter() 184 }); 185 }, 186 _animateZoom: function(e) { 187 var scale = this._map.getZoomScale(e.zoom); 188 var padding = this._map.getSize().multiplyBy(this.options.padding * scale); 189 var viewHalf = this.getSize()._divideBy(2); 190 var topLeft = this._map.project(e.center, e.zoom)._subtract(viewHalf)._add(this._map._getMapPanePos().add(padding))._round(); 191 var offset = this._map.project(this._map.getBounds().getNorthWest(), e.zoom)._subtract(topLeft); 192 L.DomUtil.setTransform(this._glMap._actualCanvas, offset.subtract(this._offset), scale); 193 }, 194 _zoomStart: function(e) { 195 this._zooming = true; 196 }, 197 _zoomEnd: function() { 198 var scale = this._map.getZoomScale(this._map.getZoom()); 199 L.DomUtil.setTransform(this._glMap._actualCanvas, null, scale); 200 this._zooming = false; 201 this._update(); 202 }, 203 _transitionEnd: function(e) { 204 L.Util.requestAnimFrame(function() { 205 var zoom = this._map.getZoom(); 206 var center = this._map.getCenter(); 207 var offset = this._map.latLngToContainerPoint(this._map.getBounds().getNorthWest()); 208 this._resizeContainer(); 209 L.DomUtil.setTransform(this._glMap._actualCanvas, offset, 1); 210 this._glMap.once("moveend", L.Util.bind(function() { 211 this._zoomEnd(); 212 }, this)); 213 this._glMap.jumpTo({ 214 center, 215 zoom: zoom - 1 216 }); 217 }, this); 218 }, 219 _resize: function(e) { 220 this._transitionEnd(e); 221 } 222 }); 223 var maplibreGL = function(options) { 224 return new MaplibreGL(options); 225 }; 226 if (Object.isExtensible(L)) { 227 L.MaplibreGL = MaplibreGL; 228 L.maplibreGL = maplibreGL; 229 } 230 //#endregion 231 exports.MaplibreGL = MaplibreGL; 232 exports.default = maplibreGL; 233 exports.maplibreGL = maplibreGL; 234});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.