solid-map-gl 1.1.4 → 1.1.5
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.
- package/README.md +44 -43
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/source/components/Control/index.jsx +3 -0
- package/dist/source/components/Layer/index.jsx +12 -7
- package/dist/source/components/Source/index.jsx +1 -1
- package/dist/source/components/Terrain/index.jsx +1 -1
- package/dist/types/components/MapGL/index.d.ts +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -74,17 +74,15 @@ By default, `MapGL` component renders in a static mode. That means that the user
|
|
|
74
74
|
|
|
75
75
|
```jsx
|
|
76
76
|
import MapGL from 'solid-map-gl'
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}}>
|
|
87
|
-
</MapGL>
|
|
77
|
+
;<MapGL
|
|
78
|
+
options={{
|
|
79
|
+
accessToken: { MAPBOX_ACCESS_TOKEN },
|
|
80
|
+
style: 'mapbox://styles/mapbox/light-v10',
|
|
81
|
+
}}
|
|
82
|
+
viewport={{
|
|
83
|
+
center: [-122.41, 37.78],
|
|
84
|
+
zoom: 11,
|
|
85
|
+
}}></MapGL>
|
|
88
86
|
```
|
|
89
87
|
|
|
90
88
|
### Interactive Map
|
|
@@ -96,14 +94,14 @@ import { createSignal } from 'solid-js'
|
|
|
96
94
|
import MapGL, { Viewport } from 'solid-map-gl'
|
|
97
95
|
|
|
98
96
|
const [viewport, setViewport] = createSignal({
|
|
99
|
-
center: [-122.41, 37.78]
|
|
100
|
-
zoom: 11
|
|
97
|
+
center: [-122.41, 37.78],
|
|
98
|
+
zoom: 11
|
|
101
99
|
} as Viewport)
|
|
102
100
|
|
|
103
101
|
<MapGL
|
|
104
102
|
options={{
|
|
105
103
|
accessToken: { MAPBOX_ACCESS_TOKEN },
|
|
106
|
-
style: 'mapbox://styles/mapbox/light-v10'
|
|
104
|
+
style: 'mapbox://styles/mapbox/light-v10'
|
|
107
105
|
}}
|
|
108
106
|
viewport={viewport()}
|
|
109
107
|
onViewportChange={evt => setViewport(evt)}>
|
|
@@ -124,7 +122,7 @@ import MapGL, { Source, Layer } from 'solid-map-gl'
|
|
|
124
122
|
<MapGL
|
|
125
123
|
options={{
|
|
126
124
|
accessToken: { MAPBOX_ACCESS_TOKEN },
|
|
127
|
-
style: 'mapbox://styles/mapbox/light-v10'
|
|
125
|
+
style: 'mapbox://styles/mapbox/light-v10'
|
|
128
126
|
}}>
|
|
129
127
|
<Source
|
|
130
128
|
source={{
|
|
@@ -152,8 +150,8 @@ import { createSignal } from 'solid-js'
|
|
|
152
150
|
import MapGL, { Source, Layer } from 'solid-map-gl'
|
|
153
151
|
|
|
154
152
|
const [viewport, setViewport] = createSignal({
|
|
155
|
-
|
|
156
|
-
|
|
153
|
+
center: [-122.486052, 37.830348],
|
|
154
|
+
zoom: 15,
|
|
157
155
|
})
|
|
158
156
|
|
|
159
157
|
const data = {
|
|
@@ -186,30 +184,32 @@ const data = {
|
|
|
186
184
|
},
|
|
187
185
|
}
|
|
188
186
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
187
|
+
;<MapGL
|
|
188
|
+
options={{
|
|
189
|
+
accessToken: { MAPBOX_ACCESS_TOKEN },
|
|
190
|
+
style: 'mapbox://styles/mapbox/light-v10',
|
|
191
|
+
}}
|
|
192
|
+
viewport={viewport()}
|
|
193
|
+
onViewportChange={evt => setViewport(evt)}>
|
|
194
|
+
<Source
|
|
195
|
+
source={{
|
|
196
|
+
type: 'geojson',
|
|
197
|
+
data: { data },
|
|
200
198
|
}}>
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
}
|
|
212
|
-
|
|
199
|
+
<Layer
|
|
200
|
+
style={{
|
|
201
|
+
type: 'line',
|
|
202
|
+
layout: {
|
|
203
|
+
'line-join': 'round',
|
|
204
|
+
'line-cap': 'round',
|
|
205
|
+
},
|
|
206
|
+
paint: {
|
|
207
|
+
'line-color': '#888',
|
|
208
|
+
'line-width': 8,
|
|
209
|
+
},
|
|
210
|
+
}}
|
|
211
|
+
/>
|
|
212
|
+
</Source>
|
|
213
213
|
</MapGL>
|
|
214
214
|
```
|
|
215
215
|
|
|
@@ -227,7 +227,7 @@ import { ScatterplotLayer } from '@deck.gl/layers'
|
|
|
227
227
|
|
|
228
228
|
const [viewport, setViewport] = createSignal({
|
|
229
229
|
center: [-74.5, 40],
|
|
230
|
-
zoom: 9
|
|
230
|
+
zoom: 9
|
|
231
231
|
})
|
|
232
232
|
|
|
233
233
|
const myDeckLayer = new MapboxLayer({
|
|
@@ -236,13 +236,13 @@ const myDeckLayer = new MapboxLayer({
|
|
|
236
236
|
data: [{ position: [-74.5, 40], size: 1000 }],
|
|
237
237
|
getPosition: d => d.position,
|
|
238
238
|
getRadius: d => d.size,
|
|
239
|
-
getColor: [255, 0, 0]
|
|
239
|
+
getColor: [255, 0, 0]
|
|
240
240
|
})
|
|
241
241
|
|
|
242
242
|
<MapGL
|
|
243
243
|
options={{
|
|
244
244
|
accessToken: { MAPBOX_ACCESS_TOKEN },
|
|
245
|
-
style: 'mapbox://styles/mapbox/light-v10'
|
|
245
|
+
style: 'mapbox://styles/mapbox/light-v10'
|
|
246
246
|
}}
|
|
247
247
|
viewport={viewport()}
|
|
248
248
|
onViewportChange={evt => setViewport(evt)}>
|
|
@@ -264,3 +264,4 @@ const myDeckLayer = new MapboxLayer({
|
|
|
264
264
|
- [x] Include Popup and Markers
|
|
265
265
|
- [x] Minify bundle & reduce size
|
|
266
266
|
- [ ] Add basemap switching
|
|
267
|
+
- [ ] Add edit functionality
|
package/dist/esm/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{template,createComponent,insert,effect,classList}from"solid-js/web";import{useTransition,createContext,onCleanup,onMount,createEffect,useContext,createUniqueId,createSignal}from"solid-js";import mapboxgl from"mapbox-gl";const _tmpl$$2=template("<main></main>",2),[pending,start]=useTransition(),MapContext=createContext(),useMap=()=>useContext(MapContext),MapGL=n=>{let t,o;onCleanup(()=>t.remove()),onMount(()=>{t=new mapboxgl.Map({...n.options,container:o,bounds:n.viewport.bounds,center:n.viewport.center,zoom:n.viewport.zoom||null,pitch:n.viewport.pitch||null,bearing:n.viewport.bearing||null,fitBoundsOptions:{padding:n.viewport.padding}})}),createEffect(()=>n.onMouseMove&&t.on("mousemove",e=>n.onMouseMove(e.lngLat)));const e=()=>{var e={center:t.getCenter(),zoom:t.getZoom(),pitch:t.getPitch(),bearing:t.getBearing(),padding:n.viewport.padding};n.onViewportChange(e)};createEffect(()=>n.onViewportChange&&t.on("dragend",e).on("moveend",e).on("zoomend",e).on("rotateend",e).on("pitchend",e).on("boxzoomend",e)),createEffect(async()=>{n.viewport.bounds&&t.fitBounds(n.viewport.bounds,{padding:n.viewport.padding})});let a=0;return createEffect(()=>{n.triggerResize&&(a=0,window.requestAnimationFrame(function e(){a<15&&(a++,window.requestAnimationFrame(e),start(()=>t.resize()))}))}),createComponent(MapContext.Provider,{value:()=>t,get children(){const a=_tmpl$$2.cloneNode(!0),e=o;return"function"==typeof e?e(a):o=a,a.style.setProperty("height","100%"),a.style.setProperty("width","100%"),insert(a,()=>n.children),effect(e=>{var t=n.class||"",o=n.classList;return t!==e._v$&&(a.className=e._v$=t),e._v$2=classList(a,o,e._v$2),e},{_v$:void 0,_v$2:void 0}),a}})},SourceContext=createContext(),useSource=()=>useContext(SourceContext),SourceComponent=t=>{const o=useMap();return t.id=t.id||createUniqueId(),onMount(async()=>{o().isStyleLoaded()||await o().once("styledata"),o().getSource(t.id)||o().addSource(t.id,t.source)}),onCleanup(()=>{o().getStyle().layers.forEach(e=>e.source===t.id&&o().removeLayer(e.id)),o().getSource(t.id)&&o().removeSource(t.id)}),createEffect(async()=>{("geojson"===t.source.type||t.source.data)&&o().getSource(t.id)&&o().getSource(t.id).setData(t.source.data)}),createComponent(SourceContext.Provider,{get value(){return{
|
|
1
|
+
import{template,createComponent,insert,effect,classList}from"solid-js/web";import{useTransition,createContext,onCleanup,onMount,createEffect,useContext,createUniqueId,createSignal}from"solid-js";import mapboxgl from"mapbox-gl";const _tmpl$$2=template("<main></main>",2),[pending,start]=useTransition(),MapContext=createContext(),useMap=()=>useContext(MapContext),MapGL=n=>{let t,o;onCleanup(()=>t.remove()),onMount(()=>{t=new mapboxgl.Map({...n.options,container:o,bounds:n.viewport.bounds,center:n.viewport.center,zoom:n.viewport.zoom||null,pitch:n.viewport.pitch||null,bearing:n.viewport.bearing||null,fitBoundsOptions:{padding:n.viewport.padding}})}),createEffect(()=>n.onMouseMove&&t.on("mousemove",e=>n.onMouseMove(e.lngLat)));const e=()=>{var e={center:t.getCenter(),zoom:t.getZoom(),pitch:t.getPitch(),bearing:t.getBearing(),padding:n.viewport.padding};n.onViewportChange(e)};createEffect(()=>n.onViewportChange&&t.on("dragend",e).on("moveend",e).on("zoomend",e).on("rotateend",e).on("pitchend",e).on("boxzoomend",e)),createEffect(async()=>{n.viewport.bounds&&t.fitBounds(n.viewport.bounds,{padding:n.viewport.padding})});let a=0;return createEffect(()=>{n.triggerResize&&(a=0,window.requestAnimationFrame(function e(){a<15&&(a++,window.requestAnimationFrame(e),start(()=>t.resize()))}))}),createComponent(MapContext.Provider,{value:()=>t,get children(){const a=_tmpl$$2.cloneNode(!0),e=o;return"function"==typeof e?e(a):o=a,a.style.setProperty("height","100%"),a.style.setProperty("width","100%"),insert(a,()=>n.children),effect(e=>{var t=n.class||"",o=n.classList;return t!==e._v$&&(a.className=e._v$=t),e._v$2=classList(a,o,e._v$2),e},{_v$:void 0,_v$2:void 0}),a}})},SourceContext=createContext(),useSource=()=>useContext(SourceContext),SourceComponent=t=>{const o=useMap();return t.id=t.id||createUniqueId(),onMount(async()=>{o().isStyleLoaded()||await o().once("styledata"),o().getSource(t.id)||o().addSource(t.id,t.source)}),onCleanup(()=>{o().getStyle().layers.forEach(e=>e.source===t.id&&o().removeLayer(e.id)),o().getSource(t.id)&&o().removeSource(t.id)}),createEffect(async()=>{("geojson"===t.source.type||t.source.data)&&o().getSource(t.id)&&o().getSource(t.id).setData(t.source.data)}),createComponent(SourceContext.Provider,{get value(){return{id:t.id}},get children(){return t.children}})},diff=(a={},n={})=>{return[...new Set([...Object.keys(a),...Object.keys(n)])].reduce((e,t)=>{var o=a[t];return o!==n[t]&&e.push([t,o]),e},[])},Layer=o=>{const a=useMap(),t=useSource();return o.id=o.id||createUniqueId(),onMount(async()=>{a().isStyleLoaded()||await a().once("styledata"),a().getLayer(o.id)||a().addLayer(o.layer||{...o.style,id:o.id,source:t.id},o.beforeType?a().getStyle().layers.find(e=>e.type===o.beforeType).id:o.beforeId)}),createEffect(async e=>{if(o.style&&a().getSource(t.id)&&a().getLayer(o.id))return a().isSourceLoaded(t.id)||await a().once("data"),diff(o.style.paint,e.paint).forEach(([e,t])=>a().setPaintProperty(o.id,e,t)),diff(o.style.layout,e.layout).forEach(([e,t])=>a().setLayoutProperty(o.id,e,t)),o.style.minzoom===e.minzoom&&o.style.maxzoom===e.max||a().setLayerZoomRange(o.id,o.style.minzoom,o.style.maxzoom),o.style},o.style),createEffect(async()=>{void 0!==o.visible&&a().getSource(t.id)&&a().getLayer(o.id)&&(a().isSourceLoaded(t.id)||await a().once("data"),a().setLayoutProperty(o.id,"visibility",o.visible?"visible":"none",{validate:!1}))}),createEffect(async()=>{o.filter&&(a().isStyleLoaded()||await a().once("styledata"),a().setFilter(o.id,o.filter))}),createEffect(async()=>{o.featureState&&o.featureState.id&&(a().loaded()||await a().once("render"),a().removeFeatureState({source:t.id,sourceLayer:o.style["source-layer"]}),a().setFeatureState({source:t.id,sourceLayer:o.style["source-layer"],id:o.featureState.id},o.featureState.state))}),o.children},Fog=e=>{const t=useMap();return onMount(async()=>{t().isStyleLoaded()||await t().once("styledata"),t().setFog(e.style)}),onCleanup(()=>t().setFog(null)),createEffect(async()=>{void 0!==e.visible&&(t().isStyleLoaded()||await t().once("styledata"),t().setFog(e.visible?e.style:null))}),e.children},Sky=e=>{const t=useMap(),o="_sky";return onMount(async()=>{t().isStyleLoaded()||await t().once("styledata"),t().getLayer(o)||t().addLayer({...e.style,id:o})}),onCleanup(()=>t().getLayer(o)&&t().removeLayer(o)),createEffect(async()=>{void 0!==e.visible&&(t().isStyleLoaded()||await t().once("styledata"),t().setLayoutProperty(o,"visibility",e.visible?"visible":"none"))}),e.children},Terrain=e=>{const t=useMap(),o=useSource();return onMount(async()=>{t().isStyleLoaded()||await t().once("styledata"),t().setTerrain({...e.style,source:o.id})}),onCleanup(()=>t().setTerrain(null)),createEffect(async()=>{void 0!==e.visible&&(t().isStyleLoaded()||await t().once("styledata"),t().setTerrain(e.visible?e.style:null))}),e.children},Control=t=>{const o=useMap(),[e,a]=createSignal(null);return onMount(async()=>{let e;switch(t.type){case"navigation":e=new mapboxgl.NavigationControl(t.options);break;case"scale":e=new mapboxgl.ScaleControl(t.options);break;case"attribution":e=new mapboxgl.AttributionControl(t.options);break;case"fullscreen":e=new mapboxgl.FullscreenControl(t.options);break;case"geolocate":e=new mapboxgl.GeolocateControl(t.options)}e&&o().addControl(e,t.position),a(e)}),onCleanup(()=>o().removeControl(e())),t.children},_tmpl$$1=template("<div></div>",2),Marker=t=>{const o=useMap();let a=null;return onMount(async()=>{var e;a=new mapboxgl.Marker(t.options).setLngLat(t.lnglat).setPopup(t.children?(new mapboxgl.Popup).setDOMContent((e=_tmpl$$1.cloneNode(!0),insert(e,()=>t.children),e)):null).addTo(o())}),onCleanup(()=>a.remove()),createEffect(()=>a.setLngLat(t.lnglat)),[]},_tmpl$=template("<div></div>",2),Popup=t=>{const o=useMap();let a=null;return onMount(async()=>{var e;a=new mapboxgl.Popup(t.options).setLngLat(t.lnglat).setDOMContent((e=_tmpl$.cloneNode(!0),insert(e,()=>t.children),e)).addTo(o())}),onCleanup(()=>a.remove()),createEffect(()=>a.setLngLat(t.lnglat)),createEffect(()=>a.setDOMContent((()=>{var e=_tmpl$.cloneNode(!0);return insert(e,()=>t.children),e})())),[]},Image=o=>{const a=useMap();return onMount(async()=>{a().isStyleLoaded()||await a().once("styledata"),o.url?a().loadImage(o.url,(e,t)=>{if(e)throw e;a().hasImage(o.id)||a().addImage(o.id,t)}):a().hasImage(o.id)||a().addImage(o.id,o.image,o.options)}),onCleanup(()=>a().hasImage(o.id)&&a().removeImage(o.id)),createEffect(async()=>{o.image&&o.url||(o.url?a().loadImage(o.url,(e,t)=>{if(e)throw e;a().hasImage(o.id)||a().updateImage(o.id,t)}):a().hasImage(o.id)&&a().updateImage(o.id,o.image))}),[]};export{Control,Fog,Image,Layer,Marker,Popup,Sky,SourceComponent as Source,Terrain,MapGL as default};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/components/MapGL/index.tsx","../../src/components/Source/index.tsx","../../src/components/Layer/index.tsx","../../src/components/Fog/index.tsx","../../src/components/Sky/index.tsx","../../src/components/Terrain/index.tsx","../../src/components/Control/index.tsx","../../src/components/Marker/index.tsx","../../src/components/Popup/index.tsx","../../src/components/Image/index.tsx"],"sourcesContent":["import {\n createEffect,\n onMount,\n onCleanup,\n createContext,\n useContext,\n Component,\n useTransition,\n} from 'solid-js'\nimport mapboxgl from 'mapbox-gl'\nimport 'mapbox-gl/dist/mapbox-gl.css'\nimport type MapboxMap from 'mapbox-gl/src/ui/map'\nimport type MapboxOptions from 'mapbox-gl/src/ui/map'\nimport type MapMouseEvent from 'mapbox-gl/src/ui/events'\nimport type { LngLatLike } from 'mapbox-gl/src/geo/lng_lat.js'\nimport type { LngLatBounds } from 'mapbox-gl/src/geo/lng_lat_bounds.js'\n\nexport type Viewport = {\n center?: LngLatLike\n bounds?: LngLatBounds\n zoom?: number\n pitch?: number\n bearing?: number\n padding?: number\n}\n\nconst [pending, start] = useTransition()\n\nconst MapContext = createContext<MapboxMap>()\nconst useMap = () => useContext(MapContext)\n\nconst MapGL: Component<{\n class?: string\n classList?: {\n [k: string]: boolean | undefined\n }\n viewport?: Viewport\n options?: MapboxOptions\n children?: Component[] | Component\n triggerResize?: boolean\n onMouseMove?: (event: MapMouseEvent) => void\n onViewportChange?: (viewport: Viewport) => void\n}> = props => {\n let map: MapboxMap\n let mapRef: HTMLElement\n\n onCleanup(() => map.remove())\n\n onMount(() => {\n map = new mapboxgl.Map({\n ...props.options,\n container: mapRef,\n bounds: props.viewport.bounds,\n center: props.viewport.center,\n zoom: props.viewport.zoom || null,\n pitch: props.viewport.pitch || null,\n bearing: props.viewport.bearing || null,\n fitBoundsOptions: { padding: props.viewport.padding },\n } as MapboxOptions)\n })\n\n createEffect(\n () =>\n props.onMouseMove &&\n map.on('mousemove', event => props.onMouseMove(event.lngLat))\n )\n\n const _onViewportChange = () => {\n const viewport: Viewport = {\n center: map.getCenter(),\n zoom: map.getZoom(),\n pitch: map.getPitch(),\n bearing: map.getBearing(),\n padding: props.viewport.padding,\n }\n props.onViewportChange(viewport)\n }\n\n createEffect(\n () =>\n props.onViewportChange &&\n map\n .on('dragend', _onViewportChange)\n .on('moveend', _onViewportChange)\n .on('zoomend', _onViewportChange)\n .on('rotateend', _onViewportChange)\n .on('pitchend', _onViewportChange)\n .on('boxzoomend', _onViewportChange)\n )\n\n createEffect(async () => {\n if (!props.viewport.bounds) return\n\n map.fitBounds(props.viewport.bounds, {\n padding: props.viewport.padding,\n })\n })\n\n let index = 0\n\n createEffect(() => {\n if (props.triggerResize) {\n index = 0\n window.requestAnimationFrame(function loop() {\n if (index < 15) {\n index++\n window.requestAnimationFrame(loop)\n start(() => map.resize())\n }\n })\n }\n })\n\n return (\n <MapContext.Provider value={() => map}>\n <main\n ref={mapRef}\n class={props.class || ''}\n classList={props.classList}\n style={{ height: '100%', width: '100%' }}>\n {props.children}\n </main>\n </MapContext.Provider>\n )\n}\n\nexport { MapGL as default, useMap }\n","import {\n onMount,\n onCleanup,\n createEffect,\n Component,\n createContext,\n useContext,\n createUniqueId,\n} from 'solid-js'\nimport { useMap } from '../MapGL'\nimport type MapboxMap from 'mapbox-gl/src/ui/map'\nimport type {\n Source,\n SourceSpecification,\n} from 'mapbox-gl/src/style-spec/types.js'\n\nconst SourceContext = createContext<Source>()\n\nconst useSource = (): Source => useContext(SourceContext)\n\nconst SourceComponent: Component<{\n id?: string\n source: SourceSpecification\n}> = props => {\n const map: MapboxMap = useMap()\n props.id = props.id || createUniqueId()\n // Add Source\n onMount(async () => {\n !map().isStyleLoaded() && (await map().once('styledata'))\n !map().getSource(props.id) && map().addSource(props.id, props.source)\n })\n\n // Remove Source\n onCleanup(() => {\n map()\n .getStyle()\n .layers.forEach(\n layer => layer.source === props.id && map().removeLayer(layer.id)\n )\n map().getSource(props.id) && map().removeSource(props.id)\n })\n\n // Update GeoJSON Data\n createEffect(async () => {\n if (props.source.type !== 'geojson' && !props.source.data) return\n\n map().getSource(props.id) &&\n map().getSource(props.id).setData(props.source.data)\n })\n\n return (\n <SourceContext.Provider value={{ source: props.id }}>\n {props.children}\n </SourceContext.Provider>\n )\n}\n\nexport { SourceComponent as default, useSource }\n","import { onMount, createEffect, Component, createUniqueId } from 'solid-js'\nimport { useMap } from '../MapGL'\nimport { useSource } from '../Source'\nimport type MapboxMap from 'mapbox-gl/src/ui/map'\nimport type {\n FilterSpecification,\n StyleSpecification,\n SourceSpecification,\n} from 'mapbox-gl/src/style-spec/types.js'\nimport type { CustomLayerInterface } from 'mapbox-gl/src/style/style_layer/custom_style_layer'\n\nconst diff = (\n newProps: StyleSpecification = {},\n prevProps: StyleSpecification = {}\n) => {\n const keys = new Set([...Object.keys(newProps), ...Object.keys(prevProps)])\n return [...keys].reduce((acc, key: string) => {\n const value = newProps[key]\n if (value !== prevProps[key]) {\n acc.push([key, value])\n }\n return acc\n }, [])\n}\n\nconst Layer: Component<{\n id?: string\n style?: StyleSpecification\n layer?: CustomLayerInterface\n filter?: FilterSpecification\n visible?: boolean\n sourceId?: string\n beforeType?:\n | 'background'\n | 'fill'\n | 'line'\n | 'symbol'\n | 'raster'\n | 'circle'\n | 'fill-extrusion'\n | 'heatmap'\n | 'hillshade'\n | 'sky'\n beforeId?: string\n featureState?: { id: number | string; state: object }\n}> = props => {\n const map: MapboxMap = useMap()\n const source: SourceSpecification = useSource()\n props.id = props.id || createUniqueId()\n // Add Layer\n onMount(async () => {\n !map().isStyleLoaded() && (await map().once('styledata'))\n\n if (map().getLayer(props.id)) return\n\n map().addLayer(\n props.layer || {\n ...props.style,\n id: props.id,\n source: source.source,\n },\n props.beforeType\n ? map()\n .getStyle()\n .layers.find(l => l.type === props.beforeType).id\n : props.beforeId\n )\n })\n\n // Update Style\n createEffect((prev: StyleSpecification) => {\n if (!props.style && map().getLayer(props.id)) return\n\n diff(props.style.paint, prev.paint).forEach(([key, value]) =>\n map().setPaintProperty(props.id, key, value)\n )\n\n diff(props.style.layout, prev.layout).forEach(([key, value]) =>\n map().setLayoutProperty(props.id, key, value)\n )\n\n if (\n props.style.minzoom !== prev.minzoom ||\n props.style.maxzoom !== prev.max\n )\n map().setLayerZoomRange(\n props.id,\n props.style.minzoom,\n props.style.maxzoom\n )\n\n return props.style\n }, props.style)\n\n // Update Visibility\n createEffect(async () => {\n if (props.visible === undefined) return\n\n !map().isStyleLoaded() && (await map().once('styledata'))\n map().setLayoutProperty(\n props.id,\n 'visibility',\n props.visible ? 'visible' : 'none',\n { validate: false }\n )\n })\n\n // Update Filter\n createEffect(async () => {\n if (!props.filter) return\n\n !map().isStyleLoaded() && (await map().once('styledata'))\n map().setFilter(props.id, props.filter)\n })\n\n // Update Feature State\n createEffect(async () => {\n if (!props.featureState || !props.featureState.id) return\n\n map().loaded() ? null : await map().once('render')\n\n map().removeFeatureState({\n source: source.source,\n sourceLayer: props.style['source-layer'],\n })\n map().setFeatureState(\n {\n source: source.source,\n sourceLayer: props.style['source-layer'],\n id: props.featureState.id,\n },\n props.featureState.state\n )\n })\n\n return props.children\n}\n\nexport default Layer\n","import { onMount, onCleanup, createEffect, Component } from 'solid-js'\nimport { useMap } from '../MapGL'\nimport type MapboxMap from 'mapbox-gl/src/ui/map'\nimport type { FogSpecification } from 'mapbox-gl/src/style-spec/types.js'\n\nconst Fog: Component<{\n style: FogSpecification\n visible?: boolean\n}> = props => {\n const map: MapboxMap = useMap()\n // Add Fog Layer\n onMount(async () => {\n !map().isStyleLoaded() && (await map().once('styledata'))\n map().setFog(props.style)\n })\n // Remove Fog Layer\n onCleanup(() => map().setFog(null))\n\n // Update Visibility\n createEffect(async () => {\n if (props.visible === undefined) return\n\n !map().isStyleLoaded() && (await map().once('styledata'))\n map().setFog(props.visible ? props.style : null)\n })\n\n return props.children\n}\n\nexport default Fog\n","import { onMount, onCleanup, createEffect, Component } from 'solid-js'\nimport { useMap } from '../MapGL'\nimport type MapboxMap from 'mapbox-gl/src/ui/map'\nimport type { StyleSpecification } from 'mapbox-gl/src/style-spec/types.js'\n\nconst Sky: Component<{\n style: StyleSpecification\n visible?: boolean\n}> = props => {\n const map: MapboxMap = useMap()\n const layerId = '_sky'\n // Add Sky Layer\n onMount(async () => {\n !map().isStyleLoaded() && (await map().once('styledata'))\n !map().getLayer(layerId) && map().addLayer({ ...props.style, id: layerId })\n })\n\n // Remove Sky Layer\n onCleanup(() => map().getLayer(layerId) && map().removeLayer(layerId))\n\n // Update Visibility\n createEffect(async () => {\n if (props.visible === undefined) return\n\n !map().isStyleLoaded() && (await map().once('styledata'))\n map().setLayoutProperty(\n layerId,\n 'visibility',\n props.visible ? 'visible' : 'none'\n )\n })\n\n return props.children\n}\n\nexport default Sky\n","import { onMount, onCleanup, createEffect, Component } from 'solid-js'\nimport { useMap } from '../MapGL'\nimport { useSource } from '../Source'\nimport type MapboxMap from 'mapbox-gl/src/ui/map'\nimport type {\n TerrainSpecification,\n SourceSpecification,\n} from 'mapbox-gl/src/style-spec/types.js'\n\nconst Terrain: Component<{\n style: TerrainSpecification\n visible?: boolean\n}> = props => {\n const map: MapboxMap = useMap()\n const source: SourceSpecification = useSource()\n\n // Add Terrain Layer\n onMount(async () => {\n !map().isStyleLoaded() && (await map().once('styledata'))\n map().setTerrain({ ...props.style, source: source.source })\n })\n\n // Remove Terrain Layer\n onCleanup(() => map().setTerrain(null))\n\n // Update Visibility\n createEffect(async () => {\n if (props.visible === undefined) return\n\n !map().isStyleLoaded() && (await map().once('styledata'))\n map().setTerrain(props.visible ? props.style : null)\n })\n\n return props.children\n}\n\nexport default Terrain\n","import { onMount, onCleanup, createSignal, Component, lazy } from 'solid-js'\nimport { useMap } from '../MapGL'\nimport mapboxgl from 'mapbox-gl'\nimport type MapboxMap from 'mapbox-gl/src/ui/map'\nimport type { Options as AttributionOptions } from 'mapbox-gl/src/ui/control/attribution_control'\nimport type { Options as FullscreenOptions } from 'mapbox-gl/src/ui/control/fullscreen_control'\nimport type { Options as GeolocateOptions } from 'mapbox-gl/src/ui/control/geolocate_control'\nimport type { Options as NavigationOptions } from 'mapbox-gl/src/ui/control/navigation_control'\nimport type { Options as ScaleOptions } from 'mapbox-gl/src/ui/control/scale_control'\n\nconst Control: Component<{\n type:\n | 'navigation'\n | 'scale'\n | 'attribution'\n | 'fullscreen'\n | 'geolocate'\n | 'language'\n | 'traffic'\n options?:\n | NavigationOptions\n | ScaleOptions\n | AttributionOptions\n | FullscreenOptions\n | GeolocateOptions\n position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'\n}> = props => {\n const map: MapboxMap = useMap()\n const [control, setControl] = createSignal(null)\n // Add Control\n onMount(async () => {\n let control\n\n switch (props.type) {\n case 'navigation':\n control = new mapboxgl.NavigationControl(props.options)\n break\n case 'scale':\n control = new mapboxgl.ScaleControl(props.options)\n break\n case 'attribution':\n control = new mapboxgl.AttributionControl(props.options)\n break\n case 'fullscreen':\n control = new mapboxgl.FullscreenControl(props.options)\n break\n case 'geolocate':\n control = new mapboxgl.GeolocateControl(props.options)\n break\n // case 'language':\n // const MapboxLanguage = (await import('@mapbox/mapbox-gl-language'))\n // .default\n // control = new MapboxLanguage(props.options)\n // break\n // case 'traffic':\n // const MapboxTraffic = (await import('@mapbox/mapbox-gl-traffic'))\n // .default\n // await import('@mapbox/mapbox-gl-traffic/mapbox-gl-traffic.css')\n // control = new MapboxTraffic(props.options)\n // break\n }\n control && map().addControl(control, props.position)\n setControl(control)\n })\n\n onCleanup(() => map().removeControl(control()))\n\n return props.children\n}\n\nexport default Control\n","import { onMount, onCleanup, createEffect, Component, children } from 'solid-js'\nimport { useMap } from '../MapGL'\nimport mapboxgl from 'mapbox-gl'\nimport type MapboxMap from 'mapbox-gl/src/ui/map'\nimport type { MarkerSpecification } from 'mapbox-gl/src/style-spec/types.js'\nimport type { LngLatLike } from 'mapbox-gl/src/geo/lng_lat.js'\n\nconst Marker: Component<{\n options?: MarkerSpecification\n lnglat: LngLatLike\n}> = props => {\n const map: MapboxMap = useMap()\n let marker = null\n\n // Add Marker\n onMount(async () => {\n marker = new mapboxgl.Marker(props.options)\n .setLngLat(props.lnglat)\n .setPopup(\n props.children\n ? new mapboxgl.Popup().setDOMContent(<div>{props.children}</div>)\n : null\n )\n .addTo(map())\n })\n // Remove Marker\n onCleanup(() => marker.remove())\n\n // Update Position\n createEffect(() => marker.setLngLat(props.lnglat))\n\n return <></>\n}\n\nexport default Marker\n","import { onMount, onCleanup, createEffect, Component } from 'solid-js'\nimport { useMap } from '../MapGL'\nimport mapboxgl from 'mapbox-gl'\nimport type MapboxMap from 'mapbox-gl/src/ui/map'\nimport type { PopupSpecification } from 'mapbox-gl/src/style-spec/types.js'\nimport type { LngLatLike } from 'mapbox-gl/src/geo/lng_lat.js'\n\nconst Popup: Component<{\n options?: PopupSpecification\n lnglat: LngLatLike\n}> = props => {\n const map: MapboxMap = useMap()\n let popup = null\n\n // Add Popup\n onMount(async () => {\n popup = new mapboxgl.Popup(props.options)\n .setLngLat(props.lnglat)\n .setDOMContent(<div>{props.children}</div>)\n .addTo(map())\n })\n // Remove Popup\n onCleanup(() => popup.remove())\n\n // Update Position\n createEffect(() => popup.setLngLat(props.lnglat))\n\n // Update Content\n createEffect(() => popup.setDOMContent(<div>{props.children}</div>))\n\n return <></>\n}\n\nexport default Popup\n","import { onMount, onCleanup, createEffect, Component } from 'solid-js'\nimport { useMap } from '../MapGL'\nimport type MapboxMap from 'mapbox-gl/src/ui/map'\nimport type {\n StyleImageInterface,\n StyleImageMetadata,\n} from 'mapbox-gl/src/style/style_image'\n\nconst Image: Component<{\n id: string\n url?: string\n image?:\n | HTMLImageElement\n | ImageBitmap\n | ImageData\n | { width: number; height: number; data: Uint8Array | Uint8ClampedArray }\n | StyleImageInterface\n options?: StyleImageMetadata\n}> = props => {\n const map: MapboxMap = useMap()\n // Add Image\n onMount(async () => {\n !map().isStyleLoaded() && (await map().once('styledata'))\n if (props.url) {\n map().loadImage(props.url, (error, image) => {\n if (error) throw error\n !map().hasImage(props.id) && map().addImage(props.id, image)\n })\n } else {\n !map().hasImage(props.id) &&\n map().addImage(props.id, props.image, props.options)\n }\n })\n // Remove Image\n onCleanup(() => map().hasImage(props.id) && map().removeImage(props.id))\n\n // Update Image\n createEffect(async () => {\n if (props.image && props.url) return\n\n if (props.url) {\n map().loadImage(props.url, (error, image) => {\n if (error) throw error\n !map().hasImage(props.id) && map().updateImage(props.id, image)\n })\n } else {\n map().hasImage(props.id) && map().updateImage(props.id, props.image)\n }\n })\n\n return <></>\n}\n\nexport default Image\n"],"names":["pending","start","useTransition","MapContext","createContext","useMap","useContext","MapGL","props","map","mapRef","onCleanup","remove","onMount","mapboxgl","Map","options","container","bounds","viewport","center","zoom","pitch","bearing","fitBoundsOptions","padding","createEffect","onMouseMove","on","event","lngLat","_onViewportChange","getCenter","getZoom","getPitch","getBearing","onViewportChange","async","fitBounds","index","triggerResize","window","requestAnimationFrame","loop","resize","children","class","classList","SourceContext","useSource","SourceComponent","id","createUniqueId","isStyleLoaded","once","getSource","addSource","source","getStyle","layers","forEach","layer","removeLayer","removeSource","type","data","setData","diff","newProps","prevProps","Set","Object","keys","reduce","acc","key","value","push","Layer","getLayer","addLayer","style","beforeType","find","l","beforeId","prev","paint","setPaintProperty","layout","setLayoutProperty","minzoom","maxzoom","max","setLayerZoomRange","undefined","visible","validate","filter","setFilter","featureState","loaded","removeFeatureState","sourceLayer","setFeatureState","state","Fog","setFog","Sky","layerId","Terrain","setTerrain","Control","control","setControl","createSignal","NavigationControl","ScaleControl","AttributionControl","FullscreenControl","GeolocateControl","addControl","position","removeControl","Marker","marker","setLngLat","lnglat","setPopup","Popup","setDOMContent","addTo","popup","Image","url","loadImage","error","image","hasImage","addImage","removeImage","updateImage"],"mappings":"8QA0BM,CAACA,QAASC,OAASC,gBAEnBC,WAAaC,gBACbC,OAAS,IAAMC,WAAWH,YAE1BI,MAWDC,QACCC,EACAC,EAEJC,UAAU,IAAMF,EAAIG,UAEpBC,QAAQ,KACNJ,EAAM,IAAIK,SAASC,IAAI,IAClBP,EAAMQ,QACTC,UAAWP,EACXQ,OAAQV,EAAMW,SAASD,OACvBE,OAAQZ,EAAMW,SAASC,OACvBC,KAAMb,EAAMW,SAASE,MAAQ,KAC7BC,MAAOd,EAAMW,SAASG,OAAS,KAC/BC,QAASf,EAAMW,SAASI,SAAW,KACnCC,iBAAkB,CAAEC,QAASjB,EAAMW,SAASM,aAIhDC,aACE,IACElB,EAAMmB,aACNlB,EAAImB,GAAG,YAAaC,GAASrB,EAAMmB,YAAYE,EAAMC,gBAGnDC,EAAoB,SAClBZ,EAAqB,CACzBC,OAAQX,EAAIuB,YACZX,KAAMZ,EAAIwB,UACVX,MAAOb,EAAIyB,WACXX,QAASd,EAAI0B,aACbV,QAASjB,EAAMW,SAASM,SAE1BjB,EAAM4B,i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C,EAAiBJ,aACnB+H,EAAQ,YAGZvH,QAAQwB,gBACN+F,EAAQ,IAAItH,SAASmH,MAAMzH,EAAMQ,SAC9B8G,UAAUtH,EAAMuH,QAChBG,mDAAoB1H,EAAMqC,cAC1BsF,MAAM1H,OAGXE,UAAU,IAAMyH,EAAMxH,UAGtBc,aAAa,IAAM0G,EAAMN,UAAUtH,EAAMuH,SAGzCrG,aAAa,IAAM0G,EAAMF,mEAAoB1H,EAAMqC,sBCpB/CwF,MAUD7H,UACGC,EAAiBJ,gBAEvBQ,QAAQwB,UACL5B,IAAM4C,uBAA0B5C,IAAM6C,KAAK,aACxC9C,EAAM8H,IACR7H,IAAM8H,UAAU/H,EAAM8H,IAAK,CAACE,EAAOC,QAC7BD,EAAO,MAAMA,EAChB/H,IAAMiI,SAASlI,EAAM2C,KAAO1C,IAAMkI,SAASnI,EAAM2C,GAAIsF,KAGvDhI,IAAMiI,SAASlI,EAAM2C,KACpB1C,IAAMkI,SAASnI,EAAM2C,GAAI3C,EAAMiI,MAAOjI,EAAMQ,WAIlDL,UAAU,IAAMF,IAAMiI,SAASlI,EAAM2C,KAAO1C,IAAMmI,YAAYpI,EAAM2C,KAGpEzB,aAAaW,UACP7B,EAAMiI,OAASjI,EAAM8H,MAErB9H,EAAM8H,IACR7H,IAAM8H,UAAU/H,EAAM8H,IAAK,CAACE,EAAOC,QAC7BD,EAAO,MAAMA,EAChB/H,IAAMiI,SAASlI,EAAM2C,KAAO1C,IAAMoI,YAAYrI,EAAM2C,GAAIsF,KAG3DhI,IAAMiI,SAASlI,EAAM2C,KAAO1C,IAAMoI,YAAYrI,EAAM2C,GAAI3C,EAAMiI"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/components/MapGL/index.tsx","../../src/components/Source/index.tsx","../../src/components/Layer/index.tsx","../../src/components/Fog/index.tsx","../../src/components/Sky/index.tsx","../../src/components/Terrain/index.tsx","../../src/components/Control/index.tsx","../../src/components/Marker/index.tsx","../../src/components/Popup/index.tsx","../../src/components/Image/index.tsx"],"sourcesContent":["import {\n createEffect,\n onMount,\n onCleanup,\n createContext,\n useContext,\n Component,\n useTransition,\n} from 'solid-js'\nimport mapboxgl from 'mapbox-gl'\nimport 'mapbox-gl/dist/mapbox-gl.css'\nimport type MapboxMap from 'mapbox-gl/src/ui/map'\nimport type MapboxOptions from 'mapbox-gl/src/ui/map'\nimport type MapMouseEvent from 'mapbox-gl/src/ui/events'\nimport type { LngLatLike } from 'mapbox-gl/src/geo/lng_lat.js'\nimport type { LngLatBounds } from 'mapbox-gl/src/geo/lng_lat_bounds.js'\n\nexport type Viewport = {\n center?: LngLatLike\n bounds?: LngLatBounds\n zoom?: number\n pitch?: number\n bearing?: number\n padding?: number\n}\n\nconst [pending, start] = useTransition()\n\nconst MapContext = createContext<MapboxMap>()\nconst useMap = () => useContext(MapContext)\n\nconst MapGL: Component<{\n class?: string\n classList?: {\n [k: string]: boolean | undefined\n }\n viewport?: Viewport\n options?: MapboxOptions\n children?: Element[]\n triggerResize?: boolean\n onMouseMove?: (event: MapMouseEvent) => void\n onViewportChange?: (viewport: Viewport) => void\n}> = props => {\n let map: MapboxMap\n let mapRef: HTMLElement\n\n onCleanup(() => map.remove())\n\n onMount(() => {\n map = new mapboxgl.Map({\n ...props.options,\n container: mapRef,\n bounds: props.viewport.bounds,\n center: props.viewport.center,\n zoom: props.viewport.zoom || null,\n pitch: props.viewport.pitch || null,\n bearing: props.viewport.bearing || null,\n fitBoundsOptions: { padding: props.viewport.padding },\n } as MapboxOptions)\n })\n\n createEffect(\n () =>\n props.onMouseMove &&\n map.on('mousemove', event => props.onMouseMove(event.lngLat))\n )\n\n const _onViewportChange = () => {\n const viewport: Viewport = {\n center: map.getCenter(),\n zoom: map.getZoom(),\n pitch: map.getPitch(),\n bearing: map.getBearing(),\n padding: props.viewport.padding,\n }\n props.onViewportChange(viewport)\n }\n\n createEffect(\n () =>\n props.onViewportChange &&\n map\n .on('dragend', _onViewportChange)\n .on('moveend', _onViewportChange)\n .on('zoomend', _onViewportChange)\n .on('rotateend', _onViewportChange)\n .on('pitchend', _onViewportChange)\n .on('boxzoomend', _onViewportChange)\n )\n\n createEffect(async () => {\n if (!props.viewport.bounds) return\n\n map.fitBounds(props.viewport.bounds, {\n padding: props.viewport.padding,\n })\n })\n\n let index = 0\n\n createEffect(() => {\n if (props.triggerResize) {\n index = 0\n window.requestAnimationFrame(function loop() {\n if (index < 15) {\n index++\n window.requestAnimationFrame(loop)\n start(() => map.resize())\n }\n })\n }\n })\n\n return (\n <MapContext.Provider value={() => map}>\n <main\n ref={mapRef}\n class={props.class || ''}\n classList={props.classList}\n style={{ height: '100%', width: '100%' }}>\n {props.children}\n </main>\n </MapContext.Provider>\n )\n}\n\nexport { MapGL as default, useMap }\n","import {\n onMount,\n onCleanup,\n createEffect,\n Component,\n createContext,\n useContext,\n createUniqueId,\n} from 'solid-js'\nimport { useMap } from '../MapGL'\nimport type MapboxMap from 'mapbox-gl/src/ui/map'\nimport type {\n Source,\n SourceSpecification,\n} from 'mapbox-gl/src/style-spec/types.js'\n\nconst SourceContext = createContext<Source>()\n\nconst useSource = (): Source => useContext(SourceContext)\n\nconst SourceComponent: Component<{\n id?: string\n source: SourceSpecification\n}> = props => {\n const map: MapboxMap = useMap()\n props.id = props.id || createUniqueId()\n // Add Source\n onMount(async () => {\n !map().isStyleLoaded() && (await map().once('styledata'))\n !map().getSource(props.id) && map().addSource(props.id, props.source)\n })\n\n // Remove Source\n onCleanup(() => {\n map()\n .getStyle()\n .layers.forEach(\n layer => layer.source === props.id && map().removeLayer(layer.id)\n )\n map().getSource(props.id) && map().removeSource(props.id)\n })\n\n // Update GeoJSON Data\n createEffect(async () => {\n if (props.source.type !== 'geojson' && !props.source.data) return\n\n map().getSource(props.id) &&\n map().getSource(props.id).setData(props.source.data)\n })\n\n return (\n <SourceContext.Provider value={{ id: props.id }}>\n {props.children}\n </SourceContext.Provider>\n )\n}\n\nexport { SourceComponent as default, useSource }\n","import { onMount, createEffect, Component, createUniqueId } from 'solid-js'\nimport { useMap } from '../MapGL'\nimport { useSource } from '../Source'\nimport type MapboxMap from 'mapbox-gl/src/ui/map'\nimport type {\n FilterSpecification,\n StyleSpecification,\n SourceSpecification,\n} from 'mapbox-gl/src/style-spec/types.js'\nimport type { CustomLayerInterface } from 'mapbox-gl/src/style/style_layer/custom_style_layer'\n\nconst diff = (\n newProps: StyleSpecification = {},\n prevProps: StyleSpecification = {}\n) => {\n const keys = new Set([...Object.keys(newProps), ...Object.keys(prevProps)])\n return [...keys].reduce((acc, key: string) => {\n const value = newProps[key]\n if (value !== prevProps[key]) {\n acc.push([key, value])\n }\n return acc\n }, [])\n}\n\nconst Layer: Component<{\n id?: string\n style?: StyleSpecification\n layer?: CustomLayerInterface\n filter?: FilterSpecification\n visible?: boolean\n sourceId?: string\n beforeType?:\n | 'background'\n | 'fill'\n | 'line'\n | 'symbol'\n | 'raster'\n | 'circle'\n | 'fill-extrusion'\n | 'heatmap'\n | 'hillshade'\n | 'sky'\n beforeId?: string\n featureState?: { id: number | string; state: object }\n}> = props => {\n const map: MapboxMap = useMap()\n const source: SourceSpecification = useSource()\n props.id = props.id || createUniqueId()\n // Add Layer\n onMount(async () => {\n !map().isStyleLoaded() && (await map().once('styledata'))\n\n if (map().getLayer(props.id)) return\n\n map().addLayer(\n props.layer || {\n ...props.style,\n id: props.id,\n source: source.id,\n },\n props.beforeType\n ? map()\n .getStyle()\n .layers.find(l => l.type === props.beforeType).id\n : props.beforeId\n )\n })\n\n // Update Style\n createEffect(async (prev: StyleSpecification) => {\n if (\n !props.style ||\n !map().getSource(source.id) ||\n !map().getLayer(props.id)\n )\n return\n\n !map().isSourceLoaded(source.id) && (await map().once('data'))\n\n diff(props.style.paint, prev.paint).forEach(([key, value]) =>\n map().setPaintProperty(props.id, key, value)\n )\n\n diff(props.style.layout, prev.layout).forEach(([key, value]) =>\n map().setLayoutProperty(props.id, key, value)\n )\n\n if (\n props.style.minzoom !== prev.minzoom ||\n props.style.maxzoom !== prev.max\n )\n map().setLayerZoomRange(\n props.id,\n props.style.minzoom,\n props.style.maxzoom\n )\n\n return props.style\n }, props.style)\n\n // Update Visibility\n createEffect(async () => {\n if (\n props.visible === undefined ||\n !map().getSource(source.id) ||\n !map().getLayer(props.id)\n )\n return\n\n !map().isSourceLoaded(source.id) && (await map().once('data'))\n map().setLayoutProperty(\n props.id,\n 'visibility',\n props.visible ? 'visible' : 'none',\n { validate: false }\n )\n })\n\n // Update Filter\n createEffect(async () => {\n if (!props.filter) return\n\n !map().isStyleLoaded() && (await map().once('styledata'))\n map().setFilter(props.id, props.filter)\n })\n\n // Update Feature State\n createEffect(async () => {\n if (!props.featureState || !props.featureState.id) return\n\n map().loaded() ? null : await map().once('render')\n\n map().removeFeatureState({\n source: source.id,\n sourceLayer: props.style['source-layer'],\n })\n map().setFeatureState(\n {\n source: source.id,\n sourceLayer: props.style['source-layer'],\n id: props.featureState.id,\n },\n props.featureState.state\n )\n })\n\n return props.children\n}\n\nexport default Layer\n","import { onMount, onCleanup, createEffect, Component } from 'solid-js'\nimport { useMap } from '../MapGL'\nimport type MapboxMap from 'mapbox-gl/src/ui/map'\nimport type { FogSpecification } from 'mapbox-gl/src/style-spec/types.js'\n\nconst Fog: Component<{\n style: FogSpecification\n visible?: boolean\n}> = props => {\n const map: MapboxMap = useMap()\n // Add Fog Layer\n onMount(async () => {\n !map().isStyleLoaded() && (await map().once('styledata'))\n map().setFog(props.style)\n })\n // Remove Fog Layer\n onCleanup(() => map().setFog(null))\n\n // Update Visibility\n createEffect(async () => {\n if (props.visible === undefined) return\n\n !map().isStyleLoaded() && (await map().once('styledata'))\n map().setFog(props.visible ? props.style : null)\n })\n\n return props.children\n}\n\nexport default Fog\n","import { onMount, onCleanup, createEffect, Component } from 'solid-js'\nimport { useMap } from '../MapGL'\nimport type MapboxMap from 'mapbox-gl/src/ui/map'\nimport type { StyleSpecification } from 'mapbox-gl/src/style-spec/types.js'\n\nconst Sky: Component<{\n style: StyleSpecification\n visible?: boolean\n}> = props => {\n const map: MapboxMap = useMap()\n const layerId = '_sky'\n // Add Sky Layer\n onMount(async () => {\n !map().isStyleLoaded() && (await map().once('styledata'))\n !map().getLayer(layerId) && map().addLayer({ ...props.style, id: layerId })\n })\n\n // Remove Sky Layer\n onCleanup(() => map().getLayer(layerId) && map().removeLayer(layerId))\n\n // Update Visibility\n createEffect(async () => {\n if (props.visible === undefined) return\n\n !map().isStyleLoaded() && (await map().once('styledata'))\n map().setLayoutProperty(\n layerId,\n 'visibility',\n props.visible ? 'visible' : 'none'\n )\n })\n\n return props.children\n}\n\nexport default Sky\n","import { onMount, onCleanup, createEffect, Component } from 'solid-js'\nimport { useMap } from '../MapGL'\nimport { useSource } from '../Source'\nimport type MapboxMap from 'mapbox-gl/src/ui/map'\nimport type {\n TerrainSpecification,\n SourceSpecification,\n} from 'mapbox-gl/src/style-spec/types.js'\n\nconst Terrain: Component<{\n style: TerrainSpecification\n visible?: boolean\n}> = props => {\n const map: MapboxMap = useMap()\n const source: SourceSpecification = useSource()\n\n // Add Terrain Layer\n onMount(async () => {\n !map().isStyleLoaded() && (await map().once('styledata'))\n map().setTerrain({ ...props.style, source: source.id })\n })\n\n // Remove Terrain Layer\n onCleanup(() => map().setTerrain(null))\n\n // Update Visibility\n createEffect(async () => {\n if (props.visible === undefined) return\n\n !map().isStyleLoaded() && (await map().once('styledata'))\n map().setTerrain(props.visible ? props.style : null)\n })\n\n return props.children\n}\n\nexport default Terrain\n","import { onMount, onCleanup, createSignal, Component, lazy } from 'solid-js'\nimport { useMap } from '../MapGL'\nimport mapboxgl from 'mapbox-gl'\nimport type MapboxMap from 'mapbox-gl/src/ui/map'\nimport type { Options as AttributionOptions } from 'mapbox-gl/src/ui/control/attribution_control'\nimport type { Options as FullscreenOptions } from 'mapbox-gl/src/ui/control/fullscreen_control'\nimport type { Options as GeolocateOptions } from 'mapbox-gl/src/ui/control/geolocate_control'\nimport type { Options as NavigationOptions } from 'mapbox-gl/src/ui/control/navigation_control'\nimport type { Options as ScaleOptions } from 'mapbox-gl/src/ui/control/scale_control'\n\nconst Control: Component<{\n type:\n | 'navigation'\n | 'scale'\n | 'attribution'\n | 'fullscreen'\n | 'geolocate'\n | 'language'\n | 'traffic'\n options?:\n | NavigationOptions\n | ScaleOptions\n | AttributionOptions\n | FullscreenOptions\n | GeolocateOptions\n position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'\n}> = props => {\n const map: MapboxMap = useMap()\n const [control, setControl] = createSignal(null)\n // Add Control\n onMount(async () => {\n let control\n\n switch (props.type) {\n case 'navigation':\n control = new mapboxgl.NavigationControl(props.options)\n break\n case 'scale':\n control = new mapboxgl.ScaleControl(props.options)\n break\n case 'attribution':\n control = new mapboxgl.AttributionControl(props.options)\n break\n case 'fullscreen':\n control = new mapboxgl.FullscreenControl(props.options)\n break\n case 'geolocate':\n control = new mapboxgl.GeolocateControl(props.options)\n break\n // case 'language':\n // // @ts-ignore\n // const MapboxLanguage = (await import('@mapbox/mapbox-gl-language'))\n // .default\n // control = new MapboxLanguage(props.options)\n // break\n // case 'traffic':\n // // @ts-ignore\n // const MapboxTraffic = (await import('@mapbox/mapbox-gl-traffic'))\n // .default\n // // @ts-ignore\n // await import('@mapbox/mapbox-gl-traffic/mapbox-gl-traffic.css')\n // control = new MapboxTraffic(props.options)\n // break\n }\n control && map().addControl(control, props.position)\n setControl(control)\n })\n\n onCleanup(() => map().removeControl(control()))\n\n return props.children\n}\n\nexport default Control\n","import { onMount, onCleanup, createEffect, Component, children } from 'solid-js'\nimport { useMap } from '../MapGL'\nimport mapboxgl from 'mapbox-gl'\nimport type MapboxMap from 'mapbox-gl/src/ui/map'\nimport type { MarkerSpecification } from 'mapbox-gl/src/style-spec/types.js'\nimport type { LngLatLike } from 'mapbox-gl/src/geo/lng_lat.js'\n\nconst Marker: Component<{\n options?: MarkerSpecification\n lnglat: LngLatLike\n}> = props => {\n const map: MapboxMap = useMap()\n let marker = null\n\n // Add Marker\n onMount(async () => {\n marker = new mapboxgl.Marker(props.options)\n .setLngLat(props.lnglat)\n .setPopup(\n props.children\n ? new mapboxgl.Popup().setDOMContent(<div>{props.children}</div>)\n : null\n )\n .addTo(map())\n })\n // Remove Marker\n onCleanup(() => marker.remove())\n\n // Update Position\n createEffect(() => marker.setLngLat(props.lnglat))\n\n return <></>\n}\n\nexport default Marker\n","import { onMount, onCleanup, createEffect, Component } from 'solid-js'\nimport { useMap } from '../MapGL'\nimport mapboxgl from 'mapbox-gl'\nimport type MapboxMap from 'mapbox-gl/src/ui/map'\nimport type { PopupSpecification } from 'mapbox-gl/src/style-spec/types.js'\nimport type { LngLatLike } from 'mapbox-gl/src/geo/lng_lat.js'\n\nconst Popup: Component<{\n options?: PopupSpecification\n lnglat: LngLatLike\n}> = props => {\n const map: MapboxMap = useMap()\n let popup = null\n\n // Add Popup\n onMount(async () => {\n popup = new mapboxgl.Popup(props.options)\n .setLngLat(props.lnglat)\n .setDOMContent(<div>{props.children}</div>)\n .addTo(map())\n })\n // Remove Popup\n onCleanup(() => popup.remove())\n\n // Update Position\n createEffect(() => popup.setLngLat(props.lnglat))\n\n // Update Content\n createEffect(() => popup.setDOMContent(<div>{props.children}</div>))\n\n return <></>\n}\n\nexport default Popup\n","import { onMount, onCleanup, createEffect, Component } from 'solid-js'\nimport { useMap } from '../MapGL'\nimport type MapboxMap from 'mapbox-gl/src/ui/map'\nimport type {\n StyleImageInterface,\n StyleImageMetadata,\n} from 'mapbox-gl/src/style/style_image'\n\nconst Image: Component<{\n id: string\n url?: string\n image?:\n | HTMLImageElement\n | ImageBitmap\n | ImageData\n | { width: number; height: number; data: Uint8Array | Uint8ClampedArray }\n | StyleImageInterface\n options?: StyleImageMetadata\n}> = props => {\n const map: MapboxMap = useMap()\n // Add Image\n onMount(async () => {\n !map().isStyleLoaded() && (await map().once('styledata'))\n if (props.url) {\n map().loadImage(props.url, (error, image) => {\n if (error) throw error\n !map().hasImage(props.id) && map().addImage(props.id, image)\n })\n } else {\n !map().hasImage(props.id) &&\n map().addImage(props.id, props.image, props.options)\n }\n })\n // Remove Image\n onCleanup(() => map().hasImage(props.id) && map().removeImage(props.id))\n\n // Update Image\n createEffect(async () => {\n if (props.image && props.url) return\n\n if (props.url) {\n map().loadImage(props.url, (error, image) => {\n if (error) throw error\n !map().hasImage(props.id) && map().updateImage(props.id, image)\n })\n } else {\n map().hasImage(props.id) && map().updateImage(props.id, props.image)\n }\n })\n\n return <></>\n}\n\nexport default Image\n"],"names":["pending","start","useTransition","MapContext","createContext","useMap","useContext","MapGL","props","map","mapRef","onCleanup","remove","onMount","mapboxgl","Map","options","container","bounds","viewport","center","zoom","pitch","bearing","fitBoundsOptions","padding","createEffect","onMouseMove","on","event","lngLat","_onViewportChange","getCenter","getZoom","getPitch","getBearing","onViewportChange","async","fitBounds","index","triggerResize","window","requestAnimationFrame","loop","resize","Provider","value","children","class","classList","SourceContext","useSource","SourceComponent","id","createUniqueId","isStyleLoaded","once","getSource","addSource","source","getStyle","layers","forEach","layer","removeLayer","removeSource","type","data","setData","diff","newProps","prevProps","Set","Object","keys","reduce","acc","key","push","Layer","getLayer","addLayer","style","beforeType","find","l","beforeId","prev","isSourceLoaded","paint","setPaintProperty","layout","setLayoutProperty","minzoom","maxzoom","max","setLayerZoomRange","undefined","visible","validate","filter","setFilter","featureState","loaded","removeFeatureState","sourceLayer","setFeatureState","state","Fog","setFog","Sky","layerId","Terrain","setTerrain","Control","control","setControl","createSignal","NavigationControl","ScaleControl","AttributionControl","FullscreenControl","GeolocateControl","addControl","position","removeControl","Marker","marker","setLngLat","lnglat","setPopup","Popup","setDOMContent","addTo","popup","Image","url","loadImage","error","image","hasImage","addImage","removeImage","updateImage"],"mappings":"8QA0BM,CAACA,QAASC,OAASC,gBAEnBC,WAAaC,gBACbC,OAAS,IAAMC,WAAWH,YAE1BI,MAWDC,QACCC,EACAC,EAEJC,UAAU,IAAMF,EAAIG,UAEpBC,QAAQ,KACNJ,EAAM,IAAIK,SAASC,IAAI,IAClBP,EA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oI,SAASrI,EAAM6C,GAAIsF,KAGvDlI,IAAMmI,SAASpI,EAAM6C,KACpB5C,IAAMoI,SAASrI,EAAM6C,GAAI7C,EAAMmI,MAAOnI,EAAMQ,WAIlDL,UAAU,IAAMF,IAAMmI,SAASpI,EAAM6C,KAAO5C,IAAMqI,YAAYtI,EAAM6C,KAGpE3B,aAAaW,UACP7B,EAAMmI,OAASnI,EAAMgI,MAErBhI,EAAMgI,IACR/H,IAAMgI,UAAUjI,EAAMgI,IAAK,CAACE,EAAOC,QAC7BD,EAAO,MAAMA,EAChBjI,IAAMmI,SAASpI,EAAM6C,KAAO5C,IAAMsI,YAAYvI,EAAM6C,GAAIsF,KAG3DlI,IAAMmI,SAASpI,EAAM6C,KAAO5C,IAAMsI,YAAYvI,EAAM6C,GAAI7C,EAAMmI"}
|
|
@@ -24,13 +24,16 @@ const Control = props => {
|
|
|
24
24
|
control = new mapboxgl.GeolocateControl(props.options);
|
|
25
25
|
break;
|
|
26
26
|
// case 'language':
|
|
27
|
+
// // @ts-ignore
|
|
27
28
|
// const MapboxLanguage = (await import('@mapbox/mapbox-gl-language'))
|
|
28
29
|
// .default
|
|
29
30
|
// control = new MapboxLanguage(props.options)
|
|
30
31
|
// break
|
|
31
32
|
// case 'traffic':
|
|
33
|
+
// // @ts-ignore
|
|
32
34
|
// const MapboxTraffic = (await import('@mapbox/mapbox-gl-traffic'))
|
|
33
35
|
// .default
|
|
36
|
+
// // @ts-ignore
|
|
34
37
|
// await import('@mapbox/mapbox-gl-traffic/mapbox-gl-traffic.css')
|
|
35
38
|
// control = new MapboxTraffic(props.options)
|
|
36
39
|
// break
|
|
@@ -23,7 +23,7 @@ const Layer = props => {
|
|
|
23
23
|
map().addLayer(props.layer || {
|
|
24
24
|
...props.style,
|
|
25
25
|
id: props.id,
|
|
26
|
-
source: source.
|
|
26
|
+
source: source.id,
|
|
27
27
|
}, props.beforeType
|
|
28
28
|
? map()
|
|
29
29
|
.getStyle()
|
|
@@ -31,9 +31,12 @@ const Layer = props => {
|
|
|
31
31
|
: props.beforeId);
|
|
32
32
|
});
|
|
33
33
|
// Update Style
|
|
34
|
-
createEffect((prev) => {
|
|
35
|
-
if (!props.style
|
|
34
|
+
createEffect(async (prev) => {
|
|
35
|
+
if (!props.style ||
|
|
36
|
+
!map().getSource(source.id) ||
|
|
37
|
+
!map().getLayer(props.id))
|
|
36
38
|
return;
|
|
39
|
+
!map().isSourceLoaded(source.id) && (await map().once('data'));
|
|
37
40
|
diff(props.style.paint, prev.paint).forEach(([key, value]) => map().setPaintProperty(props.id, key, value));
|
|
38
41
|
diff(props.style.layout, prev.layout).forEach(([key, value]) => map().setLayoutProperty(props.id, key, value));
|
|
39
42
|
if (props.style.minzoom !== prev.minzoom ||
|
|
@@ -43,9 +46,11 @@ const Layer = props => {
|
|
|
43
46
|
}, props.style);
|
|
44
47
|
// Update Visibility
|
|
45
48
|
createEffect(async () => {
|
|
46
|
-
if (props.visible === undefined
|
|
49
|
+
if (props.visible === undefined ||
|
|
50
|
+
!map().getSource(source.id) ||
|
|
51
|
+
!map().getLayer(props.id))
|
|
47
52
|
return;
|
|
48
|
-
!map().
|
|
53
|
+
!map().isSourceLoaded(source.id) && (await map().once('data'));
|
|
49
54
|
map().setLayoutProperty(props.id, 'visibility', props.visible ? 'visible' : 'none', { validate: false });
|
|
50
55
|
});
|
|
51
56
|
// Update Filter
|
|
@@ -61,11 +66,11 @@ const Layer = props => {
|
|
|
61
66
|
return;
|
|
62
67
|
map().loaded() ? null : await map().once('render');
|
|
63
68
|
map().removeFeatureState({
|
|
64
|
-
source: source.
|
|
69
|
+
source: source.id,
|
|
65
70
|
sourceLayer: props.style['source-layer'],
|
|
66
71
|
});
|
|
67
72
|
map().setFeatureState({
|
|
68
|
-
source: source.
|
|
73
|
+
source: source.id,
|
|
69
74
|
sourceLayer: props.style['source-layer'],
|
|
70
75
|
id: props.featureState.id,
|
|
71
76
|
}, props.featureState.state);
|
|
@@ -24,7 +24,7 @@ const SourceComponent = props => {
|
|
|
24
24
|
map().getSource(props.id) &&
|
|
25
25
|
map().getSource(props.id).setData(props.source.data);
|
|
26
26
|
});
|
|
27
|
-
return (<SourceContext.Provider value={{
|
|
27
|
+
return (<SourceContext.Provider value={{ id: props.id }}>
|
|
28
28
|
{props.children}
|
|
29
29
|
</SourceContext.Provider>);
|
|
30
30
|
};
|
|
@@ -7,7 +7,7 @@ const Terrain = props => {
|
|
|
7
7
|
// Add Terrain Layer
|
|
8
8
|
onMount(async () => {
|
|
9
9
|
!map().isStyleLoaded() && (await map().once('styledata'));
|
|
10
|
-
map().setTerrain({ ...props.style, source: source.
|
|
10
|
+
map().setTerrain({ ...props.style, source: source.id });
|
|
11
11
|
});
|
|
12
12
|
// Remove Terrain Layer
|
|
13
13
|
onCleanup(() => map().setTerrain(null));
|
|
@@ -20,7 +20,7 @@ declare const MapGL: Component<{
|
|
|
20
20
|
};
|
|
21
21
|
viewport?: Viewport;
|
|
22
22
|
options?: MapboxOptions;
|
|
23
|
-
children?:
|
|
23
|
+
children?: Element[];
|
|
24
24
|
triggerResize?: boolean;
|
|
25
25
|
onMouseMove?: (event: MapMouseEvent) => void;
|
|
26
26
|
onViewportChange?: (viewport: Viewport) => void;
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.1.
|
|
2
|
+
"version": "1.1.5",
|
|
3
3
|
"name": "solid-map-gl",
|
|
4
4
|
"description": "Solid Component Library for Mapbox GL JS",
|
|
5
5
|
"author": "kaihuebner",
|
|
@@ -39,14 +39,14 @@
|
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"mapbox-gl": "^2.6.1",
|
|
42
|
-
"solid-js": "^1.
|
|
42
|
+
"solid-js": "^1.3.3"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@types/mapbox-gl": "^2.4.2",
|
|
46
|
-
"rollup": "^2.
|
|
46
|
+
"rollup": "^2.65.0",
|
|
47
47
|
"rollup-plugin-import-css": "^3.0.2",
|
|
48
48
|
"rollup-plugin-uglify": "^6.0.4",
|
|
49
|
-
"rollup-preset-solid": "^1.0
|
|
50
|
-
"typescript": "^4.
|
|
49
|
+
"rollup-preset-solid": "^1.1.0",
|
|
50
|
+
"typescript": "^4.5.5"
|
|
51
51
|
}
|
|
52
52
|
}
|