solid-map-gl 1.1.28 → 1.2.0

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.
Files changed (43) hide show
  1. package/README.md +3 -3
  2. package/dist/{esm/styles.css → cjs/index.css} +0 -0
  3. package/dist/cjs/index.js +2 -0
  4. package/dist/cjs/index.js.map +1 -0
  5. package/dist/esm/index.css +1 -0
  6. package/dist/esm/index.js +1 -1
  7. package/dist/esm/index.js.map +1 -1
  8. package/dist/index/components/Camera/index.d.ts +15 -0
  9. package/dist/index/components/Camera/index.jsx +49 -0
  10. package/dist/{types → index}/components/Control/index.d.ts +2 -2
  11. package/dist/{source → index}/components/Control/index.jsx +8 -6
  12. package/dist/{types → index}/components/Fog/index.d.ts +2 -2
  13. package/dist/index/components/Fog/index.jsx +21 -0
  14. package/dist/{types → index}/components/Image/index.d.ts +1 -2
  15. package/dist/{source → index}/components/Image/index.jsx +8 -10
  16. package/dist/{types → index}/components/Layer/index.d.ts +2 -2
  17. package/dist/{source → index}/components/Layer/index.jsx +28 -26
  18. package/dist/{types → index}/components/MapGL/index.d.ts +22 -5
  19. package/dist/{source → index}/components/MapGL/index.jsx +22 -15
  20. package/dist/{types → index}/components/Marker/index.d.ts +2 -2
  21. package/dist/{source → index}/components/Marker/index.jsx +6 -5
  22. package/dist/{types → index}/components/Popup/index.d.ts +2 -2
  23. package/dist/{source → index}/components/Popup/index.jsx +7 -6
  24. package/dist/{types → index}/components/Sky/index.d.ts +2 -2
  25. package/dist/index/components/Sky/index.jsx +22 -0
  26. package/dist/index/components/Source/index.d.ts +10 -0
  27. package/dist/index/components/Source/index.jsx +72 -0
  28. package/dist/{types → index}/components/Terrain/index.d.ts +2 -2
  29. package/dist/index/components/Terrain/index.jsx +23 -0
  30. package/dist/{types → index}/events.d.ts +0 -0
  31. package/dist/{source → index}/events.js +0 -0
  32. package/dist/index/index.d.ts +12 -0
  33. package/dist/index/index.jsx +11 -0
  34. package/dist/index/styles.d.ts +56 -0
  35. package/dist/index/styles.js +121 -0
  36. package/package.json +16 -14
  37. package/dist/source/components/Fog/index.jsx +0 -21
  38. package/dist/source/components/Sky/index.jsx +0 -22
  39. package/dist/source/components/Source/index.jsx +0 -32
  40. package/dist/source/components/Terrain/index.jsx +0 -23
  41. package/dist/source/index.jsx +0 -10
  42. package/dist/types/components/Source/index.d.ts +0 -8
  43. package/dist/types/index.d.ts +0 -11
@@ -1,20 +1,25 @@
1
1
  import { createSignal, createEffect, onMount, onCleanup, createContext, useContext, useTransition, createUniqueId, untrack, on, } from 'solid-js';
2
2
  import { mapEvents } from '../../events';
3
+ import { vectorStyleList } from '../../styles';
3
4
  import mapboxgl from 'mapbox-gl';
4
5
  import 'mapbox-gl/dist/mapbox-gl.css';
5
- const [pending, start] = useTransition();
6
- const [transitionType, setTransitionType] = createSignal('flyTo');
7
6
  const MapContext = createContext();
