@deck.gl/mapbox 9.0.2 → 9.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -87,7 +87,7 @@ export function removeDeckInstance(map) {
87
87
  export function getInterleavedProps(currProps) {
88
88
  const nextProps = {
89
89
  ...currProps,
90
- // TODO: import these defaults from a single source of truth
90
+ // TODO: remove with withParametersWebGL
91
91
  parameters: {
92
92
  depthMask: true,
93
93
  depthTest: true,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["index.js", "mapbox-overlay.js", "deck-utils.js", "resolve-layers.js", "mapbox-layer.js"],
4
- "sourcesContent": ["export { default as MapboxOverlay } from \"./mapbox-overlay.js\";\n", "import { Deck, assert } from '@deck.gl/core';\nimport { getViewState, getDeckInstance, removeDeckInstance, getInterleavedProps } from \"./deck-utils.js\";\nimport { log } from '@deck.gl/core';\nimport { resolveLayers } from \"./resolve-layers.js\";\n/**\n * Implements Mapbox [IControl](https://docs.mapbox.com/mapbox-gl-js/api/markers/#icontrol) interface\n * Renders deck.gl layers over the base map and automatically synchronizes with the map's camera\n */\nexport default class MapboxOverlay {\n constructor(props) {\n this._handleStyleChange = () => {\n resolveLayers(this._map, this._deck, this._props.layers, this._props.layers);\n };\n this._updateContainerSize = () => {\n if (this._map && this._container) {\n const { clientWidth, clientHeight } = this._map.getContainer();\n Object.assign(this._container.style, {\n width: `${clientWidth}px`,\n height: `${clientHeight}px`\n });\n }\n };\n this._updateViewState = () => {\n const deck = this._deck;\n if (deck) {\n // @ts-ignore (2345) map is always defined if deck is\n deck.setProps({ viewState: getViewState(this._map) });\n // Redraw immediately if view state has changed\n if (deck.isInitialized) {\n deck.redraw();\n }\n }\n };\n // eslint-disable-next-line complexity\n this._handleMouseEvent = (event) => {\n const deck = this._deck;\n if (!deck || !deck.isInitialized) {\n return;\n }\n const mockEvent = {\n type: event.type,\n offsetCenter: event.point,\n srcEvent: event\n };\n const lastDown = this._lastMouseDownPoint;\n if (!event.point && lastDown) {\n // drag* events do not contain a `point` field\n mockEvent.deltaX = event.originalEvent.clientX - lastDown.clientX;\n mockEvent.deltaY = event.originalEvent.clientY - lastDown.clientY;\n mockEvent.offsetCenter = {\n x: lastDown.x + mockEvent.deltaX,\n y: lastDown.y + mockEvent.deltaY\n };\n }\n switch (mockEvent.type) {\n case 'mousedown':\n deck._onPointerDown(mockEvent);\n this._lastMouseDownPoint = {\n ...event.point,\n clientX: event.originalEvent.clientX,\n clientY: event.originalEvent.clientY\n };\n break;\n case 'dragstart':\n mockEvent.type = 'panstart';\n deck._onEvent(mockEvent);\n break;\n case 'drag':\n mockEvent.type = 'panmove';\n deck._onEvent(mockEvent);\n break;\n case 'dragend':\n mockEvent.type = 'panend';\n deck._onEvent(mockEvent);\n break;\n case 'click':\n mockEvent.tapCount = 1;\n deck._onEvent(mockEvent);\n break;\n case 'dblclick':\n mockEvent.type = 'click';\n mockEvent.tapCount = 2;\n deck._onEvent(mockEvent);\n break;\n case 'mousemove':\n mockEvent.type = 'pointermove';\n deck._onPointerMove(mockEvent);\n break;\n case 'mouseout':\n mockEvent.type = 'pointerleave';\n deck._onPointerMove(mockEvent);\n break;\n default:\n return;\n }\n };\n const { interleaved = false, ...otherProps } = props;\n this._interleaved = interleaved;\n this._props = otherProps;\n }\n /** Update (partial) props of the underlying Deck instance. */\n setProps(props) {\n if (this._interleaved && props.layers) {\n resolveLayers(this._map, this._deck, this._props.layers, props.layers);\n }\n Object.assign(this._props, props);\n if (this._deck) {\n this._deck.setProps(this._interleaved ? getInterleavedProps(this._props) : this._props);\n }\n }\n /** Called when the control is added to a map */\n onAdd(map) {\n this._map = map;\n return this._interleaved ? this._onAddInterleaved(map) : this._onAddOverlaid(map);\n }\n _onAddOverlaid(map) {\n /* global document */\n const container = document.createElement('div');\n Object.assign(container.style, {\n position: 'absolute',\n left: 0,\n top: 0,\n textAlign: 'initial',\n pointerEvents: 'none'\n });\n this._container = container;\n this._deck = new Deck({\n ...this._props,\n parent: container,\n viewState: getViewState(map)\n });\n map.on('resize', this._updateContainerSize);\n map.on('render', this._updateViewState);\n map.on('mousedown', this._handleMouseEvent);\n map.on('dragstart', this._handleMouseEvent);\n map.on('drag', this._handleMouseEvent);\n map.on('dragend', this._handleMouseEvent);\n map.on('mousemove', this._handleMouseEvent);\n map.on('mouseout', this._handleMouseEvent);\n map.on('click', this._handleMouseEvent);\n map.on('dblclick', this._handleMouseEvent);\n this._updateContainerSize();\n return container;\n }\n _onAddInterleaved(map) {\n // @ts-ignore non-public map property\n const gl = map.painter.context.gl;\n if (gl instanceof WebGLRenderingContext) {\n log.warn('Incompatible basemap library. See: https://deck.gl/docs/api-reference/mapbox/overview#compatibility')();\n }\n this._deck = getDeckInstance({\n map,\n gl,\n deck: new Deck({\n ...this._props,\n gl\n })\n });\n map.on('styledata', this._handleStyleChange);\n resolveLayers(map, this._deck, [], this._props.layers);\n return document.createElement('div');\n }\n /** Called when the control is removed from a map */\n onRemove() {\n const map = this._map;\n if (map) {\n if (this._interleaved) {\n this._onRemoveInterleaved(map);\n }\n else {\n this._onRemoveOverlaid(map);\n }\n }\n this._deck = undefined;\n this._map = undefined;\n this._container = undefined;\n }\n _onRemoveOverlaid(map) {\n map.off('resize', this._updateContainerSize);\n map.off('render', this._updateViewState);\n map.off('mousedown', this._handleMouseEvent);\n map.off('dragstart', this._handleMouseEvent);\n map.off('drag', this._handleMouseEvent);\n map.off('dragend', this._handleMouseEvent);\n map.off('mousemove', this._handleMouseEvent);\n map.off('mouseout', this._handleMouseEvent);\n map.off('click', this._handleMouseEvent);\n map.off('dblclick', this._handleMouseEvent);\n this._deck?.finalize();\n }\n _onRemoveInterleaved(map) {\n map.off('styledata', this._handleStyleChange);\n resolveLayers(map, this._deck, this._props.layers, []);\n removeDeckInstance(map);\n }\n getDefaultPosition() {\n return 'top-left';\n }\n /** Forwards the Deck.pickObject method */\n pickObject(params) {\n assert(this._deck);\n return this._deck.pickObject(params);\n }\n /** Forwards the Deck.pickMultipleObjects method */\n pickMultipleObjects(params) {\n assert(this._deck);\n return this._deck.pickMultipleObjects(params);\n }\n /** Forwards the Deck.pickObjects method */\n pickObjects(params) {\n assert(this._deck);\n return this._deck.pickObjects(params);\n }\n /** Remove from map and releases all resources */\n finalize() {\n if (this._map) {\n this._map.removeControl(this);\n }\n }\n /** If interleaved: true, returns base map's canvas, otherwise forwards the Deck.getCanvas method. */\n getCanvas() {\n if (!this._map) {\n return null;\n }\n return this._interleaved ? this._map.getCanvas() : this._deck.getCanvas();\n }\n}\n", "import { Deck, WebMercatorViewport, MapView, _flatten as flatten } from '@deck.gl/core';\nimport { lngLatToWorld, unitsPerMeter } from '@math.gl/web-mercator';\nimport { GL } from '@luma.gl/constants';\n// Mercator constants\nconst TILE_SIZE = 512;\nconst DEGREES_TO_RADIANS = Math.PI / 180;\n// Create an interleaved deck instance.\nexport function getDeckInstance({ map, gl, deck }) {\n // Only create one deck instance per context\n if (map.__deck) {\n return map.__deck;\n }\n // Only initialize certain props once per context\n const customRender = deck?.props._customRender;\n const onLoad = deck?.props.onLoad;\n const deckProps = getInterleavedProps({\n ...deck?.props,\n _customRender: () => {\n map.triggerRepaint();\n // customRender may be subscribed by DeckGL React component to update child props\n // make sure it is still called\n // Hack - do not pass a redraw reason here to prevent the React component from clearing the context\n // Rerender will be triggered by MapboxLayer's render()\n customRender?.('');\n }\n });\n let deckInstance;\n if (!deck || deck.props.gl === gl) {\n // If deck isn't defined (Internal MapboxLayer use case),\n // or if deck is defined and is using the WebGLContext created by mapbox (MapboxOverlay and External MapboxLayer use case),\n // block deck from setting the canvas size, and use the map's viewState to drive deck.\n // Otherwise, we use deck's viewState to drive the map.\n Object.assign(deckProps, {\n gl,\n width: null,\n height: null,\n touchAction: 'unset',\n viewState: getViewState(map)\n });\n if (deck?.isInitialized) {\n watchMapMove(deck, map);\n }\n else {\n deckProps.onLoad = () => {\n onLoad?.();\n watchMapMove(deckInstance, map);\n };\n }\n }\n if (deck) {\n deckInstance = deck;\n deck.setProps(deckProps);\n deck.userData.isExternal = true;\n }\n else {\n deckInstance = new Deck(deckProps);\n map.on('remove', () => {\n removeDeckInstance(map);\n });\n }\n deckInstance.userData.mapboxLayers = new Set();\n // (deckInstance.userData as UserData).mapboxVersion = getMapboxVersion(map);\n map.__deck = deckInstance;\n map.on('render', () => {\n if (deckInstance.isInitialized)\n afterRender(deckInstance, map);\n });\n return deckInstance;\n}\nfunction watchMapMove(deck, map) {\n const _handleMapMove = () => {\n if (deck.isInitialized) {\n // call view state methods\n onMapMove(deck, map);\n }\n else {\n // deregister itself when deck is finalized\n map.off('move', _handleMapMove);\n }\n };\n map.on('move', _handleMapMove);\n}\nexport function removeDeckInstance(map) {\n map.__deck?.finalize();\n map.__deck = null;\n}\nexport function getInterleavedProps(currProps) {\n const nextProps = {\n ...currProps,\n // TODO: import these defaults from a single source of truth\n parameters: {\n depthMask: true,\n depthTest: true,\n blend: true,\n blendFunc: [770, 771, 1, 771],\n polygonOffsetFill: true,\n depthFunc: 515,\n blendEquation: 32774,\n ...currProps.parameters\n },\n views: currProps.views || [new MapView({ id: 'mapbox' })]\n };\n return nextProps;\n}\nexport function addLayer(deck, layer) {\n deck.userData.mapboxLayers.add(layer);\n updateLayers(deck);\n}\nexport function removeLayer(deck, layer) {\n deck.userData.mapboxLayers.delete(layer);\n updateLayers(deck);\n}\nexport function updateLayer(deck, layer) {\n updateLayers(deck);\n}\nexport function drawLayer(deck, map, layer) {\n let { currentViewport } = deck.userData;\n let clearStack = false;\n if (!currentViewport) {\n // This is the first layer drawn in this render cycle.\n // Generate viewport from the current map state.\n currentViewport = getViewport(deck, map, true);\n deck.userData.currentViewport = currentViewport;\n clearStack = true;\n }\n if (!deck.isInitialized) {\n return;\n }\n deck._drawLayers('mapbox-repaint', {\n viewports: [currentViewport],\n layerFilter: ({ layer: deckLayer }) => layer.id === deckLayer.id || deckLayer.props.operation.includes('terrain'),\n clearStack,\n clearCanvas: false\n });\n}\nexport function getViewState(map) {\n const { lng, lat } = map.getCenter();\n const viewState = {\n // Longitude returned by getCenter can be outside of [-180, 180] when zooming near the anti meridian\n // https://github.com/visgl/deck.gl/issues/6894\n longitude: ((lng + 540) % 360) - 180,\n latitude: lat,\n zoom: map.getZoom(),\n bearing: map.getBearing(),\n pitch: map.getPitch(),\n padding: map.getPadding(),\n repeat: map.getRenderWorldCopies()\n };\n if (map.getTerrain?.()) {\n // When the base map has terrain, we need to target the camera at the terrain surface\n centerCameraOnTerrain(map, viewState);\n }\n return viewState;\n}\nfunction centerCameraOnTerrain(map, viewState) {\n if (map.getFreeCameraOptions) {\n // mapbox-gl v2\n const { position } = map.getFreeCameraOptions();\n if (!position || position.z === undefined) {\n return;\n }\n // @ts-ignore transform is not typed\n const height = map.transform.height;\n const { longitude, latitude, pitch } = viewState;\n // Convert mapbox mercator coordinate to deck common space\n const cameraX = position.x * TILE_SIZE;\n const cameraY = (1 - position.y) * TILE_SIZE;\n const cameraZ = position.z * TILE_SIZE;\n // Mapbox manipulates zoom in terrain mode, see discussion here: https://github.com/mapbox/mapbox-gl-js/issues/12040\n const center = lngLatToWorld([longitude, latitude]);\n const dx = cameraX - center[0];\n const dy = cameraY - center[1];\n const cameraToCenterDistanceGround = Math.sqrt(dx * dx + dy * dy);\n const pitchRadians = pitch * DEGREES_TO_RADIANS;\n const altitudePixels = 1.5 * height;\n const scale = pitchRadians < 0.001\n ? // Pitch angle too small to deduce the look at point, assume elevation is 0\n (altitudePixels * Math.cos(pitchRadians)) / cameraZ\n : (altitudePixels * Math.sin(pitchRadians)) / cameraToCenterDistanceGround;\n viewState.zoom = Math.log2(scale);\n const cameraZFromSurface = (altitudePixels * Math.cos(pitchRadians)) / scale;\n const surfaceElevation = cameraZ - cameraZFromSurface;\n viewState.position = [0, 0, surfaceElevation / unitsPerMeter(latitude)];\n }\n // @ts-ignore transform is not typed\n else if (typeof map.transform.elevation === 'number') {\n // maplibre-gl\n // @ts-ignore transform is not typed\n viewState.position = [0, 0, map.transform.elevation];\n }\n}\n// function getMapboxVersion(map: Map): {minor: number; major: number} {\n// // parse mapbox version string\n// let major = 0;\n// let minor = 0;\n// // @ts-ignore (2339) undefined property\n// const version: string = map.version;\n// if (version) {\n// [major, minor] = version.split('.').slice(0, 2).map(Number);\n// }\n// return {major, minor};\n// }\nfunction getViewport(deck, map, useMapboxProjection = true) {\n return new WebMercatorViewport({\n id: 'mapbox',\n x: 0,\n y: 0,\n width: deck.width,\n height: deck.height,\n ...getViewState(map),\n nearZMultiplier: useMapboxProjection\n ? // match mapbox-gl@>=1.3.0's projection matrix\n 0.02\n : // use deck.gl's own default\n 0.1,\n nearZ: map.transform._nearZ / map.transform.height,\n farZ: map.transform._farZ / map.transform.height\n });\n}\nfunction afterRender(deck, map) {\n const { mapboxLayers, isExternal } = deck.userData;\n if (isExternal) {\n // Draw non-Mapbox layers\n const mapboxLayerIds = Array.from(mapboxLayers, layer => layer.id);\n const deckLayers = flatten(deck.props.layers, Boolean);\n const hasNonMapboxLayers = deckLayers.some(layer => layer && !mapboxLayerIds.includes(layer.id));\n let viewports = deck.getViewports();\n const mapboxViewportIdx = viewports.findIndex(vp => vp.id === 'mapbox');\n const hasNonMapboxViews = viewports.length > 1 || mapboxViewportIdx < 0;\n if (hasNonMapboxLayers || hasNonMapboxViews) {\n if (mapboxViewportIdx >= 0) {\n viewports = viewports.slice();\n viewports[mapboxViewportIdx] = getViewport(deck, map, false);\n }\n deck._drawLayers('mapbox-repaint', {\n viewports,\n layerFilter: params => (!deck.props.layerFilter || deck.props.layerFilter(params)) &&\n (params.viewport.id !== 'mapbox' || !mapboxLayerIds.includes(params.layer.id)),\n clearCanvas: false\n });\n }\n }\n // End of render cycle, clear generated viewport\n deck.userData.currentViewport = null;\n}\nfunction onMapMove(deck, map) {\n deck.setProps({\n viewState: getViewState(map)\n });\n // Camera changed, will trigger a map repaint right after this\n // Clear any change flag triggered by setting viewState so that deck does not request\n // a second repaint\n deck.needsRedraw({ clearRedrawFlags: true });\n}\nfunction updateLayers(deck) {\n if (deck.userData.isExternal) {\n return;\n }\n const layers = [];\n deck.userData.mapboxLayers.forEach(deckLayer => {\n const LayerType = deckLayer.props.type;\n const layer = new LayerType(deckLayer.props);\n layers.push(layer);\n });\n deck.setProps({ layers });\n}\n", "import { _flatten as flatten } from '@deck.gl/core';\nimport MapboxLayer from \"./mapbox-layer.js\";\nconst UNDEFINED_BEFORE_ID = '__UNDEFINED__';\n/** Insert Deck layers into the mapbox Map according to the user-defined order */\n// eslint-disable-next-line complexity, max-statements\nexport function resolveLayers(map, deck, oldLayers, newLayers) {\n // Wait until map style is loaded\n // @ts-ignore non-public map property\n if (!map || !deck || !map.style || !map.style._loaded) {\n return;\n }\n const layers = flatten(newLayers, Boolean);\n if (oldLayers !== newLayers) {\n // Step 1: remove layers that no longer exist\n const prevLayers = flatten(oldLayers, Boolean);\n const prevLayerIds = new Set(prevLayers.map(l => l.id));\n for (const layer of layers) {\n prevLayerIds.delete(layer.id);\n }\n for (const id of prevLayerIds) {\n if (map.getLayer(id)) {\n map.removeLayer(id);\n }\n }\n }\n // Step 2: add missing layers\n for (const layer of layers) {\n const mapboxLayer = map.getLayer(layer.id);\n if (mapboxLayer) {\n // @ts-expect-error not typed\n mapboxLayer.implementation.setProps(layer.props);\n }\n else {\n map.addLayer(new MapboxLayer({ id: layer.id, deck }), \n // @ts-expect-error beforeId is not defined in LayerProps\n layer.props.beforeId);\n }\n }\n // Step 3: check the order of layers\n // If beforeId is defined, the deck layer should always render before the mapbox layer [beforeId]\n // If beforeId is not defined, the deck layer should appear after all mapbox layers\n // When two deck layers share the same beforeId, they are rendered in the order that is passed into Deck props.layers\n // @ts-ignore non-public map property\n const mapLayers = map.style._order;\n // Group deck layers by beforeId\n const layerGroups = {};\n for (const layer of layers) {\n // @ts-expect-error beforeId is not defined in LayerProps\n let { beforeId } = layer.props;\n if (!beforeId || !mapLayers.includes(beforeId)) {\n beforeId = UNDEFINED_BEFORE_ID;\n }\n layerGroups[beforeId] = layerGroups[beforeId] || [];\n layerGroups[beforeId].push(layer.id);\n }\n for (const beforeId in layerGroups) {\n const layerGroup = layerGroups[beforeId];\n let lastLayerIndex = beforeId === UNDEFINED_BEFORE_ID ? mapLayers.length : mapLayers.indexOf(beforeId);\n let lastLayerId = beforeId === UNDEFINED_BEFORE_ID ? undefined : beforeId;\n for (let i = layerGroup.length - 1; i >= 0; i--) {\n const layerId = layerGroup[i];\n const layerIndex = mapLayers.indexOf(layerId);\n if (layerIndex !== lastLayerIndex - 1) {\n map.moveLayer(layerId, lastLayerId);\n if (layerIndex > lastLayerIndex) {\n // The last layer's index have changed\n lastLayerIndex++;\n }\n }\n lastLayerIndex--;\n lastLayerId = layerId;\n }\n }\n}\n", "import { getDeckInstance, addLayer, removeLayer, updateLayer, drawLayer } from \"./deck-utils.js\";\nexport default class MapboxLayer {\n /* eslint-disable no-this-before-super */\n constructor(props) {\n if (!props.id) {\n throw new Error('Layer must have an unique id');\n }\n this.id = props.id;\n this.type = 'custom';\n this.renderingMode = props.renderingMode || '3d';\n this.map = null;\n this.deck = null;\n this.props = props;\n }\n /* Mapbox custom layer methods */\n onAdd(map, gl) {\n this.map = map;\n this.deck = getDeckInstance({ map, gl, deck: this.props.deck });\n addLayer(this.deck, this);\n }\n onRemove() {\n if (this.deck) {\n removeLayer(this.deck, this);\n }\n }\n setProps(props) {\n // id cannot be changed\n Object.assign(this.props, props, { id: this.id });\n // safe guard in case setProps is called before onAdd\n if (this.deck) {\n updateLayer(this.deck, this);\n }\n }\n render() {\n drawLayer(this.deck, this.map, this);\n }\n}\n"],
4
+ "sourcesContent": ["export { default as MapboxOverlay } from \"./mapbox-overlay.js\";\n", "import { Deck, assert } from '@deck.gl/core';\nimport { getViewState, getDeckInstance, removeDeckInstance, getInterleavedProps } from \"./deck-utils.js\";\nimport { log } from '@deck.gl/core';\nimport { resolveLayers } from \"./resolve-layers.js\";\n/**\n * Implements Mapbox [IControl](https://docs.mapbox.com/mapbox-gl-js/api/markers/#icontrol) interface\n * Renders deck.gl layers over the base map and automatically synchronizes with the map's camera\n */\nexport default class MapboxOverlay {\n constructor(props) {\n this._handleStyleChange = () => {\n resolveLayers(this._map, this._deck, this._props.layers, this._props.layers);\n };\n this._updateContainerSize = () => {\n if (this._map && this._container) {\n const { clientWidth, clientHeight } = this._map.getContainer();\n Object.assign(this._container.style, {\n width: `${clientWidth}px`,\n height: `${clientHeight}px`\n });\n }\n };\n this._updateViewState = () => {\n const deck = this._deck;\n if (deck) {\n // @ts-ignore (2345) map is always defined if deck is\n deck.setProps({ viewState: getViewState(this._map) });\n // Redraw immediately if view state has changed\n if (deck.isInitialized) {\n deck.redraw();\n }\n }\n };\n // eslint-disable-next-line complexity\n this._handleMouseEvent = (event) => {\n const deck = this._deck;\n if (!deck || !deck.isInitialized) {\n return;\n }\n const mockEvent = {\n type: event.type,\n offsetCenter: event.point,\n srcEvent: event\n };\n const lastDown = this._lastMouseDownPoint;\n if (!event.point && lastDown) {\n // drag* events do not contain a `point` field\n mockEvent.deltaX = event.originalEvent.clientX - lastDown.clientX;\n mockEvent.deltaY = event.originalEvent.clientY - lastDown.clientY;\n mockEvent.offsetCenter = {\n x: lastDown.x + mockEvent.deltaX,\n y: lastDown.y + mockEvent.deltaY\n };\n }\n switch (mockEvent.type) {\n case 'mousedown':\n deck._onPointerDown(mockEvent);\n this._lastMouseDownPoint = {\n ...event.point,\n clientX: event.originalEvent.clientX,\n clientY: event.originalEvent.clientY\n };\n break;\n case 'dragstart':\n mockEvent.type = 'panstart';\n deck._onEvent(mockEvent);\n break;\n case 'drag':\n mockEvent.type = 'panmove';\n deck._onEvent(mockEvent);\n break;\n case 'dragend':\n mockEvent.type = 'panend';\n deck._onEvent(mockEvent);\n break;\n case 'click':\n mockEvent.tapCount = 1;\n deck._onEvent(mockEvent);\n break;\n case 'dblclick':\n mockEvent.type = 'click';\n mockEvent.tapCount = 2;\n deck._onEvent(mockEvent);\n break;\n case 'mousemove':\n mockEvent.type = 'pointermove';\n deck._onPointerMove(mockEvent);\n break;\n case 'mouseout':\n mockEvent.type = 'pointerleave';\n deck._onPointerMove(mockEvent);\n break;\n default:\n return;\n }\n };\n const { interleaved = false, ...otherProps } = props;\n this._interleaved = interleaved;\n this._props = otherProps;\n }\n /** Update (partial) props of the underlying Deck instance. */\n setProps(props) {\n if (this._interleaved && props.layers) {\n resolveLayers(this._map, this._deck, this._props.layers, props.layers);\n }\n Object.assign(this._props, props);\n if (this._deck) {\n this._deck.setProps(this._interleaved ? getInterleavedProps(this._props) : this._props);\n }\n }\n /** Called when the control is added to a map */\n onAdd(map) {\n this._map = map;\n return this._interleaved ? this._onAddInterleaved(map) : this._onAddOverlaid(map);\n }\n _onAddOverlaid(map) {\n /* global document */\n const container = document.createElement('div');\n Object.assign(container.style, {\n position: 'absolute',\n left: 0,\n top: 0,\n textAlign: 'initial',\n pointerEvents: 'none'\n });\n this._container = container;\n this._deck = new Deck({\n ...this._props,\n parent: container,\n viewState: getViewState(map)\n });\n map.on('resize', this._updateContainerSize);\n map.on('render', this._updateViewState);\n map.on('mousedown', this._handleMouseEvent);\n map.on('dragstart', this._handleMouseEvent);\n map.on('drag', this._handleMouseEvent);\n map.on('dragend', this._handleMouseEvent);\n map.on('mousemove', this._handleMouseEvent);\n map.on('mouseout', this._handleMouseEvent);\n map.on('click', this._handleMouseEvent);\n map.on('dblclick', this._handleMouseEvent);\n this._updateContainerSize();\n return container;\n }\n _onAddInterleaved(map) {\n // @ts-ignore non-public map property\n const gl = map.painter.context.gl;\n if (gl instanceof WebGLRenderingContext) {\n log.warn('Incompatible basemap library. See: https://deck.gl/docs/api-reference/mapbox/overview#compatibility')();\n }\n this._deck = getDeckInstance({\n map,\n gl,\n deck: new Deck({\n ...this._props,\n gl\n })\n });\n map.on('styledata', this._handleStyleChange);\n resolveLayers(map, this._deck, [], this._props.layers);\n return document.createElement('div');\n }\n /** Called when the control is removed from a map */\n onRemove() {\n const map = this._map;\n if (map) {\n if (this._interleaved) {\n this._onRemoveInterleaved(map);\n }\n else {\n this._onRemoveOverlaid(map);\n }\n }\n this._deck = undefined;\n this._map = undefined;\n this._container = undefined;\n }\n _onRemoveOverlaid(map) {\n map.off('resize', this._updateContainerSize);\n map.off('render', this._updateViewState);\n map.off('mousedown', this._handleMouseEvent);\n map.off('dragstart', this._handleMouseEvent);\n map.off('drag', this._handleMouseEvent);\n map.off('dragend', this._handleMouseEvent);\n map.off('mousemove', this._handleMouseEvent);\n map.off('mouseout', this._handleMouseEvent);\n map.off('click', this._handleMouseEvent);\n map.off('dblclick', this._handleMouseEvent);\n this._deck?.finalize();\n }\n _onRemoveInterleaved(map) {\n map.off('styledata', this._handleStyleChange);\n resolveLayers(map, this._deck, this._props.layers, []);\n removeDeckInstance(map);\n }\n getDefaultPosition() {\n return 'top-left';\n }\n /** Forwards the Deck.pickObject method */\n pickObject(params) {\n assert(this._deck);\n return this._deck.pickObject(params);\n }\n /** Forwards the Deck.pickMultipleObjects method */\n pickMultipleObjects(params) {\n assert(this._deck);\n return this._deck.pickMultipleObjects(params);\n }\n /** Forwards the Deck.pickObjects method */\n pickObjects(params) {\n assert(this._deck);\n return this._deck.pickObjects(params);\n }\n /** Remove from map and releases all resources */\n finalize() {\n if (this._map) {\n this._map.removeControl(this);\n }\n }\n /** If interleaved: true, returns base map's canvas, otherwise forwards the Deck.getCanvas method. */\n getCanvas() {\n if (!this._map) {\n return null;\n }\n return this._interleaved ? this._map.getCanvas() : this._deck.getCanvas();\n }\n}\n", "import { Deck, WebMercatorViewport, MapView, _flatten as flatten } from '@deck.gl/core';\nimport { lngLatToWorld, unitsPerMeter } from '@math.gl/web-mercator';\nimport { GL } from '@luma.gl/constants';\n// Mercator constants\nconst TILE_SIZE = 512;\nconst DEGREES_TO_RADIANS = Math.PI / 180;\n// Create an interleaved deck instance.\nexport function getDeckInstance({ map, gl, deck }) {\n // Only create one deck instance per context\n if (map.__deck) {\n return map.__deck;\n }\n // Only initialize certain props once per context\n const customRender = deck?.props._customRender;\n const onLoad = deck?.props.onLoad;\n const deckProps = getInterleavedProps({\n ...deck?.props,\n _customRender: () => {\n map.triggerRepaint();\n // customRender may be subscribed by DeckGL React component to update child props\n // make sure it is still called\n // Hack - do not pass a redraw reason here to prevent the React component from clearing the context\n // Rerender will be triggered by MapboxLayer's render()\n customRender?.('');\n }\n });\n let deckInstance;\n if (!deck || deck.props.gl === gl) {\n // If deck isn't defined (Internal MapboxLayer use case),\n // or if deck is defined and is using the WebGLContext created by mapbox (MapboxOverlay and External MapboxLayer use case),\n // block deck from setting the canvas size, and use the map's viewState to drive deck.\n // Otherwise, we use deck's viewState to drive the map.\n Object.assign(deckProps, {\n gl,\n width: null,\n height: null,\n touchAction: 'unset',\n viewState: getViewState(map)\n });\n if (deck?.isInitialized) {\n watchMapMove(deck, map);\n }\n else {\n deckProps.onLoad = () => {\n onLoad?.();\n watchMapMove(deckInstance, map);\n };\n }\n }\n if (deck) {\n deckInstance = deck;\n deck.setProps(deckProps);\n deck.userData.isExternal = true;\n }\n else {\n deckInstance = new Deck(deckProps);\n map.on('remove', () => {\n removeDeckInstance(map);\n });\n }\n deckInstance.userData.mapboxLayers = new Set();\n // (deckInstance.userData as UserData).mapboxVersion = getMapboxVersion(map);\n map.__deck = deckInstance;\n map.on('render', () => {\n if (deckInstance.isInitialized)\n afterRender(deckInstance, map);\n });\n return deckInstance;\n}\nfunction watchMapMove(deck, map) {\n const _handleMapMove = () => {\n if (deck.isInitialized) {\n // call view state methods\n onMapMove(deck, map);\n }\n else {\n // deregister itself when deck is finalized\n map.off('move', _handleMapMove);\n }\n };\n map.on('move', _handleMapMove);\n}\nexport function removeDeckInstance(map) {\n map.__deck?.finalize();\n map.__deck = null;\n}\nexport function getInterleavedProps(currProps) {\n const nextProps = {\n ...currProps,\n // TODO: remove with withParametersWebGL\n parameters: {\n depthMask: true,\n depthTest: true,\n blend: true,\n blendFunc: [770, 771, 1, 771],\n polygonOffsetFill: true,\n depthFunc: 515,\n blendEquation: 32774,\n ...currProps.parameters\n },\n views: currProps.views || [new MapView({ id: 'mapbox' })]\n };\n return nextProps;\n}\nexport function addLayer(deck, layer) {\n deck.userData.mapboxLayers.add(layer);\n updateLayers(deck);\n}\nexport function removeLayer(deck, layer) {\n deck.userData.mapboxLayers.delete(layer);\n updateLayers(deck);\n}\nexport function updateLayer(deck, layer) {\n updateLayers(deck);\n}\nexport function drawLayer(deck, map, layer) {\n let { currentViewport } = deck.userData;\n let clearStack = false;\n if (!currentViewport) {\n // This is the first layer drawn in this render cycle.\n // Generate viewport from the current map state.\n currentViewport = getViewport(deck, map, true);\n deck.userData.currentViewport = currentViewport;\n clearStack = true;\n }\n if (!deck.isInitialized) {\n return;\n }\n deck._drawLayers('mapbox-repaint', {\n viewports: [currentViewport],\n layerFilter: ({ layer: deckLayer }) => layer.id === deckLayer.id || deckLayer.props.operation.includes('terrain'),\n clearStack,\n clearCanvas: false\n });\n}\nexport function getViewState(map) {\n const { lng, lat } = map.getCenter();\n const viewState = {\n // Longitude returned by getCenter can be outside of [-180, 180] when zooming near the anti meridian\n // https://github.com/visgl/deck.gl/issues/6894\n longitude: ((lng + 540) % 360) - 180,\n latitude: lat,\n zoom: map.getZoom(),\n bearing: map.getBearing(),\n pitch: map.getPitch(),\n padding: map.getPadding(),\n repeat: map.getRenderWorldCopies()\n };\n if (map.getTerrain?.()) {\n // When the base map has terrain, we need to target the camera at the terrain surface\n centerCameraOnTerrain(map, viewState);\n }\n return viewState;\n}\nfunction centerCameraOnTerrain(map, viewState) {\n if (map.getFreeCameraOptions) {\n // mapbox-gl v2\n const { position } = map.getFreeCameraOptions();\n if (!position || position.z === undefined) {\n return;\n }\n // @ts-ignore transform is not typed\n const height = map.transform.height;\n const { longitude, latitude, pitch } = viewState;\n // Convert mapbox mercator coordinate to deck common space\n const cameraX = position.x * TILE_SIZE;\n const cameraY = (1 - position.y) * TILE_SIZE;\n const cameraZ = position.z * TILE_SIZE;\n // Mapbox manipulates zoom in terrain mode, see discussion here: https://github.com/mapbox/mapbox-gl-js/issues/12040\n const center = lngLatToWorld([longitude, latitude]);\n const dx = cameraX - center[0];\n const dy = cameraY - center[1];\n const cameraToCenterDistanceGround = Math.sqrt(dx * dx + dy * dy);\n const pitchRadians = pitch * DEGREES_TO_RADIANS;\n const altitudePixels = 1.5 * height;\n const scale = pitchRadians < 0.001\n ? // Pitch angle too small to deduce the look at point, assume elevation is 0\n (altitudePixels * Math.cos(pitchRadians)) / cameraZ\n : (altitudePixels * Math.sin(pitchRadians)) / cameraToCenterDistanceGround;\n viewState.zoom = Math.log2(scale);\n const cameraZFromSurface = (altitudePixels * Math.cos(pitchRadians)) / scale;\n const surfaceElevation = cameraZ - cameraZFromSurface;\n viewState.position = [0, 0, surfaceElevation / unitsPerMeter(latitude)];\n }\n // @ts-ignore transform is not typed\n else if (typeof map.transform.elevation === 'number') {\n // maplibre-gl\n // @ts-ignore transform is not typed\n viewState.position = [0, 0, map.transform.elevation];\n }\n}\n// function getMapboxVersion(map: Map): {minor: number; major: number} {\n// // parse mapbox version string\n// let major = 0;\n// let minor = 0;\n// // @ts-ignore (2339) undefined property\n// const version: string = map.version;\n// if (version) {\n// [major, minor] = version.split('.').slice(0, 2).map(Number);\n// }\n// return {major, minor};\n// }\nfunction getViewport(deck, map, useMapboxProjection = true) {\n return new WebMercatorViewport({\n id: 'mapbox',\n x: 0,\n y: 0,\n width: deck.width,\n height: deck.height,\n ...getViewState(map),\n nearZMultiplier: useMapboxProjection\n ? // match mapbox-gl@>=1.3.0's projection matrix\n 0.02\n : // use deck.gl's own default\n 0.1,\n nearZ: map.transform._nearZ / map.transform.height,\n farZ: map.transform._farZ / map.transform.height\n });\n}\nfunction afterRender(deck, map) {\n const { mapboxLayers, isExternal } = deck.userData;\n if (isExternal) {\n // Draw non-Mapbox layers\n const mapboxLayerIds = Array.from(mapboxLayers, layer => layer.id);\n const deckLayers = flatten(deck.props.layers, Boolean);\n const hasNonMapboxLayers = deckLayers.some(layer => layer && !mapboxLayerIds.includes(layer.id));\n let viewports = deck.getViewports();\n const mapboxViewportIdx = viewports.findIndex(vp => vp.id === 'mapbox');\n const hasNonMapboxViews = viewports.length > 1 || mapboxViewportIdx < 0;\n if (hasNonMapboxLayers || hasNonMapboxViews) {\n if (mapboxViewportIdx >= 0) {\n viewports = viewports.slice();\n viewports[mapboxViewportIdx] = getViewport(deck, map, false);\n }\n deck._drawLayers('mapbox-repaint', {\n viewports,\n layerFilter: params => (!deck.props.layerFilter || deck.props.layerFilter(params)) &&\n (params.viewport.id !== 'mapbox' || !mapboxLayerIds.includes(params.layer.id)),\n clearCanvas: false\n });\n }\n }\n // End of render cycle, clear generated viewport\n deck.userData.currentViewport = null;\n}\nfunction onMapMove(deck, map) {\n deck.setProps({\n viewState: getViewState(map)\n });\n // Camera changed, will trigger a map repaint right after this\n // Clear any change flag triggered by setting viewState so that deck does not request\n // a second repaint\n deck.needsRedraw({ clearRedrawFlags: true });\n}\nfunction updateLayers(deck) {\n if (deck.userData.isExternal) {\n return;\n }\n const layers = [];\n deck.userData.mapboxLayers.forEach(deckLayer => {\n const LayerType = deckLayer.props.type;\n const layer = new LayerType(deckLayer.props);\n layers.push(layer);\n });\n deck.setProps({ layers });\n}\n", "import { _flatten as flatten } from '@deck.gl/core';\nimport MapboxLayer from \"./mapbox-layer.js\";\nconst UNDEFINED_BEFORE_ID = '__UNDEFINED__';\n/** Insert Deck layers into the mapbox Map according to the user-defined order */\n// eslint-disable-next-line complexity, max-statements\nexport function resolveLayers(map, deck, oldLayers, newLayers) {\n // Wait until map style is loaded\n // @ts-ignore non-public map property\n if (!map || !deck || !map.style || !map.style._loaded) {\n return;\n }\n const layers = flatten(newLayers, Boolean);\n if (oldLayers !== newLayers) {\n // Step 1: remove layers that no longer exist\n const prevLayers = flatten(oldLayers, Boolean);\n const prevLayerIds = new Set(prevLayers.map(l => l.id));\n for (const layer of layers) {\n prevLayerIds.delete(layer.id);\n }\n for (const id of prevLayerIds) {\n if (map.getLayer(id)) {\n map.removeLayer(id);\n }\n }\n }\n // Step 2: add missing layers\n for (const layer of layers) {\n const mapboxLayer = map.getLayer(layer.id);\n if (mapboxLayer) {\n // @ts-expect-error not typed\n mapboxLayer.implementation.setProps(layer.props);\n }\n else {\n map.addLayer(new MapboxLayer({ id: layer.id, deck }), \n // @ts-expect-error beforeId is not defined in LayerProps\n layer.props.beforeId);\n }\n }\n // Step 3: check the order of layers\n // If beforeId is defined, the deck layer should always render before the mapbox layer [beforeId]\n // If beforeId is not defined, the deck layer should appear after all mapbox layers\n // When two deck layers share the same beforeId, they are rendered in the order that is passed into Deck props.layers\n // @ts-ignore non-public map property\n const mapLayers = map.style._order;\n // Group deck layers by beforeId\n const layerGroups = {};\n for (const layer of layers) {\n // @ts-expect-error beforeId is not defined in LayerProps\n let { beforeId } = layer.props;\n if (!beforeId || !mapLayers.includes(beforeId)) {\n beforeId = UNDEFINED_BEFORE_ID;\n }\n layerGroups[beforeId] = layerGroups[beforeId] || [];\n layerGroups[beforeId].push(layer.id);\n }\n for (const beforeId in layerGroups) {\n const layerGroup = layerGroups[beforeId];\n let lastLayerIndex = beforeId === UNDEFINED_BEFORE_ID ? mapLayers.length : mapLayers.indexOf(beforeId);\n let lastLayerId = beforeId === UNDEFINED_BEFORE_ID ? undefined : beforeId;\n for (let i = layerGroup.length - 1; i >= 0; i--) {\n const layerId = layerGroup[i];\n const layerIndex = mapLayers.indexOf(layerId);\n if (layerIndex !== lastLayerIndex - 1) {\n map.moveLayer(layerId, lastLayerId);\n if (layerIndex > lastLayerIndex) {\n // The last layer's index have changed\n lastLayerIndex++;\n }\n }\n lastLayerIndex--;\n lastLayerId = layerId;\n }\n }\n}\n", "import { getDeckInstance, addLayer, removeLayer, updateLayer, drawLayer } from \"./deck-utils.js\";\nexport default class MapboxLayer {\n /* eslint-disable no-this-before-super */\n constructor(props) {\n if (!props.id) {\n throw new Error('Layer must have an unique id');\n }\n this.id = props.id;\n this.type = 'custom';\n this.renderingMode = props.renderingMode || '3d';\n this.map = null;\n this.deck = null;\n this.props = props;\n }\n /* Mapbox custom layer methods */\n onAdd(map, gl) {\n this.map = map;\n this.deck = getDeckInstance({ map, gl, deck: this.props.deck });\n addLayer(this.deck, this);\n }\n onRemove() {\n if (this.deck) {\n removeLayer(this.deck, this);\n }\n }\n setProps(props) {\n // id cannot be changed\n Object.assign(this.props, props, { id: this.id });\n // safe guard in case setProps is called before onAdd\n if (this.deck) {\n updateLayer(this.deck, this);\n }\n }\n render() {\n drawLayer(this.deck, this.map, this);\n }\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,IAAAA,eAA6B;;;ACA7B,kBAAwE;AACxE,0BAA6C;AAC7C,uBAAmB;AAEnB,IAAM,YAAY;AAClB,IAAM,qBAAqB,KAAK,KAAK;AAE9B,SAAS,gBAAgB,EAAE,KAAK,IAAI,KAAK,GAAG;AAE/C,MAAI,IAAI,QAAQ;AACZ,WAAO,IAAI;AAAA,EACf;AAEA,QAAM,eAAe,6BAAM,MAAM;AACjC,QAAM,SAAS,6BAAM,MAAM;AAC3B,QAAM,YAAY,oBAAoB;AAAA,IAClC,GAAG,6BAAM;AAAA,IACT,eAAe,MAAM;AACjB,UAAI,eAAe;AAKnB,mDAAe;AAAA,IACnB;AAAA,EACJ,CAAC;AACD,MAAI;AACJ,MAAI,CAAC,QAAQ,KAAK,MAAM,OAAO,IAAI;AAK/B,WAAO,OAAO,WAAW;AAAA,MACrB;AAAA,MACA,OAAO;AAAA,MACP,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,WAAW,aAAa,GAAG;AAAA,IAC/B,CAAC;AACD,QAAI,6BAAM,eAAe;AACrB,mBAAa,MAAM,GAAG;AAAA,IAC1B,OACK;AACD,gBAAU,SAAS,MAAM;AACrB;AACA,qBAAa,cAAc,GAAG;AAAA,MAClC;AAAA,IACJ;AAAA,EACJ;AACA,MAAI,MAAM;AACN,mBAAe;AACf,SAAK,SAAS,SAAS;AACvB,SAAK,SAAS,aAAa;AA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AAa,KAAK,iBAAiB;AAC3C,QAAI,IAAI,YAAY,KAAK,iBAAiB;AAC1C,QAAI,IAAI,SAAS,KAAK,iBAAiB;AACvC,QAAI,IAAI,YAAY,KAAK,iBAAiB;AAC1C,eAAK,UAAL,mBAAY;AAAA,EAChB;AAAA,EACA,qBAAqB,KAAK;AACtB,QAAI,IAAI,aAAa,KAAK,kBAAkB;AAC5C,kBAAc,KAAK,KAAK,OAAO,KAAK,OAAO,QAAQ,CAAC,CAAC;AACrD,uBAAmB,GAAG;AAAA,EAC1B;AAAA,EACA,qBAAqB;AACjB,WAAO;AAAA,EACX;AAAA,EAEA,WAAW,QAAQ;AACf,6BAAO,KAAK,KAAK;AACjB,WAAO,KAAK,MAAM,WAAW,MAAM;AAAA,EACvC;AAAA,EAEA,oBAAoB,QAAQ;AACxB,6BAAO,KAAK,KAAK;AACjB,WAAO,KAAK,MAAM,oBAAoB,MAAM;AAAA,EAChD;AAAA,EAEA,YAAY,QAAQ;AAChB,6BAAO,KAAK,KAAK;AACjB,WAAO,KAAK,MAAM,YAAY,MAAM;AAAA,EACxC;AAAA,EAEA,WAAW;AACP,QAAI,KAAK,MAAM;AACX,WAAK,KAAK,cAAc,IAAI;AAAA,IAChC;AAAA,EACJ;AAAA,EAEA,YAAY;AACR,QAAI,CAAC,KAAK,MAAM;AACZ,aAAO;AAAA,IACX;AACA,WAAO,KAAK,eAAe,KAAK,KAAK,UAAU,IAAI,KAAK,MAAM,UAAU;AAAA,EAC5E;AACJ;",
6
6
  "names": ["import_core", "flatten", "import_core", "import_core", "flatten"]
7
7
  }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Use deck.gl layers as custom mapbox-gl-js layers",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
- "version": "9.0.2",
6
+ "version": "9.0.4",
7
7
  "publishConfig": {
8
8
  "access": "public"
9
9
  },
@@ -38,12 +38,12 @@
38
38
  "prepublishOnly": "npm run build-bundle && npm run build-bundle -- --env=dev"
39
39
  },
40
40
  "dependencies": {
41
- "@luma.gl/constants": "^9.0.7",
41
+ "@luma.gl/constants": "^9.0.9",
42
42
  "@math.gl/web-mercator": "^4.0.0"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@deck.gl/core": "^9.0.0",
46
46
  "@luma.gl/core": "^9.0.0"
47
47
  },
48
- "gitHead": "4f17a7e9b7a68187990b0cfb0239ad9a186df0f6"
48
+ "gitHead": "4f73dc322e5a34cf3e7770d10f973aa37d3830d2"
49
49
  }
package/src/deck-utils.ts CHANGED
@@ -114,7 +114,7 @@ export function removeDeckInstance(map: Map & {__deck?: Deck | null}) {
114
114
  export function getInterleavedProps(currProps: DeckProps) {
115
115
  const nextProps: DeckProps = {
116
116
  ...currProps,
117
- // TODO: import these defaults from a single source of truth
117
+ // TODO: remove with withParametersWebGL
118
118
  parameters: {
119
119
  depthMask: true,
120
120
  depthTest: true,
@@ -124,7 +124,7 @@ export function getInterleavedProps(currProps: DeckProps) {
124
124
  depthFunc: GL.LEQUAL,
125
125
  blendEquation: GL.FUNC_ADD,
126
126
  ...currProps.parameters
127
- },
127
+ } as any,
128
128
  views: currProps.views || [new MapView({id: 'mapbox'})]
129
129
  };
130
130