solid-map-gl 1.7.2 → 1.8.1
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 +5 -7
- package/dist/source/components/Camera/index.jsx +23 -33
- package/dist/source/components/Control/index.jsx +16 -30
- package/dist/source/components/Draw/index.jsx +7 -9
- package/dist/source/components/Image/index.jsx +14 -16
- package/dist/source/components/Layer/index.jsx +19 -21
- package/dist/source/components/Light/index.jsx +5 -7
- package/dist/source/components/MapGL/index.jsx +12 -13
- package/dist/source/components/MapProvider/index.jsx +15 -0
- package/dist/source/components/Marker/index.jsx +6 -8
- package/dist/source/components/Popup/index.jsx +6 -8
- package/dist/source/components/Source/index.jsx +13 -15
- package/dist/source/components/Terrain/index.jsx +18 -25
- package/dist/source/index.jsx +2 -1
- package/dist/types/components/Atmosphere/index.d.ts +2 -2
- package/dist/types/components/Camera/index.d.ts +24 -1
- package/dist/types/components/Control/index.d.ts +2 -1
- package/dist/types/components/Light/index.d.ts +1 -1
- package/dist/types/components/MapGL/index.d.ts +7 -2
- package/dist/types/components/MapProvider/index.d.ts +14 -0
- package/dist/types/components/Marker/index.d.ts +1 -3
- package/dist/types/components/Popup/index.d.ts +1 -2
- package/dist/types/components/Terrain/index.d.ts +2 -9
- package/dist/types/events.d.ts +1 -1
- package/dist/types/index.d.ts +2 -1
- package/package.json +11 -10
|
@@ -1,35 +1,28 @@
|
|
|
1
|
-
import { createEffect, createUniqueId
|
|
2
|
-
import {
|
|
1
|
+
import { createEffect, createUniqueId } from 'solid-js';
|
|
2
|
+
import { useMapContext } from '../MapProvider';
|
|
3
3
|
import { useSourceId } from '../Source';
|
|
4
|
-
export const Terrain = props => {
|
|
5
|
-
|
|
6
|
-
return;
|
|
7
|
-
const [map] = useMap();
|
|
4
|
+
export const Terrain = (props) => {
|
|
5
|
+
const [ctx] = useMapContext();
|
|
8
6
|
let sourceId = useSourceId();
|
|
9
|
-
// Add Terrain
|
|
10
|
-
if (sourceId
|
|
7
|
+
// Add Terrain Source if not already defined
|
|
8
|
+
if (!sourceId && !props.source) {
|
|
11
9
|
sourceId = createUniqueId();
|
|
12
|
-
map
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
tileSize: 512,
|
|
22
|
-
maxzoom: 14,
|
|
23
|
-
});
|
|
24
|
-
map().sourceIdList.push(sourceId);
|
|
10
|
+
ctx.map.addSource(sourceId, {
|
|
11
|
+
type: 'raster-dem',
|
|
12
|
+
url: ctx.map.isMapLibre
|
|
13
|
+
? 'https://demotiles.maplibre.org/terrain-tiles/tiles.json'
|
|
14
|
+
: 'mapbox://mapbox.terrain-rgb',
|
|
15
|
+
tileSize: ctx.map.isMapLibre ? 256 : 512,
|
|
16
|
+
maxzoom: ctx.map.isMapLibre ? undefined : 14
|
|
17
|
+
});
|
|
18
|
+
ctx.map.sourceIdList.push(sourceId);
|
|
25
19
|
}
|
|
20
|
+
// Add or Update Terrain Layer
|
|
26
21
|
createEffect(() => {
|
|
27
|
-
map
|
|
22
|
+
ctx.map.setTerrain({
|
|
28
23
|
exaggeration: props.exaggeration || 1,
|
|
29
|
-
source: sourceId,
|
|
24
|
+
source: props.source || sourceId,
|
|
30
25
|
});
|
|
31
26
|
});
|
|
32
|
-
// Remove Terrain Layer
|
|
33
|
-
// onCleanup(() => map().setTerrain(null))
|
|
34
27
|
return null;
|
|
35
28
|
};
|
package/dist/source/index.jsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { MapGL as default
|
|
1
|
+
export { MapGL as default } from './components/MapGL';
|
|
2
|
+
export { MapProvider, useMapContext } from './components/MapProvider';
|
|
2
3
|
export { Source, useSourceId } from './components/Source';
|
|
3
4
|
export { Layer } from './components/Layer';
|
|
4
5
|
export { Atmosphere } from './components/Atmosphere';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { VoidComponent } from 'solid-js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { Fog } from 'mapbox-gl';
|
|
3
3
|
type Props = {
|
|
4
4
|
/** Fog/Atmosphere Specifications */
|
|
5
|
-
style?:
|
|
5
|
+
style?: Fog;
|
|
6
6
|
};
|
|
7
7
|
export declare const Atmosphere: VoidComponent<Props>;
|
|
8
8
|
export {};
|
|
@@ -1,30 +1,53 @@
|
|
|
1
1
|
import { Component } from 'solid-js';
|
|
2
|
-
import type LngLatLike from 'mapbox-gl
|
|
2
|
+
import type { LngLatLike } from 'mapbox-gl';
|
|
3
|
+
/** Options for rotating the globe. */
|
|
3
4
|
interface RotateGlobeOptions {
|
|
5
|
+
/** The number of seconds per revolution. */
|
|
4
6
|
secPerRev?: number;
|
|
7
|
+
/** The maximum zoom level for spinning the globe. */
|
|
5
8
|
maxSpinZoom?: number;
|
|
9
|
+
/** The zoom level at which the spinning slows down. */
|
|
6
10
|
slowSpinZoom?: number;
|
|
7
11
|
}
|
|
12
|
+
/** Options for rotating the viewport. */
|
|
8
13
|
interface RotateViewportOptions {
|
|
14
|
+
/** The number of seconds per revolution. */
|
|
9
15
|
secPerRev?: number;
|
|
16
|
+
/** The pitch angle in degrees. */
|
|
10
17
|
pitch?: number;
|
|
18
|
+
/** The center of rotation. */
|
|
11
19
|
around?: LngLatLike;
|
|
12
20
|
}
|
|
21
|
+
/** Props for the component. */
|
|
13
22
|
type Props = {
|
|
23
|
+
/** Whether to rotate the globe. */
|
|
14
24
|
rotateGlobe?: boolean | RotateGlobeOptions;
|
|
25
|
+
/** Whether to rotate the viewport. */
|
|
15
26
|
rotateViewport?: boolean | RotateViewportOptions;
|
|
27
|
+
/** Whether to reverse the rotation direction. */
|
|
16
28
|
reverse?: boolean;
|
|
29
|
+
/** Whether to reset the rotation when stopped. */
|
|
17
30
|
resetWhenStopped?: boolean;
|
|
31
|
+
/** Translation options. */
|
|
18
32
|
translate?: {
|
|
33
|
+
/** The type of translation. */
|
|
19
34
|
type?: 'line' | 'sphere';
|
|
35
|
+
/** The starting position. */
|
|
20
36
|
start: [number, number, number];
|
|
37
|
+
/** The ending position. */
|
|
21
38
|
end: [number, number, number];
|
|
39
|
+
/** The target position. */
|
|
22
40
|
target: LngLatLike;
|
|
41
|
+
/** The ending target position. */
|
|
23
42
|
targetEnd?: LngLatLike;
|
|
43
|
+
/** The easing function to use. */
|
|
24
44
|
easing?: 'in' | 'out' | 'inOut';
|
|
45
|
+
/** Whether to loop the translation. */
|
|
25
46
|
loop?: boolean;
|
|
47
|
+
/** The duration of the translation in milliseconds. */
|
|
26
48
|
duration: number;
|
|
27
49
|
};
|
|
50
|
+
/** The children to render. */
|
|
28
51
|
children?: any;
|
|
29
52
|
};
|
|
30
53
|
export declare const Camera: Component<Props>;
|
|
@@ -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,11 +1,18 @@
|
|
|
1
1
|
import { Component } from 'solid-js';
|
|
2
2
|
import type { mapEventTypes } from '../../events';
|
|
3
|
+
import type mapboxgl from 'mapbox-gl';
|
|
3
4
|
import type { MapboxOptions } from 'mapbox-gl/src/ui/map';
|
|
4
5
|
import type { LngLatLike } from 'mapbox-gl/src/geo/lng_lat.js';
|
|
5
6
|
import type { LngLatBounds } from 'mapbox-gl/src/geo/lng_lat_bounds.js';
|
|
6
7
|
import type { PaddingOptions } from 'mapbox-gl/src/geo/edge_insets.js';
|
|
7
8
|
import type { StyleSpecification } from 'mapbox-gl/src/style-spec/types.js';
|
|
8
9
|
import type { JSX } from 'solid-js';
|
|
10
|
+
export type Map = mapboxgl.Map & {
|
|
11
|
+
mapLib: any;
|
|
12
|
+
debug: boolean;
|
|
13
|
+
sourceIdList: string[];
|
|
14
|
+
layerIdList: string[];
|
|
15
|
+
};
|
|
9
16
|
export type Viewport = {
|
|
10
17
|
id?: string;
|
|
11
18
|
point?: {
|
|
@@ -64,8 +71,6 @@ type Props = {
|
|
|
64
71
|
/** Children within the Map Container */
|
|
65
72
|
children?: any;
|
|
66
73
|
} & mapEventTypes;
|
|
67
|
-
/** Provides the Mapbox Map Object */
|
|
68
|
-
export declare const useMap: () => MapboxMap;
|
|
69
74
|
/** Creates a new Map Container */
|
|
70
75
|
export declare const MapGL: Component<Props>;
|
|
71
76
|
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ParentComponent } from "solid-js";
|
|
2
|
+
import type { Map } from '../MapGL';
|
|
3
|
+
export declare const MapContext: import("solid-js").Context<{
|
|
4
|
+
map: any;
|
|
5
|
+
userInteraction: boolean;
|
|
6
|
+
}[]>;
|
|
7
|
+
export declare const useMapContext: () => {
|
|
8
|
+
map: any;
|
|
9
|
+
userInteraction: boolean;
|
|
10
|
+
}[];
|
|
11
|
+
export declare const MapProvider: ParentComponent<{
|
|
12
|
+
map?: Map;
|
|
13
|
+
userInteraction?: boolean;
|
|
14
|
+
}>;
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { Component } from 'solid-js';
|
|
2
|
-
import type { PopupOptions } from 'mapbox-gl
|
|
3
|
-
import type { MarkerOptions } from 'mapbox-gl/src/ui/marker.js';
|
|
4
|
-
import type { LngLatLike } from 'mapbox-gl/src/geo/lng_lat.js';
|
|
2
|
+
import type { PopupOptions, MarkerOptions, LngLatLike } from 'mapbox-gl';
|
|
5
3
|
type Props = {
|
|
6
4
|
/** Options for the Mapbox GL JS marker */
|
|
7
5
|
options?: MarkerOptions & {
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Component } from 'solid-js';
|
|
2
|
-
import type { PopupOptions } from 'mapbox-gl
|
|
3
|
-
import type { LngLatLike } from 'mapbox-gl/src/geo/lng_lat.js';
|
|
2
|
+
import type { PopupOptions, LngLatLike } from 'mapbox-gl';
|
|
4
3
|
type Props = {
|
|
5
4
|
/** Options for configuring the popup */
|
|
6
5
|
options?: PopupOptions;
|
|
@@ -1,10 +1,3 @@
|
|
|
1
1
|
import { VoidComponent } from 'solid-js';
|
|
2
|
-
import type { TerrainSpecification } from 'mapbox-gl
|
|
3
|
-
|
|
4
|
-
/** Height exaggeration factor */
|
|
5
|
-
exaggeration?: number;
|
|
6
|
-
/** Terrain Source object */
|
|
7
|
-
source?: TerrainSpecification;
|
|
8
|
-
};
|
|
9
|
-
export declare const Terrain: VoidComponent<Props>;
|
|
10
|
-
export {};
|
|
2
|
+
import type { TerrainSpecification } from 'mapbox-gl';
|
|
3
|
+
export declare const Terrain: VoidComponent<TerrainSpecification>;
|
package/dist/types/events.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { MapMouseEvent, MapTouchEvent, MapWheelEvent, MapDataEvent, MapBoxZoomEvent } from 'mapbox-gl
|
|
1
|
+
import type { MapMouseEvent, MapTouchEvent, MapWheelEvent, MapDataEvent, MapBoxZoomEvent } from 'mapbox-gl';
|
|
2
2
|
type mapEventTypes = {
|
|
3
3
|
onMouseDown?: (event: MapMouseEvent) => void;
|
|
4
4
|
onMouseUp?: (event: MapMouseEvent) => void;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { MapGL as default
|
|
1
|
+
export { MapGL as default } from './components/MapGL';
|
|
2
|
+
export { MapProvider, useMapContext } from './components/MapProvider';
|
|
2
3
|
export { Source, useSourceId } from './components/Source';
|
|
3
4
|
export { Layer } from './components/Layer';
|
|
4
5
|
export { Atmosphere } from './components/Atmosphere';
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.8.1",
|
|
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.",
|
|
@@ -50,19 +50,20 @@
|
|
|
50
50
|
"not ie 11"
|
|
51
51
|
],
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@rollup/plugin-terser": "^0.4.
|
|
54
|
-
"@solidjs/testing-library": "^0.7.
|
|
53
|
+
"@rollup/plugin-terser": "^0.4.3",
|
|
54
|
+
"@solidjs/testing-library": "^0.7.1",
|
|
55
|
+
"@types/mapbox-gl": "^2.7.11",
|
|
55
56
|
"canvas": "^2.11.2",
|
|
56
|
-
"jsdom": "^
|
|
57
|
-
"mapbox-gl": "^2.
|
|
58
|
-
"rollup": "^3.
|
|
57
|
+
"jsdom": "^22.1.0",
|
|
58
|
+
"mapbox-gl": "^2.15.0",
|
|
59
|
+
"rollup": "^3.25.1",
|
|
59
60
|
"rollup-plugin-import-css": "^3.2.1",
|
|
60
61
|
"rollup-preset-solid": "^2.0.1",
|
|
61
|
-
"solid-js": "^1.7.
|
|
62
|
-
"typescript": "^5.
|
|
63
|
-
"vite": "^4.
|
|
62
|
+
"solid-js": "^1.7.6",
|
|
63
|
+
"typescript": "^5.1.3",
|
|
64
|
+
"vite": "^4.3.9",
|
|
64
65
|
"vite-plugin-solid": "^2.7.0",
|
|
65
|
-
"vitest": "^0.
|
|
66
|
+
"vitest": "^0.32.0"
|
|
66
67
|
},
|
|
67
68
|
"peerDependencies": {
|
|
68
69
|
"mapbox-gl": "^0.x || ^1.x || ^2.x"
|