8
- const useMap = () => useContext(MapContext);
9
- const MapGL = props => {
7
+ /** Provides the Mapbox Map Object */
8
+ export const useMap = () => useContext(MapContext);
9
+ /** Creates a new Map Container */
10
+ export const MapGL = props => {
10
11
  let map;
11
12
  let mapRef;
12
13
  let containerRef;
13
14
  props.id = props.id || createUniqueId();
14
- onMount(() => {
15
+ const [mapRoot, setMapRoot] = createSignal();
16
+ const [pending, start] = useTransition();
17
+ const [transitionType, setTransitionType] = createSignal('flyTo');
18
+ onMount(async () => {
15
19
  map = new mapboxgl.Map({
16
20
  ...props.options,
17
- style: props.options?.style || { version: 8, sources: {}, layers: [] },
21
+ style: vectorStyleList[props.options?.style] ||
22
+ props.options?.style || { version: 8, sources: {}, layers: [] },
18
23
  container: mapRef,
19
24
  interactive: !!props.onViewportChange,
20
25
  bounds: props.viewport?.bounds,
@@ -25,6 +30,8 @@ const MapGL = props => {
25
30
  fitBoundsOptions: { padding: props.viewport?.padding },
26
31
  });
27
32
  map.container = containerRef;
33
+ await map.once('styledata');
34
+ setMapRoot(map);
28
35
  });
29
36
  onCleanup(() => map.remove());
30
37
  // Hook up events
@@ -43,14 +50,18 @@ const MapGL = props => {
43
50
  createEffect(() => (map.showCollisionBoxes = props.showCollisionBoxes));
44
51
  createEffect(() => (map.showOverdrawInspector = props.showOverdrawInspector));
45
52
  createEffect(() => (map.getCanvas().style.cursor = props.cursorStyle));
53
+ createEffect(() => setTransitionType(props.transitionType));
54
+ // Update projection
55
+ createEffect(on(() => props.options?.projection, proj => map.setProjection(proj), { defer: true }));
46
56
  // Update map style
47
- createEffect(on(() => props.options.style, () => {
57
+ createEffect(on(() => props.options?.style, style => {
48
58
  const oldStyle = map.getStyle();
49
59
  const oldLayers = oldStyle.layers.filter(l => l.id.startsWith('cl-'));
50
60
  const oldSources = Object.keys(oldStyle.sources)
51
61
  .filter(s => s.startsWith('cl-'))
52
62
  .reduce((obj, key) => ({ ...obj, [key]: oldStyle.sources[key] }), {});
53
- map.setStyle(props.options.style);
63
+ map.setStyle(vectorStyleList[style] ||
64
+ style || { version: 8, sources: {}, layers: [] });
54
65
  map.once('styledata', () => {
55
66
  const newStyle = map.getStyle();
56
67
  map.setStyle({
@@ -60,9 +71,6 @@ const MapGL = props => {
60
71
  });
61
72
  });
62
73
  }, { defer: true }));
63
- // Update projection
64
- createEffect(on(() => props.options.projection, () => map.setProjection(props.options.projection), { defer: true }));
65
- createEffect(() => setTransitionType(props.transitionType));
66
74
  // Hook up viewport events
67
75
  createEffect(() => {
68
76
  const viewport = {
@@ -129,11 +137,10 @@ const MapGL = props => {
129
137
  });
130
138
  }
131
139
  });
132
- return (<MapContext.Provider value={() => map}>
140
+ return (<MapContext.Provider value={mapRoot}>
133
141
  <section ref={containerRef} style={{ position: 'absolute', 'z-index': 1 }}>
134
- {props.children}
142
+ {props.children || null}
135
143
  </section>
136
- <div ref={mapRef} class={props.class || ''} classList={props.classList} style={{ height: '100%', width: '100%', ...props.style }}/>
144
+ <div ref={mapRef} class={props.class || null} classList={props.classList || null} style={{ height: '100%', width: '100%', ...props.style }}/>
137
145
  </MapContext.Provider>);
138
146
  };
139
- export { MapGL as default, useMap };
@@ -1,8 +1,8 @@
1
1
  import { Component } from 'solid-js';
2
2
  import type { MarkerSpecification } from 'mapbox-gl/src/style-spec/types.js';
3
3
  import type { LngLatLike } from 'mapbox-gl/src/geo/lng_lat.js';
4
- declare const Marker: Component<{
4
+ export declare const Marker: Component<{
5
5
  options?: MarkerSpecification;
6
6
  lnglat: LngLatLike;
7
+ children?: any;
7
8
  }>;
8
- export default Marker;
@@ -1,11 +1,13 @@
1
- import { onMount, onCleanup, createEffect } from 'solid-js';
1
+ import { onCleanup, createEffect } from 'solid-js';
2
2
  import { useMap } from '../MapGL';
3
3
  import mapboxgl from 'mapbox-gl';
4
- const Marker = props => {
4
+ export const Marker = props => {
5
5
  const map = useMap();
6
6
  let marker = null;
7
7
  // Add Marker
8
- onMount(async () => {
8
+ createEffect(() => {
9
+ if (!map())
10
+ return;
9
11
  marker = new mapboxgl.Marker(props.options)
10
12
  .setLngLat(props.lnglat)
11
13
  .setPopup(props.children
@@ -16,7 +18,6 @@ const Marker = props => {
16
18
  // Remove Marker
17
19
  onCleanup(() => marker.remove());
18
20
  // Update Position
19
- createEffect(() => marker.setLngLat(props.lnglat));
21
+ createEffect(() => marker && marker.setLngLat(props.lnglat));
20
22
  return <></>;
21
23
  };
22
- export default Marker;
@@ -1,8 +1,8 @@
1
1
  import { Component } from 'solid-js';
2
2
  import type { PopupSpecification } from 'mapbox-gl/src/style-spec/types.js';
3
3
  import type { LngLatLike } from 'mapbox-gl/src/geo/lng_lat.js';
4
- declare const Popup: Component<{
4
+ export declare const Popup: Component<{
5
5
  options?: PopupSpecification;
6
6
  lnglat: LngLatLike;
7
+ children?: any;
7
8
  }>;
8
- export default Popup;
@@ -1,11 +1,13 @@
1
- import { onMount, onCleanup, createEffect } from 'solid-js';
1
+ import { onCleanup, createEffect } from 'solid-js';
2
2
  import { useMap } from '../MapGL';
3
3
  import mapboxgl from 'mapbox-gl';
4
- const Popup = props => {
4
+ export const Popup = props => {
5
5
  const map = useMap();
6
6
  let popup = null;
7
7
  // Add Popup
8
- onMount(async () => {
8
+ createEffect(() => {
9
+ if (!map())
10
+ return;
9
11
  popup = new mapboxgl.Popup(props.options)
10
12
  .setLngLat(props.lnglat)
11
13
  .setDOMContent(<div>{props.children}</div>)
@@ -14,9 +16,8 @@ const Popup = props => {
14
16
  // Remove Popup
15
17
  onCleanup(() => popup.remove());
16
18
  // Update Position
17
- createEffect(() => popup.setLngLat(props.lnglat));
19
+ createEffect(() => popup && popup.setLngLat(props.lnglat));
18
20
  // Update Content
19
- createEffect(() => popup.setDOMContent(<div>{props.children}</div>));
21
+ createEffect(() => popup && popup.setDOMContent(<div>{props.children}</div>));
20
22
  return <></>;
21
23
  };
22
- export default Popup;
@@ -1,7 +1,7 @@
1
1
  import { Component } from 'solid-js';
2
2
  import type { StyleSpecification } from 'mapbox-gl/src/style-spec/types.js';
3
- declare const Sky: Component<{
3
+ export declare const Sky: Component<{
4
4
  style: StyleSpecification;
5
5
  visible?: boolean;
6
+ children?: any;
6
7
  }>;
7
- export default Sky;
@@ -0,0 +1,22 @@
1
+ import { onCleanup, createEffect } from 'solid-js';
2
+ import { useMap } from '../MapGL';
3
+ export const Sky = props => {
4
+ const map = useMap();
5
+ const layerId = '_sky';
6
+ // Add Sky Layer
7
+ createEffect(() => {
8
+ if (!map())
9
+ return;
10
+ map().getLayer(layerId) && map().addLayer({ ...props.style, id: layerId });
11
+ });
12
+ // Remove Sky Layer
13
+ onCleanup(() => map().getLayer(layerId) && map().removeLayer(layerId));
14
+ // Update Visibility
15
+ createEffect(() => {
16
+ if (!map())
17
+ return;
18
+ props.visible !== undefined &&
19
+ map().setLayoutProperty(layerId, 'visibility', props.visible ? 'visible' : 'none');
20
+ });
21
+ return props.children;
22
+ };
@@ -0,0 +1,10 @@
1
+ import { Component } from 'solid-js';
2
+ import type { SourceSpecification } from 'mapbox-gl/src/style-spec/types.js';
3
+ export declare const useSourceId: () => string;
4
+ export declare const Source: Component<{
5
+ /** @optional Source ID for referencing non nexted Layers */
6
+ id?: string;
7
+ /** @see https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/ */
8
+ source: SourceSpecification;
9
+ children?: any;
10
+ }>;
@@ -0,0 +1,72 @@
1
+ import { onCleanup, createEffect, createContext, useContext, createUniqueId, } from 'solid-js';
2
+ import { useMap } from '../MapGL';
3
+ import { rasterStyleList } from '../../styles';
4
+ const SourceContext = createContext();
5
+ export const useSourceId = () => useContext(SourceContext);
6
+ export const Source = props => {
7
+ const map = useMap();
8
+ props.id = props.id || createUniqueId();
9
+ const lookup = url => rasterStyleList[url]
10
+ ? {
11
+ ...props.source,
12
+ url: '',
13
+ tiles: [
14
+ rasterStyleList[url][0].replace('{apikey}', props.source.apikey),
15
+ ],
16
+ attribution: rasterStyleList[url][1],
17
+ }
18
+ : props.source;
19
+ // Add Source
20
+ createEffect(() => {
21
+ if (!map())
22
+ return;
23
+ const source = lookup(props.source.url);
24
+ source.tiles &&
25
+ (source.tiles = ['a', 'b', 'c'].map(i => source.tiles[0].replace('{s}', i)));
26
+ !map().getSource(props.id) && map().addSource(props.id, source);
27
+ });
28
+ // Remove Source
29
+ onCleanup(() => {
30
+ map()
31
+ .getStyle()
32
+ .layers.forEach(layer => layer.source === props.id && map().removeLayer(layer.id));
33
+ map().getSource(props.id) && map().removeSource(props.id);
34
+ });
35
+ // Update
36
+ createEffect(() => {
37
+ if (!map())
38
+ return;
39
+ const source = map().getSource(props.id);
40
+ if (!source)
41
+ return;
42
+ // Update GeoJSON Data
43
+ if (props.source.type === 'geojson' && props.source.data)
44
+ source.setData(props.source.data);
45
+ // Update Image URL
46
+ if (props.source.type === 'image' &&
47
+ (props.source.url || props.source.coordinates))
48
+ source.updateImage(props.source.url, props.source.coordinates);
49
+ // Update Vector URL or Tiles
50
+ if (props.source.type === 'vector' &&
51
+ (props.source.url || props.source.tiles))
52
+ props.source.url
53
+ ? source.setUrl(props.source.url)
54
+ : source.setTiles(props.source.tiles);
55
+ // Update Raster URL or Tiles
56
+ if (props.source.type === 'raster' &&
57
+ (props.source.url || props.source.tiles)) {
58
+ const src = lookup(props.source.url);
59
+ src.tiles &&
60
+ (src.tiles = ['a', 'b', 'c'].map(i => src.tiles[0].replace('{s}', i)));
61
+ source._tileJSONRequest?.cancel();
62
+ source.url = src.url;
63
+ source.scheme = src.scheme;
64
+ source._options = { ...source._options, ...src };
65
+ map().style._sourceCaches[`other:${props.id}`]?.clearTiles();
66
+ source.load();
67
+ }
68
+ });
69
+ return (<SourceContext.Provider value={props.id}>
70
+ {props.children}
71
+ </SourceContext.Provider>);
72
+ };
@@ -1,7 +1,7 @@
1
1
  import { Component } from 'solid-js';
2
2
  import type { TerrainSpecification } from 'mapbox-gl/src/style-spec/types.js';
3
- declare const Terrain: Component<{
3
+ export declare const Terrain: Component<{
4
4
  style: TerrainSpecification;
5
5
  visible?: boolean;
6
+ children?: any;
6
7
  }>;
7
- export default Terrain;
@@ -0,0 +1,23 @@
1
+ import { onCleanup, createEffect } from 'solid-js';
2
+ import { useMap } from '../MapGL';
3
+ import { useSourceId } from '../Source';
4
+ export const Terrain = props => {
5
+ const map = useMap();
6
+ const sourceId = useSourceId();
7
+ // Add Terrain Layer
8
+ createEffect(() => {
9
+ if (!map())
10
+ return;
11
+ map().setTerrain({ ...props.style, source: sourceId });
12
+ });
13
+ // Remove Terrain Layer
14
+ onCleanup(() => map().setTerrain(null));
15
+ // Update Visibility
16
+ createEffect(() => {
17
+ if (!map())
18
+ return;
19
+ props.visible !== undefined &&
20
+ map().setTerrain(props.visible ? props.style : null);
21
+ });
22
+ return props.children;
23
+ };
File without changes
File without changes
@@ -0,0 +1,12 @@
1
+ export { MapGL as default, useMap } from './components/MapGL';
2
+ export { Source, useSourceId } from './components/Source';
3
+ export { Layer } from './components/Layer';
4
+ export { Fog } from './components/Fog';
5
+ export { Sky } from './components/Sky';
6
+ export { Terrain } from './components/Terrain';
7
+ export { Control } from './components/Control';
8
+ export { Marker } from './components/Marker';
9
+ export { Popup } from './components/Popup';
10
+ export { Image } from './components/Image';
11
+ export { Camera } from './components/Camera';
12
+ export type { Viewport } from './components/MapGL';
@@ -0,0 +1,11 @@
1
+ export { MapGL as default, useMap } from './components/MapGL';
2
+ export { Source, useSourceId } from './components/Source';
3
+ export { Layer } from './components/Layer';
4
+ export { Fog } from './components/Fog';
5
+ export { Sky } from './components/Sky';
6
+ export { Terrain } from './components/Terrain';
7
+ export { Control } from './components/Control';
8
+ export { Marker } from './components/Marker';
9
+ export { Popup } from './components/Popup';
10
+ export { Image } from './components/Image';
11
+ export { Camera } from './components/Camera';
@@ -0,0 +1,56 @@
1
+ export declare const vectorStyleList: {
2
+ 'mb:light': string;
3
+ 'mb:dark': string;
4
+ 'mb:streets': string;
5
+ 'mb:outdoor': string;
6
+ 'mb:sat': string;
7
+ 'mb:sat-streets': string;
8
+ 'mb:nav': string;
9
+ 'mb:nav-night': string;
10
+ 'mb:basic': string;
11
+ 'mb:monochrome': string;
12
+ 'mb:leshine': string;
13
+ 'mb:icecream': string;
14
+ 'mb:cali': string;
15
+ 'mb:northstar': string;
16
+ 'mb:mineral': string;
17
+ 'mb:moonlight': string;
18
+ 'mb:frank': string;
19
+ 'mb:minimo': string;
20
+ 'mb:decimal': string;
21
+ 'mb:standard': string;
22
+ 'mb:blueprint': string;
23
+ 'mb:bubble': string;
24
+ 'mb:pencil': string;
25
+ 'mb:swiss-ski': string;
26
+ 'mb:vintage': string;
27
+ 'mb:whaam': string;
28
+ 'mb:neon': string;
29
+ 'mb:camoflauge': string;
30
+ 'mb:emerald': string;
31
+ 'mb:runner': string;
32
+ 'mb:x-ray': string;
33
+ };
34
+ export declare const rasterStyleList: {
35
+ 'osm:org': string[];
36
+ 'osm:human': string[];
37
+ 'osm:cycle': string[];
38
+ 'carto:voyager': string[];
39
+ 'carto:positron': string[];
40
+ 'carto:dark': string[];
41
+ 'open:topo': string[];
42
+ 'stamen:toner': string[];
43
+ 'stamen:toner-lite': string[];
44
+ 'stamen:watercolor': string[];
45
+ 'stamen:terrain': string[];
46
+ 'tf:cycle': string[];
47
+ 'tf:trans': string[];
48
+ 'tf:trans-dark': string[];
49
+ 'tf:landscape': string[];
50
+ 'tf:outdoors': string[];
51
+ 'tf:neighbourhood': string[];
52
+ 'tf:spinal': string[];
53
+ 'tf:pioneer': string[];
54
+ 'tf:atlas': string[];
55
+ 'tf:mobile': string[];
56
+ };
@@ -0,0 +1,121 @@
1
+ const mapBase = 'mapbox://styles/mapbox';
2
+ const gitBase = 'https://raw.githubusercontent.com';
3
+ export const vectorStyleList = {
4
+ 'mb:light': `${mapBase}/light-v10`,
5
+ 'mb:dark': `${mapBase}/dark-v10`,
6
+ 'mb:streets': `${mapBase}/streets-v11`,
7
+ 'mb:outdoor': `${mapBase}/outdoors-v11`,
8
+ 'mb:sat': `${mapBase}/satellite-v9`,
9
+ 'mb:sat-streets': `${mapBase}/satellite-streets-v11`,
10
+ 'mb:nav': `${mapBase}/navigation-guidance-day-v4`,
11
+ 'mb:nav-night': `${mapBase}/navigation-guidance-night-v4`,
12
+ 'mb:basic': `${mapBase}/cjf4m44iw0uza2spb3q0a7s41`,
13
+ 'mb:monochrome': `${mapBase}/cjv6rzz4j3m4b1fqcchuxclhb`,
14
+ 'mb:leshine': `${mapBase}/cjcunv5ae262f2sm9tfwg8i0w`,
15
+ 'mb:icecream': `${mapBase}/cj7t3i5yj0unt2rmt3y4b5e32`,
16
+ 'mb:cali': `${mapBase}/cjerxnqt3cgvp2rmyuxbeqme7`,
17
+ 'mb:northstar': `${mapBase}/cj44mfrt20f082snokim4ungi`,
18
+ 'mb:mineral': `${mapBase}/cjtep62gq54l21frr1whf27ak`,
19
+ 'mb:moonlight': `${mapBase}/cj3kbeqzo00022smj7akz3o1e`,
20
+ 'mb:frank': `${mapBase}-map-design/ckshxkppe0gge18nz20i0nrwq`,
21
+ 'mb:minimo': `${mapBase}-map-design/cksjc2nsq1bg117pnekb655h1`,
22
+ 'mb:decimal': `${mapBase}-map-design/ck4014y110wt61ctt07egsel6`,
23
+ 'mb:standard': `${mapBase}-map-design/ckr0svm3922ki18qntevm857n`,
24
+ 'mb:blueprint': `${mapBase}-map-design/cks97e1e37nsd17nzg7p0308g`,
25
+ 'mb:bubble': `${mapBase}-map-design/cksysy2nl62zp17quosctdtcc`,
26
+ 'mb:pencil': `${mapBase}-map-design/cks9iema71es417mlrft4go2k`,
27
+ 'mb:swiss-ski': `${gitBase}/mapbox/mapbox-gl-swiss-ski-style/master/cij1zoclj002y8rkkdjl69psd.json`,
28
+ 'mb:vintage': `${gitBase}/mapbox/mapbox-gl-vintage-style/master/cif5p01n202nisaktvljx9mv3.json`,
29
+ 'mb:whaam': `${gitBase}/mapbox/mapbox-gl-whaam-style/master/cii8323c8004w0nlvtss3dbm2.json`,
30
+ 'mb:neon': `${gitBase}/NatEvatt/awesome-mapbox-gl-styles/master/styles/Neon/style.json`,
31
+ 'mb:camoflauge': `${gitBase}/jingsam/mapbox-gl-styles/master/Camouflage.json`,
32
+ 'mb:emerald': `${gitBase}/jingsam/mapbox-gl-styles/master/Emerald.json`,
33
+ 'mb:runner': `${gitBase}/jingsam/mapbox-gl-styles/master/Runner.json`,
34
+ 'mb:x-ray': `${gitBase}/jingsam/mapbox-gl-styles/master/X-ray.json`,
35
+ };
36
+ export const rasterStyleList = {
37
+ 'osm:org': [
38
+ 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
39
+ 'Map &copy; <a href="https://www.openstreetmap.org"><em>OpenStreetMap</em></a>',
40
+ ],
41
+ 'osm:human': [
42
+ 'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',
43
+ 'Map &copy; <a href="http://hot.openstreetmap.org"><em>Humanitarian OpenStreetMap Team</em></a>',
44
+ ],
45
+ 'osm:cycle': [
46
+ 'https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png',
47
+ 'Maps &copy; <a href="https://www.cyclosm.org" target="_blank"><em>CyclOSM</em></a>, Data &copy; <a href="http://www.openstreetmap.org/copyright" target="_blank"><em>OpenStreetMap</em></a>',
48
+ ],
49
+ 'carto:voyager': [
50
+ 'https://{s}.basemaps.cartocdn.com/rastertiles/voyager_labels_under/{z}/{x}/{y}.png',
51
+ 'Maps &copy; <a href="https://carto.com/attribution"><em>Carto</em></a>',
52
+ ],
53
+ 'carto:positron': [
54
+ 'https://{s}.basemaps.cartocdn.com/rastertiles/light_all/{z}/{x}/{y}.png',
55
+ 'Maps &copy; <a href="https://carto.com/attribution"><em>Carto</em></a>',
56
+ ],
57
+ 'carto:dark': [
58
+ 'https://{s}.basemaps.cartocdn.com/rastertiles/dark_all/{z}/{x}/{y}.png',
59
+ 'Maps &copy; <a href="https://carto.com/attribution"><em>Carto</em></a>',
60
+ ],
61
+ 'open:topo': [
62
+ 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',
63
+ 'Maps &copy; <a href="https://opentopomap.org/credits"><em>OpenTopoMap</em></a>, Data &copy; <a href="http://www.openstreetmap.org/copyright" target="_blank"><em>OpenStreetMap</em></a>',
64
+ ],
65
+ 'stamen:toner': [
66
+ 'https://stamen-tiles-{s}.a.ssl.fastly.net/toner/{z}/{x}/{y}.png',
67
+ 'Maps &copy; <a href="https://stamen.com" target="_blank"><em>Stamen Design</em></a>, Data &copy; <a href="http://www.openstreetmap.org/copyright" target="_blank"><em>OpenStreetMap</em></a>',
68
+ ],
69
+ 'stamen:toner-lite': [
70
+ 'https://stamen-tiles-{s}.a.ssl.fastly.net/toner-lite/{z}/{x}/{y}.png',
71
+ 'Maps &copy; <a href="https://stamen.com" target="_blank"><em>Stamen Design</em></a>, Data &copy; <a href="http://www.openstreetmap.org/copyright" target="_blank"><em>OpenStreetMap</em></a>',
72
+ ],
73
+ 'stamen:watercolor': [
74
+ 'https://stamen-tiles-{s}.a.ssl.fastly.net/watercolor/{z}/{x}/{y}.jpg',
75
+ 'Maps &copy; <a href="https://stamen.com" target="_blank"><em>Stamen Design</em></a>, Data &copy; <a href="http://www.openstreetmap.org/copyright" target="_blank"><em>OpenStreetMap</em></a>',
76
+ ],
77
+ 'stamen:terrain': [
78
+ 'https://stamen-tiles-{s}.a.ssl.fastly.net/terrain/{z}/{x}/{y}.jpg',
79
+ 'Maps &copy; <a href="https://stamen.com" target="_blank"><em>Stamen Design</em></a>, Data &copy; <a href="http://www.openstreetmap.org/copyright" target="_blank"><em>OpenStreetMap</em></a>',
80
+ ],
81
+ 'tf:cycle': [
82
+ 'https://{s}.tile.thunderforest.com/cycle/{z}/{x}/{y}@2x.png?apikey={apikey}',
83
+ 'Maps &copy; <a href="https://thunderforest.com" target="_blank"><em>Thunderforest</em></a>, Data &copy; <a href="http://www.openstreetmap.org/copyright" target="_blank"><em>OpenStreetMap</em></a>',
84
+ ],
85
+ 'tf:trans': [
86
+ 'https://{s}.tile.thunderforest.com/transport/{z}/{x}/{y}.png?apikey={apikey}',
87
+ 'Maps &copy; <a href="https://thunderforest.com" target="_blank"><em>Thunderforest</em></a>, Data &copy; <a href="http://www.openstreetmap.org/copyright" target="_blank"><em>OpenStreetMap</em></a>',
88
+ ],
89
+ 'tf:trans-dark': [
90
+ 'https://{s}.tile.thunderforest.com/transport-dark/{z}/{x}/{y}.png?apikey={apikey}',
91
+ 'Maps &copy; <a href="https://thunderforest.com" target="_blank"><em>Thunderforest</em></a>, Data &copy; <a href="http://www.openstreetmap.org/copyright" target="_blank"><em>OpenStreetMap</em></a>',
92
+ ],
93
+ 'tf:landscape': [
94
+ 'https://{s}.tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey={apikey}',
95
+ 'Maps &copy; <a href="https://thunderforest.com" target="_blank"><em>Thunderforest</em></a>, Data &copy; <a href="http://www.openstreetmap.org/copyright" target="_blank"><em>OpenStreetMap</em></a>',
96
+ ],
97
+ 'tf:outdoors': [
98
+ 'https://{s}.tile.thunderforest.com/outdoors/{z}/{x}/{y}.png?apikey={apikey}',
99
+ 'Maps &copy; <a href="https://thunderforest.com" target="_blank"><em>Thunderforest</em></a>, Data &copy; <a href="http://www.openstreetmap.org/copyright" target="_blank"><em>OpenStreetMap</em></a>',
100
+ ],
101
+ 'tf:neighbourhood': [
102
+ 'https://{s}.tile.thunderforest.com/neighbourhood/{z}/{x}/{y}.png?apikey={apikey}',
103
+ 'Maps &copy; <a href="https://thunderforest.com" target="_blank"><em>Thunderforest</em></a>, Data &copy; <a href="http://www.openstreetmap.org/copyright" target="_blank"><em>OpenStreetMap</em></a>',
104
+ ],
105
+ 'tf:spinal': [
106
+ 'https://{s}.tile.thunderforest.com/spinal-map/{z}/{x}/{y}.png?apikey={apikey}',
107
+ 'Maps &copy; <a href="https://thunderforest.com" target="_blank"><em>Thunderforest</em></a>, Data &copy; <a href="http://www.openstreetmap.org/copyright" target="_blank"><em>OpenStreetMap</em></a>',
108
+ ],
109
+ 'tf:pioneer': [
110
+ 'https://{s}.tile.thunderforest.com/pioneer/{z}/{x}/{y}.png?apikey={apikey}',
111
+ 'Maps &copy; <a href="https://thunderforest.com" target="_blank"><em>Thunderforest</em></a>, Data &copy; <a href="http://www.openstreetmap.org/copyright" target="_blank"><em>OpenStreetMap</em></a>',
112
+ ],
113
+ 'tf:atlas': [
114
+ 'https://{s}.tile.thunderforest.com/atlas/{z}/{x}/{y}.png?apikey={apikey}',
115
+ 'Maps &copy; <a href="https://thunderforest.com" target="_blank"><em>Thunderforest</em></a>, Data &copy; <a href="http://www.openstreetmap.org/copyright" target="_blank"><em>OpenStreetMap</em></a>',
116
+ ],
117
+ 'tf:mobile': [
118
+ 'https://{s}.tile.thunderforest.com/mobile-atlas/{z}/{x}/{y}.png?apikey={apikey}',
119
+ 'Maps &copy; <a href="https://thunderforest.com" target="_blank"><em>Thunderforest</em></a>, Data &copy; <a href="http://www.openstreetmap.org/copyright" target="_blank"><em>OpenStreetMap</em></a>',
120
+ ],
121
+ };
package/package.json CHANGED
@@ -1,9 +1,8 @@
1
1
  {
2
- "version": "1.1.28",
2
+ "version": "1.2.0",
3
3
  "name": "solid-map-gl",
4
4
  "description": "Solid Component Library for Mapbox GL JS",
5
5
  "info": "Solid Component Library for Mapbox GL JS. Mapbox GL JS is a JavaScript library that renders interactive maps from vector tiles and Mapbox styles using WebGL. This project is intended to be as close as possible to the Mapbox GL JS API.",
6
- "homepage": "https://determined-mirzakhani-29bbc7.netlify.app",
7
6
  "author": "kaihuebner",
8
7
  "contributors": [
9
8
  {
@@ -18,26 +17,30 @@
18
17
  "mapbox-gl",
19
18
  "mapbox-gl-js",
20
19
  "mapbox",
21
- "solidjs",
22
- "solidhack",
23
- "best_ecosystem"
20
+ "solidjs"
24
21
  ],
25
22
  "license": "MIT",
26
23
  "type": "module",
27
24
  "files": [
28
25
  "dist"
29
26
  ],
27
+ "source": "dist/index/index.jsx",
30
28
  "main": "dist/esm/index.js",
31
29
  "module": "dist/esm/index.js",
32
30
  "types": "dist/types/index.d.ts",
33
31
  "exports": {
34
32
  ".": {
35
- "solid": "./dist/source/index.jsx",
36
- "default": "./dist/esm/index.js"
33
+ "solid": "./dist/index/index.jsx",
34
+ "default": "./dist/esm/index.js",
35
+ "import": "./dist/esm/index.js",
36
+ "browser": "./dist/esm/index.js",
37
+ "require": "./dist/cjs/index.js",
38
+ "node": "./dist/cjs/index.js"
37
39
  }
38
40
  },
39
41
  "scripts": {
40
42
  "build": "rollup -c",
43
+ "watch": "rollup -c -w",
41
44
  "test": "vitest"
42
45
  },
43
46
  "repository": {
@@ -49,20 +52,19 @@
49
52
  "not ie 11"
50
53
  ],
51
54
  "dependencies": {
52
- "mapbox-gl": "^2.8.0",
53
- "solid-js": "^1.3.14"
55
+ "mapbox-gl": "^2.8.2",
56
+ "solid-js": "1.4.2"
54
57
  },
55
58
  "devDependencies": {
56
- "canvas": "^2.9.1",
57
59
  "jsdom": "^19.0.0",
58
- "rollup": "^2.70.1",
60
+ "rollup": "^2.74.1",
59
61
  "rollup-plugin-import-css": "^3.0.3",
60
62
  "rollup-plugin-uglify": "^6.0.4",
61
63
  "rollup-preset-solid": "^1.4.0",
62
64
  "solid-testing-library": "^0.3.0",
63
- "typescript": "^4.6.3",
64
- "vite": "^2.9.1",
65
+ "typescript": "^4.6.4",
66
+ "vite": "^2.9.9",
65
67
  "vite-plugin-solid": "^2.2.6",
66
- "vitest": "^0.9.3"
68
+ "vitest": "^0.12.7"
67
69
  }
68
70
  }
@@ -1,21 +0,0 @@
1
- import { onMount, onCleanup, createEffect } from 'solid-js';
2
- import { useMap } from '../MapGL';
3
- const Fog = props => {
4
- const map = useMap();
5
- // Add Fog Layer
6
- onMount(async () => {
7
- !map().isStyleLoaded() && (await map().once('styledata'));
8
- map().setFog(props.style);
9
- });
10
- // Remove Fog Layer
11
- onCleanup(() => map().setFog(null));
12
- // Update Visibility
13
- createEffect(async () => {
14
- if (props.visible === undefined)
15
- return;
16
- !map().isStyleLoaded() && (await map().once('styledata'));
17
- map().setFog(props.visible ? props.style : null);
18
- });
19
- return props.children;
20
- };
21
- export default Fog;
@@ -1,22 +0,0 @@
1
- import { onMount, onCleanup, createEffect } from 'solid-js';
2
- import { useMap } from '../MapGL';
3
- const Sky = props => {
4
- const map = useMap();
5
- const layerId = '_sky';
6
- // Add Sky Layer
7
- onMount(async () => {
8
- !map().isStyleLoaded() && (await map().once('styledata'));
9
- !map().getLayer(layerId) && map().addLayer({ ...props.style, id: layerId });
10
- });
11
- // Remove Sky Layer
12
- onCleanup(() => map().getLayer(layerId) && map().removeLayer(layerId));
13
- // Update Visibility
14
- createEffect(async () => {
15
- if (props.visible === undefined)
16
- return;
17
- !map().isStyleLoaded() && (await map().once('styledata'));
18
- map().setLayoutProperty(layerId, 'visibility', props.visible ? 'visible' : 'none');
19
- });
20
- return props.children;
21
- };
22
- export default Sky;