{"version":3,"file":"esri-leaflet-vector.js","sources":["../src/Util.js","../src/MaplibreGLLayer.js","../src/VectorTileLayer.js","../src/VectorBasemapLayer.js","../src/EsriLeafletVector.js"],"sourcesContent":["import { latLng, latLngBounds } from 'leaflet';\nimport { request, Support, Util } from 'esri-leaflet';\n\n/*\n utility to establish a URL for the basemap styles API\n used primarily by VectorBasemapLayer.js\n*/\nexport function getBasemapStyleUrl (style, apikey) {\n if (style.includes('/')) {\n throw new Error(style + ' is a v2 style enumeration. Set version:2 to request this style');\n }\n\n let url =\n 'https://basemaps-api.arcgis.com/arcgis/rest/services/styles/' +\n style +\n '?type=style';\n if (apikey) {\n url = url + '&token=' + apikey;\n }\n return url;\n}\n\nexport function getBasemapStyleV2Url (style, apikey, language) {\n if (style.includes(':')) {\n throw new Error(style + ' is a v1 style enumeration. Set version:1 to request this style');\n }\n\n let url = 'https://basemapstyles-api.arcgis.com/arcgis/rest/services/styles/v2/styles/';\n if (!(style.startsWith('osm/') || style.startsWith('arcgis/')) && style.length === 32) {\n // style is an itemID\n url = url + 'items/' + style;\n\n if (language) {\n throw new Error('The \\'language\\' parameter is not supported for custom basemap styles');\n }\n } else {\n url = url + style;\n }\n\n if (apikey) {\n url = url + '?token=' + apikey;\n\n if (language) {\n url = url + '&language=' + language;\n }\n }\n return url;\n}\n/*\n utilities to communicate with custom user styles via an ITEM ID or SERVICE URL\n used primarily by VectorTileLayer.js\n*/\nexport function loadStyle (idOrUrl, options, callback) {\n const httpRegex = /^https?:\\/\\//;\n const serviceRegex = /\\/VectorTileServer\\/?$/;\n\n if (httpRegex.test(idOrUrl) && serviceRegex.test(idOrUrl)) {\n const serviceUrl = idOrUrl;\n loadStyleFromService(serviceUrl, options, callback);\n } else {\n const itemId = idOrUrl;\n loadStyleFromItem(itemId, options, callback);\n }\n}\n\nexport function loadService (serviceUrl, options, callback) {\n const params = options.token ? { token: options.token } : {};\n request(serviceUrl, params, callback);\n}\n\nfunction loadItem (itemId, options, callback) {\n const params = options.token ? { token: options.token } : {};\n const url = options.portalUrl + '/sharing/rest/content/items/' + itemId;\n request(url, params, callback);\n}\n\nfunction loadStyleFromItem (itemId, options, callback) {\n const itemStyleUrl =\n options.portalUrl +\n '/sharing/rest/content/items/' +\n itemId +\n '/resources/styles/root.json';\n\n loadStyleFromUrl(itemStyleUrl, options, function (error, style) {\n if (error) {\n loadItem(itemId, options, function (error, item) {\n if (error) {\n callback(error);\n return;\n }\n loadStyleFromService(item.url, options, callback);\n });\n } else {\n loadItem(itemId, options, function (error, item) {\n if (error) {\n callback(error);\n return;\n }\n loadService(item.url, options, function (error, service) {\n callback(error, style, itemStyleUrl, service, item.url);\n });\n });\n }\n });\n}\n\nfunction loadStyleFromService (serviceUrl, options, callback) {\n loadService(serviceUrl, options, function (error, service) {\n if (error) {\n callback(error);\n return;\n }\n\n let sanitizedServiceUrl = serviceUrl;\n // a trailing \"/\" may create invalid paths\n if (serviceUrl.charAt(serviceUrl.length - 1) === '/') {\n sanitizedServiceUrl = serviceUrl.slice(0, serviceUrl.length - 1);\n }\n\n let defaultStylesUrl;\n // inadvertently inserting more than 1 adjacent \"/\" may create invalid paths\n if (service.defaultStyles.charAt(0) === '/') {\n defaultStylesUrl =\n sanitizedServiceUrl + service.defaultStyles + '/root.json';\n } else {\n defaultStylesUrl =\n sanitizedServiceUrl + '/' + service.defaultStyles + '/root.json';\n }\n\n loadStyleFromUrl(defaultStylesUrl, options, function (error, style) {\n if (error) {\n callback(error);\n return;\n }\n callback(null, style, defaultStylesUrl, service, serviceUrl);\n });\n });\n}\n\nfunction loadStyleFromUrl (styleUrl, options, callback) {\n const params = options.token ? { token: options.token } : {};\n request(styleUrl, params, callback);\n}\n\nfunction isSameTLD (url1, url2) {\n return (new URL(url1)).hostname === (new URL(url2)).hostname;\n}\n\nexport function formatStyle (style, styleUrl, metadata, token) {\n // transforms style object in place and also returns it\n\n // modify each source in style.sources\n const sourcesKeys = Object.keys(style.sources);\n for (let sourceIndex = 0; sourceIndex < sourcesKeys.length; sourceIndex++) {\n const source = style.sources[sourcesKeys[sourceIndex]];\n\n // if a relative path is referenced, the default style can be found in a standard location\n if (source.url.indexOf('http') === -1) {\n source.url = styleUrl.replace('/resources/styles/root.json', '');\n }\n\n // a trailing \"/\" may create invalid paths\n if (source.url.charAt(source.url.length - 1) === '/') {\n source.url = source.url.slice(0, source.url.length - 1);\n }\n\n // add tiles property if missing\n if (!source.tiles) {\n // right now ArcGIS Pro published vector services have a slightly different signature\n // the '/' is needed in the URL string concatenation below for source.tiles\n if (metadata.tiles && metadata.tiles[0].charAt(0) !== '/') {\n metadata.tiles[0] = '/' + metadata.tiles[0];\n }\n\n source.tiles = [source.url + metadata.tiles[0]];\n }\n\n // some VectorTileServer endpoints may default to returning f=html,\n // specify f=json to account for that behavior\n source.url += '?f=json';\n\n // add the token to the source url and tiles properties as a query param\n source.url += token ? '&token=' + token : '';\n source.tiles[0] += token ? '?token=' + token : '';\n // add minzoom and maxzoom to each source based on the service metadata\n // prefer minLOD/maxLOD if it exists since that is the level that tiles are cooked too\n // MapLibre will overzoom for LODs that are not cooked\n source.minzoom = metadata.minLOD || metadata.tileInfo.lods[0].level;\n source.maxzoom =\n metadata.maxLOD ||\n metadata.tileInfo.lods[metadata.tileInfo.lods.length - 1].level;\n }\n\n // add the attribution and copyrightText properties to the last source in style.sources based on the service metadata\n const lastSource = style.sources[sourcesKeys[sourcesKeys.length - 1]];\n lastSource.attribution = metadata.copyrightText || '';\n lastSource.copyrightText = metadata.copyrightText || '';\n\n // if any layer in style.layers has a layout.text-font property (it will be any array of strings) remove all items in the array after the first\n for (let layerIndex = 0; layerIndex < style.layers.length; layerIndex++) {\n const layer = style.layers[layerIndex];\n if (\n layer.layout &&\n layer.layout['text-font'] &&\n layer.layout['text-font'].length > 1\n ) {\n layer.layout['text-font'] = [layer.layout['text-font'][0]];\n }\n }\n\n if (style.sprite && style.sprite.indexOf('http') === -1) {\n // resolve absolute URL for style.sprite\n style.sprite = styleUrl.replace(\n 'styles/root.json',\n style.sprite.replace('../', '')\n );\n }\n if (style.sprite && token) {\n // add the token to the style.sprite property as a query param, only if same domain (for token security)\n if (isSameTLD(styleUrl, style.sprite)) {\n style.sprite += '?token=' + token;\n } else {\n console.warn('Passing a token but sprite URL is not on same base URL, so you must pass the token manually.');\n }\n }\n\n if (style.glyphs && style.glyphs.indexOf('http') === -1) {\n // resolve absolute URL for style.glyphs\n style.glyphs = styleUrl.replace(\n 'styles/root.json',\n style.glyphs.replace('../', '')\n );\n }\n\n if (style.glyphs && token) {\n // add the token to the style.glyphs property as a query param\n if (isSameTLD(styleUrl, style.glyphs)) {\n style.glyphs += '?token=' + token;\n } else {\n console.warn('Passing a token but glyph URL is not on same base URL, so you must pass the token manually.');\n }\n }\n\n return style;\n}\n\n/*\n utility to assist with dynamic attribution data\n used primarily by VectorBasemapLayer.js\n*/\nexport function getAttributionData (url, map) {\n if (Support.cors) {\n request(url, {}, function (error, attributions) {\n if (error) {\n return;\n }\n map._esriAttributions = map._esriAttributions || [];\n for (let c = 0; c < attributions.contributors.length; c++) {\n const contributor = attributions.contributors[c];\n\n for (let i = 0; i < contributor.coverageAreas.length; i++) {\n const coverageArea = contributor.coverageAreas[i];\n const southWest = latLng(coverageArea.bbox[0], coverageArea.bbox[1]);\n const northEast = latLng(coverageArea.bbox[2], coverageArea.bbox[3]);\n map._esriAttributions.push({\n attribution: contributor.attribution,\n score: coverageArea.score,\n bounds: latLngBounds(southWest, northEast),\n minZoom: coverageArea.zoomMin,\n maxZoom: coverageArea.zoomMax\n });\n }\n }\n\n map._esriAttributions.sort(function (a, b) {\n return b.score - a.score;\n });\n\n // pass the same argument as the map's 'moveend' event\n const obj = { target: map };\n Util._updateMapAttribution(obj);\n });\n }\n}\n\n/*\n utility to check if a service's tileInfo spatial reference is in Web Mercator\n used primarily by VectorTileLayer.js\n*/\nconst WEB_MERCATOR_WKIDS = [3857, 102100, 102113];\n\nexport function isWebMercator (wkid) {\n return WEB_MERCATOR_WKIDS.indexOf(wkid) >= 0;\n}\n\nexport var EsriUtil = {\n formatStyle: formatStyle\n};\n\nexport default EsriUtil;\n","import {\n DomEvent,\n DomUtil,\n extend,\n latLngBounds,\n Layer,\n setOptions,\n Util\n} from 'leaflet';\nimport maplibregl from 'maplibre-gl';\n\nexport const setRTLTextPlugin = (url, callback, deferred) => {\n maplibregl.setRTLTextPlugin(url, callback, deferred);\n};\n\nexport var MaplibreGLJSLayer = Layer.extend({\n options: {\n updateInterval: 32,\n // How much to extend the overlay view (relative to map size)\n // e.g. 0.1 would be 10% of map view in each direction\n padding: 0.1,\n // whether or not to register the mouse and keyboard\n // events on the mapbox overlay\n interactive: false,\n // set the tilepane as the default pane to draw gl tiles\n pane: 'tilePane'\n },\n\n initialize: function (options) {\n setOptions(this, options);\n\n // setup throttling the update event when panning\n this._throttledUpdate = Util.throttle(\n this._update,\n this.options.updateInterval,\n this\n );\n },\n\n onAdd: function (map) {\n if (!this._container) {\n this._initContainer();\n }\n\n const paneName = this.getPaneName();\n map.getPane(paneName).appendChild(this._container);\n\n this._initGL();\n\n this._offset = this._map.containerPointToLayerPoint([0, 0]);\n\n // work around https://github.com/mapbox/mapbox-gl-leaflet/issues/47\n if (map.options.zoomAnimation) {\n DomEvent.on(\n map._proxy,\n DomUtil.TRANSITION_END,\n this._transitionEnd,\n this\n );\n }\n },\n\n onRemove: function (map) {\n if (this._map._proxy && this._map.options.zoomAnimation) {\n DomEvent.off(\n this._map._proxy,\n DomUtil.TRANSITION_END,\n this._transitionEnd,\n this\n );\n }\n\n const paneName = this.getPaneName();\n\n map.getPane(paneName).removeChild(this._container);\n this._container = null;\n\n this._glMap.remove();\n this._glMap = null;\n },\n\n getEvents: function () {\n return {\n move: this._throttledUpdate, // sensibly throttle updating while panning\n zoomanim: this._animateZoom, // applies the zoom animation to the \n zoom: this._pinchZoom, // animate every zoom event for smoother pinch-zooming\n zoomstart: this._zoomStart, // flag starting a zoom to disable panning\n zoomend: this._zoomEnd,\n resize: this._resize\n };\n },\n\n getMaplibreMap: function () {\n return this._glMap;\n },\n\n getCanvas: function () {\n return this._glMap.getCanvas();\n },\n\n getSize: function () {\n return this._map.getSize().multiplyBy(1 + this.options.padding * 2);\n },\n\n getOpacity: function () {\n return this.options.opacity;\n },\n\n setOpacity: function (opacity) {\n this.options.opacity = opacity;\n this._container.style.opacity = opacity;\n },\n\n getBounds: function () {\n const halfSize = this.getSize().multiplyBy(0.5);\n const center = this._map.latLngToContainerPoint(this._map.getCenter());\n return latLngBounds(\n this._map.containerPointToLatLng(center.subtract(halfSize)),\n this._map.containerPointToLatLng(center.add(halfSize))\n );\n },\n\n getContainer: function () {\n return this._container;\n },\n\n // returns the pane name set in options if it is a valid pane, defaults to tilePane\n getPaneName: function () {\n return this._map.getPane(this.options.pane)\n ? this.options.pane\n : 'tilePane';\n },\n\n _resize: function () {\n return this._glMap._resize;\n },\n\n _initContainer: function () {\n if (this._container) {\n return;\n }\n\n this._container = DomUtil.create('div', 'leaflet-gl-layer');\n\n const size = this.getSize();\n const offset = this._map.getSize().multiplyBy(this.options.padding);\n this._container.style.width = size.x + 'px';\n this._container.style.height = size.y + 'px';\n\n const topLeft = this._map.containerPointToLayerPoint([0, 0]).subtract(offset);\n\n DomUtil.setPosition(this._container, topLeft);\n },\n\n _initGL: function () {\n if (this._glMap) {\n return;\n }\n\n const center = this._map.getCenter();\n\n const options = extend({}, this.options, {\n container: this._container,\n center: [center.lng, center.lat],\n zoom: this._map.getZoom() - 1,\n attributionControl: false\n });\n\n this._glMap = new maplibregl.Map(options);\n\n // Fire event for Maplibre \"styledata\" event.\n this._glMap.once(\n 'styledata',\n function (res) {\n this.fire('styleLoaded');\n }.bind(this)\n );\n\n // allow GL base map to pan beyond min/max latitudes\n this._glMap.transform.latRange = null;\n this._glMap.transform.maxValidLatitude = Infinity;\n\n this._transformGL(this._glMap);\n\n if (this._glMap._canvas.canvas) {\n // older versions of mapbox-gl surfaced the canvas differently\n this._glMap._actualCanvas = this._glMap._canvas.canvas;\n } else {\n this._glMap._actualCanvas = this._glMap._canvas;\n }\n\n // treat child element like L.ImageOverlay\n const canvas = this._glMap._actualCanvas;\n DomUtil.addClass(canvas, 'leaflet-image-layer');\n DomUtil.addClass(canvas, 'leaflet-zoom-animated');\n if (this.options.interactive) {\n DomUtil.addClass(canvas, 'leaflet-interactive');\n }\n if (this.options.className) {\n DomUtil.addClass(canvas, this.options.className);\n }\n },\n\n _update: function (e) {\n // update the offset, so we can correct for it later when we zoom\n this._offset = this._map.containerPointToLayerPoint([0, 0]);\n\n if (this._zooming) {\n return;\n }\n\n const size = this.getSize();\n const container = this._container;\n const gl = this._glMap;\n const offset = this._map.getSize().multiplyBy(this.options.padding);\n const topLeft = this._map.containerPointToLayerPoint([0, 0]).subtract(offset);\n\n DomUtil.setPosition(container, topLeft);\n\n this._transformGL(gl);\n\n if (gl.transform.width !== size.x || gl.transform.height !== size.y) {\n container.style.width = size.x + 'px';\n container.style.height = size.y + 'px';\n if (gl._resize !== null && gl._resize !== undefined) {\n gl._resize();\n } else {\n gl.resize();\n }\n } else {\n // older versions of mapbox-gl surfaced update publicly\n if (gl._update !== null && gl._update !== undefined) {\n gl._update();\n } else {\n gl.update();\n }\n }\n },\n\n _transformGL: function (gl) {\n const center = this._map.getCenter();\n\n // gl.setView([center.lat, center.lng], this._map.getZoom() - 1, 0);\n // calling setView directly causes sync issues because it uses requestAnimFrame\n\n const tr = gl.transform;\n tr.center = maplibregl.LngLat.convert([center.lng, center.lat]);\n tr.zoom = this._map.getZoom() - 1;\n },\n\n // update the map constantly during a pinch zoom\n _pinchZoom: function (e) {\n this._glMap.jumpTo({\n zoom: this._map.getZoom() - 1,\n center: this._map.getCenter()\n });\n },\n\n // borrowed from L.ImageOverlay\n // https://github.com/Leaflet/Leaflet/blob/master/src/layer/ImageOverlay.js#L139-L144\n _animateZoom: function (e) {\n const scale = this._map.getZoomScale(e.zoom);\n const padding = this._map.getSize().multiplyBy(this.options.padding * scale);\n const viewHalf = this.getSize()._divideBy(2);\n // corrections for padding (scaled), adapted from\n // https://github.com/Leaflet/Leaflet/blob/master/src/map/Map.js#L1490-L1508\n const topLeft = this._map\n .project(e.center, e.zoom)\n ._subtract(viewHalf)\n ._add(this._map._getMapPanePos().add(padding))\n ._round();\n const offset = this._map\n .project(this._map.getBounds().getNorthWest(), e.zoom)\n ._subtract(topLeft);\n\n DomUtil.setTransform(\n this._glMap._actualCanvas,\n offset.subtract(this._offset),\n scale\n );\n },\n\n _zoomStart: function (e) {\n this._zooming = true;\n },\n\n _zoomEnd: function () {\n const scale = this._map.getZoomScale(this._map.getZoom());\n\n DomUtil.setTransform(this._glMap._actualCanvas, null, scale);\n\n this._zooming = false;\n\n this._update();\n },\n\n _transitionEnd: function (e) {\n Util.requestAnimFrame(function () {\n const zoom = this._map.getZoom();\n const center = this._map.getCenter();\n const offset = this._map.latLngToContainerPoint(\n this._map.getBounds().getNorthWest()\n );\n\n // reset the scale and offset\n DomUtil.setTransform(this._glMap._actualCanvas, offset, 1);\n\n // enable panning once the gl map is ready again\n this._glMap.once(\n 'moveend',\n Util.bind(function () {\n this._zoomEnd();\n }, this)\n );\n\n // update the map position\n this._glMap.jumpTo({\n center: center,\n zoom: zoom - 1\n });\n }, this);\n }\n});\n\nexport function maplibreGLJSLayer (options) {\n return new MaplibreGLJSLayer(options);\n}\n","import { Layer, setOptions } from 'leaflet';\nimport { loadStyle, formatStyle, isWebMercator } from './Util';\nimport { maplibreGLJSLayer } from './MaplibreGLLayer';\n\nexport var VectorTileLayer = Layer.extend({\n options: {\n // if portalUrl is not provided, default to ArcGIS Online\n portalUrl: 'https://www.arcgis.com',\n // for performance optimization default to `false`\n // set to `true` to resolve printing issues in Firefox\n preserveDrawingBuffer: false\n },\n\n /**\n * Populates \"this.options\" to be used in the rest of the module and creates the layer instance.\n *\n * @param {string} key an ITEM ID or SERVICE URL\n * @param {object} options optional\n */\n initialize: function (key, options) {\n if (options) {\n setOptions(this, options);\n }\n\n // support outdated casing apiKey of apikey\n if (this.options.apiKey) {\n this.options.apikey = this.options.apiKey;\n }\n\n // if apiKey is passed in, propagate to token\n // if token is passed in, propagate to apiKey\n if (this.options.apikey) {\n this.options.token = this.options.apikey;\n } else if (this.options.token) {\n this.options.apikey = this.options.token;\n }\n\n // if no key passed in\n if (!key) {\n throw new Error(\n 'An ITEM ID or SERVICE URL is required for vectorTileLayer.'\n );\n }\n\n // set key onto \"this.options\" for use elsewhere in the module.\n if (key) {\n this.options.key = key;\n }\n\n // this.options has been set, continue on to create the layer:\n this._createLayer();\n },\n\n /**\n * Creates the maplibreGLJSLayer given using \"this.options\"\n */\n _createLayer: function () {\n loadStyle(\n this.options.key,\n this.options,\n function (error, style, styleUrl, service) {\n if (error) {\n this.fire('load-error', {\n value: error\n });\n return;\n }\n\n if (!isWebMercator(service.tileInfo.spatialReference.wkid)) {\n console.warn(\n 'This layer is not guaranteed to display properly because its service does not use the Web Mercator projection. The \"tileInfo.spatialReference\" property is:',\n service.tileInfo.spatialReference,\n '\\nMore information is available at https://github.com/maplibre/maplibre-gl-js/issues/168 and https://github.com/Esri/esri-leaflet-vector/issues/94.'\n );\n }\n\n // once style object is loaded it must be transformed to be compliant with maplibreGLJSLayer\n style = formatStyle(style, styleUrl, service, this.options.token);\n\n this._createMaplibreLayer(style);\n }.bind(this)\n );\n },\n\n _setupAttribution: function () {\n // if a custom attribution was not provided in the options,\n // then attempt to rely on the attribution of the last source in the style object\n // and add it to the map's attribution control\n // (otherwise it would have already been added by leaflet to the attribution control)\n if (!this.getAttribution()) {\n const sources = this._maplibreGL.getMaplibreMap().style.stylesheet.sources;\n const sourcesKeys = Object.keys(sources);\n this.options.attribution =\n sources[sourcesKeys[sourcesKeys.length - 1]].attribution;\n if (this._map && this._map.attributionControl) {\n // NOTE: if attribution is an empty string (or otherwise falsy) at this point it would not appear in the attribution control\n this._map.attributionControl.addAttribution(this.getAttribution());\n }\n }\n },\n\n _createMaplibreLayer: function (style) {\n this._maplibreGL = maplibreGLJSLayer({\n style: style,\n pane: this.options.pane,\n opacity: this.options.opacity,\n preserveDrawingBuffer: this.options.preserveDrawingBuffer\n });\n\n this._ready = true;\n this.fire('ready', {}, true);\n\n this._maplibreGL.on('styleLoaded', function () {\n this._setupAttribution();\n // additionally modify the style object with the user's optional style override function\n if (this.options.style && typeof this.options.style === 'function') {\n this._maplibreGL._glMap.setStyle(this.options.style(this._maplibreGL._glMap.getStyle()));\n }\n }.bind(this));\n },\n\n onAdd: function (map) {\n this._map = map;\n\n if (this._ready) {\n this._asyncAdd();\n } else {\n this.once(\n 'ready',\n function () {\n this._asyncAdd();\n },\n this\n );\n }\n },\n\n onRemove: function (map) {\n map.removeLayer(this._maplibreGL);\n },\n\n _asyncAdd: function () {\n const map = this._map;\n this._maplibreGL.addTo(map, this);\n }\n});\n\nexport function vectorTileLayer (key, options) {\n return new VectorTileLayer(key, options);\n}\n\nexport default vectorTileLayer;\n","import { Util } from 'esri-leaflet';\nimport { getBasemapStyleUrl, getAttributionData, getBasemapStyleV2Url } from './Util';\nimport { VectorTileLayer } from './VectorTileLayer';\n\nexport var VectorBasemapLayer = VectorTileLayer.extend({\n /**\n * Populates \"this.options\" to be used in the rest of the module.\n *\n * @param {string} key\n * @param {object} options optional\n */\n initialize: function (key, options) {\n // Default to the v1 service endpoint\n if (!options.version) {\n if (key.includes('/')) options.version = 2;\n else options.version = 1;\n }\n if (!key) {\n // Default style enum if none provided\n key = options.version === 1 ? 'ArcGIS:Streets' : 'arcgis/streets';\n }\n // If no API Key or token is provided (support outdated casing apiKey of apikey)\n if (!(options.apikey || options.apiKey || options.token)) {\n throw new Error('An API Key or token is required for vectorBasemapLayer.');\n }\n // Validate language param\n if (options.language) {\n if (options.version !== 2) {\n throw new Error('The language parameter is only supported by the basemap styles service v2. Provide a v2 style enumeration to use this option.');\n }\n }\n // Determine layer order\n if (!options.pane) {\n if (key.includes(':Label') || key.includes('/label')) {\n options.pane = 'esri-labels';\n } else if (key.includes(':Detail') || key.includes('/detail')) {\n options.pane = 'esri-detail';\n } else {\n // Create layer in the tilePane by default\n options.pane = 'tilePane';\n }\n }\n\n // Options has been configured, continue on to create the layer:\n VectorTileLayer.prototype.initialize.call(this, key, options);\n },\n\n /**\n * Creates the maplibreGLJSLayer using \"this.options\"\n */\n _createLayer: function () {\n let styleUrl;\n if (this.options.version && this.options.version === 2) {\n styleUrl = getBasemapStyleV2Url(this.options.key, this.options.apikey, this.options.language);\n } else {\n styleUrl = getBasemapStyleUrl(this.options.key, this.options.apikey);\n }\n this._createMaplibreLayer(styleUrl);\n },\n\n _setupAttribution: function () {\n // Set attribution\n Util.setEsriAttribution(this._map);\n\n if (this.options.key.length === 32) {\n // this is an itemId\n const sources = this._maplibreGL.getMaplibreMap().style.stylesheet.sources;\n const allAttributions = [];\n Object.keys(sources).forEach(function (key) {\n allAttributions.push(sources[key].attribution);\n if (sources[key].copyrightText && sources[key].copyrightText && sources[key].copyrightText !== '' && sources[key].attribution !== sources[key].copyrightText) {\n allAttributions.push(sources[key].copyrightText);\n }\n });\n\n this._map.attributionControl.addAttribution('' + allAttributions.join(', ') + '');\n } else {\n // this is an enum\n if (!this.options.attributionUrls) {\n this.options.attributionUrls = this._getAttributionUrls(this.options.key);\n }\n\n if (this._map && this.options.attributionUrls) {\n if (this._map.attributionControl) {\n for (\n let index = 0;\n index < this.options.attributionUrls.length;\n index++\n ) {\n const attributionUrl = this.options.attributionUrls[index];\n getAttributionData(attributionUrl, this._map);\n }\n\n this._map.attributionControl.addAttribution(\n ''\n );\n }\n Util._updateMapAttribution({ target: this._map });\n }\n }\n },\n\n /**\n * Given a key, return the attribution url(s).\n * @param {string} key\n */\n _getAttributionUrls: function (key) {\n if (key.indexOf('OSM:') === 0 || (key.indexOf('osm/') === 0)) {\n return ['https://static.arcgis.com/attribution/Vector/OpenStreetMap_v2'];\n } else if (key.indexOf('ArcGIS:Imagery') === 0 || key.indexOf('arcgis/imagery') === 0) {\n return [\n 'https://static.arcgis.com/attribution/World_Imagery',\n 'https://static.arcgis.com/attribution/Vector/World_Basemap_v2'\n ];\n }\n\n // default:\n return ['https://static.arcgis.com/attribution/Vector/World_Basemap_v2'];\n },\n\n _initPane: function () {\n if (!this._map.getPane(this.options.pane)) {\n const pane = this._map.createPane(this.options.pane);\n pane.style.pointerEvents = 'none';\n\n let zIndex = 500;\n if (this.options.pane === 'esri-detail') {\n zIndex = 250;\n } else if (this.options.pane === 'esri-labels') {\n zIndex = 300;\n }\n pane.style.zIndex = zIndex;\n }\n },\n\n onRemove: function (map) {\n map.off('moveend', Util._updateMapAttribution);\n map.removeLayer(this._maplibreGL);\n\n if (map.attributionControl) {\n const element = document.getElementsByClassName('esri-dynamic-attribution');\n\n if (element && element.length > 0) {\n const vectorAttribution = element[0].outerHTML;\n // this doesn't work, not sure why.\n map.attributionControl.removeAttribution(vectorAttribution);\n }\n }\n },\n\n _asyncAdd: function () {\n const map = this._map;\n this._initPane();\n map.on('moveend', Util._updateMapAttribution);\n this._maplibreGL.addTo(map, this);\n }\n});\n\nexport function vectorBasemapLayer (key, options) {\n return new VectorBasemapLayer(key, options);\n}\n\nexport default vectorBasemapLayer;\n","// export version\nimport packageInfo from '../package.json';\nconst version = packageInfo.version;\nexport { version as VERSION };\n\nexport { VectorBasemapLayer, vectorBasemapLayer } from './VectorBasemapLayer';\nexport { VectorTileLayer, vectorTileLayer } from './VectorTileLayer';\nexport { EsriUtil as Util } from './Util';\nexport { MaplibreGLJSLayer, maplibreGLJSLayer, setRTLTextPlugin } from './MaplibreGLLayer';\n"],"names":["loadStyle","idOrUrl","options","callback","test","loadStyleFromService","itemId","itemStyleUrl","portalUrl","loadStyleFromUrl","error","style","loadItem","item","url","loadService","service","loadStyleFromItem","serviceUrl","params","token","request","defaultStylesUrl","sanitizedServiceUrl","charAt","length","slice","defaultStyles","styleUrl","isSameTLD","url1","url2","URL","hostname","formatStyle","metadata","sourcesKeys","Object","keys","sources","sourceIndex","source","indexOf","replace","tiles","minzoom","minLOD","tileInfo","lods","level","maxzoom","maxLOD","lastSource","attribution","copyrightText","layerIndex","layers","layer","layout","sprite","console","warn","glyphs","getAttributionData","map","Support","cors","attributions","_esriAttributions","c","contributors","contributor","i","coverageAreas","coverageArea","southWest","latLng","bbox","northEast","push","score","bounds","latLngBounds","minZoom","zoomMin","maxZoom","zoomMax","sort","a","b","obj","target","Util","_updateMapAttribution","WEB_MERCATOR_WKIDS","EsriUtil","MaplibreGLJSLayer","Layer","extend","updateInterval","padding","interactive","pane","initialize","setOptions","this","_throttledUpdate","throttle","_update","onAdd","_container","_initContainer","paneName","getPaneName","getPane","appendChild","_initGL","_offset","_map","containerPointToLayerPoint","zoomAnimation","DomEvent","on","_proxy","DomUtil","TRANSITION_END","_transitionEnd","onRemove","off","removeChild","_glMap","remove","getEvents","move","zoomanim","_animateZoom","zoom","_pinchZoom","zoomstart","_zoomStart","zoomend","_zoomEnd","resize","_resize","getMaplibreMap","getCanvas","getSize","multiplyBy","getOpacity","opacity","setOpacity","getBounds","halfSize","center","latLngToContainerPoint","getCenter","containerPointToLatLng","subtract","add","getContainer","create","size","offset","width","x","height","y","topLeft","setPosition","container","lng","lat","getZoom","attributionControl","maplibregl","Map","once","res","fire","bind","transform","latRange","maxValidLatitude","Infinity","_transformGL","_canvas","canvas","_actualCanvas","addClass","className","e","_zooming","gl","undefined","update","tr","LngLat","convert","jumpTo","scale","getZoomScale","viewHalf","_divideBy","project","_subtract","_add","_getMapPanePos","_round","getNorthWest","setTransform","requestAnimFrame","maplibreGLJSLayer","VectorTileLayer","preserveDrawingBuffer","key","apiKey","apikey","Error","_createLayer","wkid","value","spatialReference","_createMaplibreLayer","_setupAttribution","getAttribution","_maplibreGL","stylesheet","addAttribution","_ready","setStyle","getStyle","_asyncAdd","removeLayer","addTo","VectorBasemapLayer","version","includes","language","prototype","call","startsWith","getBasemapStyleV2Url","getBasemapStyleUrl","setEsriAttribution","allAttributions","forEach","join","attributionUrls","_getAttributionUrls","index","_initPane","createPane","pointerEvents","zIndex","element","document","getElementsByClassName","vectorAttribution","outerH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