solid-map-gl 1.8.0 → 1.8.2
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/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/source/components/Atmosphere/index.jsx +4 -4
- package/dist/source/components/Camera/index.jsx +27 -25
- package/dist/source/components/Control/index.jsx +16 -28
- package/dist/source/components/Draw/index.jsx +6 -6
- package/dist/source/components/Image/index.jsx +14 -14
- package/dist/source/components/Layer/index.jsx +19 -19
- package/dist/source/components/Light/index.jsx +4 -4
- package/dist/source/components/MapGL/index.jsx +18 -24
- package/dist/source/components/MapProvider/index.jsx +8 -11
- package/dist/source/components/Marker/index.jsx +5 -5
- package/dist/source/components/Popup/index.jsx +5 -5
- package/dist/source/components/Source/index.jsx +13 -13
- package/dist/source/components/Terrain/index.jsx +8 -8
- package/dist/source/index.jsx +1 -1
- package/dist/types/components/Control/index.d.ts +2 -1
- package/dist/types/components/MapProvider/index.d.ts +7 -4
- package/dist/types/index.d.ts +1 -1
- package/package.json +2 -2
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { onCleanup, createEffect, createContext, useContext, createUniqueId, } from 'solid-js';
|
|
2
|
-
import {
|
|
2
|
+
import { useMapContext } from '../MapProvider';
|
|
3
3
|
import { rasterStyleList } from '../../mapStyles';
|
|
4
4
|
const SourceContext = createContext();
|
|
5
5
|
export const useSourceId = () => useContext(SourceContext);
|
|
6
6
|
export const Source = props => {
|
|
7
|
-
const [
|
|
7
|
+
const [ctx] = useMapContext();
|
|
8
8
|
props.id ??= createUniqueId();
|
|
9
9
|
const debug = (text, value) => {
|
|
10
|
-
map
|
|
10
|
+
ctx.map.debug &&
|
|
11
11
|
console.debug('%c[MapGL]', 'color: #ec4899', text, value || '');
|
|
12
12
|
};
|
|
13
13
|
const lookup = url => {
|
|
@@ -30,16 +30,16 @@ export const Source = props => {
|
|
|
30
30
|
return source;
|
|
31
31
|
};
|
|
32
32
|
// Add Source
|
|
33
|
-
map
|
|
34
|
-
map
|
|
33
|
+
ctx.map.addSource(props.id, lookup(props.source.url));
|
|
34
|
+
ctx.map.sourceIdList.push(props.id);
|
|
35
35
|
debug('Add Source:', props.id);
|
|
36
36
|
// Update Data
|
|
37
|
-
const source = map
|
|
37
|
+
const source = ctx.map.getSource(props.id);
|
|
38
38
|
switch (props.source.type) {
|
|
39
39
|
case 'geojson':
|
|
40
40
|
createEffect(() => {
|
|
41
41
|
const data = props.source.data;
|
|
42
|
-
if (!map
|
|
42
|
+
if (!ctx.map.isSourceLoaded(props.id))
|
|
43
43
|
return;
|
|
44
44
|
source.setData(data || {});
|
|
45
45
|
debug('Update GeoJSON Data:', props.id);
|
|
@@ -49,7 +49,7 @@ export const Source = props => {
|
|
|
49
49
|
createEffect(() => {
|
|
50
50
|
const url = props.source.url;
|
|
51
51
|
const coords = props.source.coordinates;
|
|
52
|
-
if (!map
|
|
52
|
+
if (!ctx.map.isSourceLoaded(props.id))
|
|
53
53
|
return;
|
|
54
54
|
source.updateImage(url, coords);
|
|
55
55
|
debug('Update Image Data:', props.id);
|
|
@@ -59,7 +59,7 @@ export const Source = props => {
|
|
|
59
59
|
createEffect(() => {
|
|
60
60
|
const url = props.source.url;
|
|
61
61
|
const tiles = props.source.tiles;
|
|
62
|
-
if (!map
|
|
62
|
+
if (!ctx.map.isSourceLoaded(props.id))
|
|
63
63
|
return;
|
|
64
64
|
url ? source.setUrl(url) : source.setTiles(tiles);
|
|
65
65
|
debug('Update Vector Data:', props.id);
|
|
@@ -68,7 +68,7 @@ export const Source = props => {
|
|
|
68
68
|
case 'raster':
|
|
69
69
|
createEffect(() => {
|
|
70
70
|
const src = lookup(props.source.url);
|
|
71
|
-
if (!map
|
|
71
|
+
if (!ctx.map.isSourceLoaded(props.id))
|
|
72
72
|
return;
|
|
73
73
|
src.url ? source.setUrl(src.url) : source.setTiles(src.tiles);
|
|
74
74
|
debug('Update Raster Data:', props.id);
|
|
@@ -77,10 +77,10 @@ export const Source = props => {
|
|
|
77
77
|
}
|
|
78
78
|
// Remove Source
|
|
79
79
|
onCleanup(() => {
|
|
80
|
-
map
|
|
80
|
+
ctx.map
|
|
81
81
|
?.getStyle()
|
|
82
|
-
.layers.forEach(layer => layer.source === props.id && map
|
|
83
|
-
map
|
|
82
|
+
.layers.forEach(layer => layer.source === props.id && ctx.map.removeLayer(layer.id));
|
|
83
|
+
ctx.map?.getSource(props.id) && ctx.map?.removeSource(props.id);
|
|
84
84
|
debug('Remove Source:', props.id);
|
|
85
85
|
});
|
|
86
86
|
return (<SourceContext.Provider value={props.id}>
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import { createEffect, createUniqueId } from 'solid-js';
|
|
2
|
-
import {
|
|
2
|
+
import { useMapContext } from '../MapProvider';
|
|
3
3
|
import { useSourceId } from '../Source';
|
|
4
4
|
export const Terrain = (props) => {
|
|
5
|
-
const [
|
|
5
|
+
const [ctx] = useMapContext();
|
|
6
6
|
let sourceId = useSourceId();
|
|
7
7
|
// Add Terrain Source if not already defined
|
|
8
8
|
if (!sourceId && !props.source) {
|
|
9
9
|
sourceId = createUniqueId();
|
|
10
|
-
map
|
|
10
|
+
ctx.map.addSource(sourceId, {
|
|
11
11
|
type: 'raster-dem',
|
|
12
|
-
url: map
|
|
12
|
+
url: ctx.map.isMapLibre
|
|
13
13
|
? 'https://demotiles.maplibre.org/terrain-tiles/tiles.json'
|
|
14
14
|
: 'mapbox://mapbox.terrain-rgb',
|
|
15
|
-
tileSize: map
|
|
16
|
-
maxzoom: map
|
|
15
|
+
tileSize: ctx.map.isMapLibre ? 256 : 512,
|
|
16
|
+
maxzoom: ctx.map.isMapLibre ? undefined : 14
|
|
17
17
|
});
|
|
18
|
-
map
|
|
18
|
+
ctx.map.sourceIdList.push(sourceId);
|
|
19
19
|
}
|
|
20
20
|
// Add or Update Terrain Layer
|
|
21
21
|
createEffect(() => {
|
|
22
|
-
map
|
|
22
|
+
ctx.map.setTerrain({
|
|
23
23
|
exaggeration: props.exaggeration || 1,
|
|
24
24
|
source: props.source || sourceId,
|
|
25
25
|
});
|
package/dist/source/index.jsx
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { MapGL as default } from './components/MapGL';
|
|
2
|
-
export { MapProvider,
|
|
2
|
+
export { MapProvider, useMapContext } from './components/MapProvider';
|
|
3
3
|
export { Source, useSourceId } from './components/Source';
|
|
4
4
|
export { Layer } from './components/Layer';
|
|
5
5
|
export { Atmosphere } from './components/Atmosphere';
|
|
@@ -4,8 +4,9 @@ import type { Options as FullscreenOptions } from 'mapbox-gl/src/ui/control/full
|
|
|
4
4
|
import type { Options as GeolocateOptions } from 'mapbox-gl/src/ui/control/geolocate_control';
|
|
5
5
|
import type { Options as NavigationOptions } from 'mapbox-gl/src/ui/control/navigation_control';
|
|
6
6
|
import type { Options as ScaleOptions } from 'mapbox-gl/src/ui/control/scale_control';
|
|
7
|
+
type ControlType = 'navigation' | 'scale' | 'attribution' | 'fullscreen' | 'geolocate';
|
|
7
8
|
type Props = {
|
|
8
|
-
type?:
|
|
9
|
+
type?: ControlType;
|
|
9
10
|
/** a string that specifies the type of control to be displayed. It can be one of 'navigation', 'scale', 'attribution', 'fullscreen', or 'geolocate' */
|
|
10
11
|
options?: NavigationOptions | ScaleOptions | AttributionOptions | FullscreenOptions | GeolocateOptions | object;
|
|
11
12
|
/** an optional object that contains options specific to the control type */
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import { ParentComponent } from
|
|
1
|
+
import { ParentComponent } from 'solid-js';
|
|
2
2
|
import type { Map } from '../MapGL';
|
|
3
|
-
export declare const MapContext: import("solid-js").Context<
|
|
4
|
-
|
|
3
|
+
export declare const MapContext: import("solid-js").Context<{
|
|
4
|
+
map: any;
|
|
5
|
+
}[]>;
|
|
6
|
+
export declare const useMapContext: () => {
|
|
7
|
+
map: any;
|
|
8
|
+
}[];
|
|
5
9
|
export declare const MapProvider: ParentComponent<{
|
|
6
10
|
map?: Map;
|
|
7
|
-
userInteraction?: boolean;
|
|
8
11
|
}>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { MapGL as default } from './components/MapGL';
|
|
2
|
-
export { MapProvider,
|
|
2
|
+
export { MapProvider, useMapContext } from './components/MapProvider';
|
|
3
3
|
export { Source, useSourceId } from './components/Source';
|
|
4
4
|
export { Layer } from './components/Layer';
|
|
5
5
|
export { Atmosphere } from './components/Atmosphere';
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.8.
|
|
2
|
+
"version": "1.8.2",
|
|
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.",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"canvas": "^2.11.2",
|
|
57
57
|
"jsdom": "^22.1.0",
|
|
58
58
|
"mapbox-gl": "^2.15.0",
|
|
59
|
-
"rollup": "^3.
|
|
59
|
+
"rollup": "^3.25.1",
|
|
60
60
|
"rollup-plugin-import-css": "^3.2.1",
|
|
61
61
|
"rollup-preset-solid": "^2.0.1",
|
|
62
62
|
"solid-js": "^1.7.6",
|