solid-map-gl 1.11.2 → 1.12.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 (31) hide show
  1. package/dist/esm/index.js +1 -1
  2. package/dist/esm/index.js.map +1 -1
  3. package/dist/source/components/Draw/drawingStyles.js +225 -0
  4. package/dist/source/components/Draw/index.jsx +35 -8
  5. package/dist/source/components/Draw/modes/index.js +9 -0
  6. package/dist/source/components/Draw/modes/line_string.js +43 -0
  7. package/dist/source/components/Draw/modes/measurements.js +76 -0
  8. package/dist/source/components/Draw/modes/multi_point.js +37 -0
  9. package/dist/source/components/Draw/modes/point.js +25 -0
  10. package/dist/source/components/Draw/modes/polygon.js +25 -0
  11. package/dist/source/components/Draw/modes/radius.js +138 -0
  12. package/dist/source/components/Draw/modes/rectangle.js +118 -0
  13. package/dist/source/components/Draw/modes/rectangle_assisted.js +233 -0
  14. package/dist/source/components/Layer/index.jsx +17 -17
  15. package/dist/source/components/Layer3D/index.jsx +256 -21
  16. package/dist/source/components/Popup/index.jsx +10 -10
  17. package/dist/source/index.jsx +14 -14
  18. package/dist/types/components/Draw/drawingStyles.d.ts +20 -0
  19. package/dist/types/components/Draw/index.d.ts +5 -3
  20. package/dist/types/components/Draw/modes/index.d.ts +6 -0
  21. package/dist/types/components/Draw/modes/line_string.d.ts +2 -0
  22. package/dist/types/components/Draw/modes/multi_point.d.ts +2 -0
  23. package/dist/types/components/Draw/modes/point.d.ts +2 -0
  24. package/dist/types/components/Draw/modes/polygon.d.ts +2 -0
  25. package/dist/types/components/Draw/modes/radius.d.ts +2 -0
  26. package/dist/types/components/Draw/modes/rectangle.d.ts +2 -0
  27. package/dist/types/components/Draw/modes/rectangle_assisted.d.ts +18 -0
  28. package/dist/types/components/Layer3D/index.d.ts +7 -2
  29. package/dist/types/components/Popup/index.d.ts +2 -2
  30. package/dist/types/index.d.ts +16 -16
  31. package/package.json +20 -13
@@ -1,24 +1,44 @@
1
- import { onCleanup, createUniqueId, onMount } from 'solid-js';
2
- import { useMapContext } from '../MapProvider';
1
+ import { onCleanup, createUniqueId, createSignal, onMount, createContext, useContext, } from "solid-js";
2
+ import { useMapContext } from "../MapProvider";
3
+ const deg2rad = (degrees) => {
4
+ return (degrees * Math.PI) / 180;
5
+ };
6
+ const latLng2Mercator = (lat, lng, altitude) => {
7
+ const R = 6378137.0; // earth radius in meters
8
+ const x = R * deg2rad(lng);
9
+ const y = R * Math.log(Math.tan(Math.PI / 4 + deg2rad(lat) / 2));
10
+ return [x, y, altitude];
11
+ };
12
+ const latLng2Cartesian = ({ lat, lng }, altitude = 0) => {
13
+ const R = 6378137.0; // earth radius in meters
14
+ const x = R * Math.cos(deg2rad(lat)) * Math.cos(deg2rad(lng));
15
+ const y = R * Math.cos(deg2rad(lat)) * Math.sin(deg2rad(lng));
16
+ const z = altitude; // + R * Math.sin(deg2rad(lat));
17
+ return { x, y, z };
18
+ };
19
+ const LayerContext = createContext();
20
+ export const useScene = () => useContext(LayerContext);
3
21
  export const Layer3D = (props) => {
4
22
  const [ctx] = useMapContext();
23
+ const [scene, setScene] = createSignal(null);
5
24
  onMount(async () => {
6
25
  props.id = props.id || createUniqueId();
7
- const worldOriginMercator = window.MapLib.MercatorCoordinate.fromLngLat(props.origin ? [props.origin[0], props.origin[1]] : [0, 0], props.origin ? props.origin[2] : 0);
26
+ const worldOriginMercator = window.MapLib.MercatorCoordinate.fromLngLat([props.origin[0] || 0, props.origin[1] || 0], props.origin[2] || 0);
8
27
  const worldScale = worldOriginMercator.meterInMercatorCoordinateUnits();
28
+ const { x, y, z } = worldOriginMercator;
9
29
  let worldMatrix = null;
10
30
  let BABYLON = null;
11
31
  let THREE = null;
12
32
  if (props.babylon) {
13
- BABYLON = await import('@babylonjs/core');
14
- worldMatrix = BABYLON.Matrix.Compose(new BABYLON.Vector3(worldScale, worldScale, worldScale), BABYLON.Quaternion.FromEulerAngles(Math.PI / 2, 0, 0), new BABYLON.Vector3(worldOriginMercator.x, worldOriginMercator.y, worldOriginMercator.z));
33
+ BABYLON = await import("@babylonjs/core");
34
+ worldMatrix = BABYLON.Matrix.Compose(new BABYLON.Vector3(worldScale, worldScale, worldScale), BABYLON.Quaternion.FromEulerAngles(Math.PI / 2, 0, 0), new BABYLON.Vector3(x, y, z));
15
35
  }
16
36
  else {
17
- THREE = await import('three');
37
+ THREE = await import("three");
18
38
  worldMatrix = {
19
- translateX: worldOriginMercator.x,
20
- translateY: worldOriginMercator.y,
21
- translateZ: worldOriginMercator.z,
39
+ translateX: x,
40
+ translateY: y,
41
+ translateZ: z,
22
42
  rotateX: Math.PI / 2,
23
43
  rotateY: 0,
24
44
  rotateZ: 0,
@@ -27,20 +47,44 @@ export const Layer3D = (props) => {
27
47
  }
28
48
  ctx.map.addLayer({
29
49
  id: props.id,
30
- type: 'custom',
31
- renderingMode: '3d',
50
+ type: "custom",
51
+ renderingMode: "3d",
32
52
  onAdd(map, gl) {
33
53
  if (props.babylon) {
34
54
  const engine = new BABYLON.Engine(gl, true, {
35
55
  useHighPrecisionMatrix: true,
36
56
  }, true);
57
+ // this.index = 0;
37
58
  this.scene = new BABYLON.Scene(engine);
38
59
  this.scene.autoClear = false;
39
- this.scene.detachControl();
40
- this.scene.beforeRender = () => engine.wipeCaches(true);
41
- this.scene.activeCamera = new BABYLON.Camera('Camera', new BABYLON.Vector3(), this.scene);
60
+ // this.scene.autoClearDepthAndStencil = false;
61
+ // this.scene.detachControl();
62
+ this.scene.preventDefaultOnPointerDown = false;
63
+ this.scene.preventDefaultOnPointerUp = false;
64
+ // this.scene.beforeRender = () => engine.wipeCaches(true);
65
+ const camera = new BABYLON.UniversalCamera("Camera", BABYLON.Vector3.Zero());
66
+ camera.mode = BABYLON.Camera.ORTHOGRAPHIC_CAMERA;
67
+ camera.inertia = 0;
68
+ // this.scene.activeCamera.setTarget(new BABYLON.Vector3(-1, 0, 0));
69
+ // this.scene.activeCamera.rotationQuaternion =
70
+ // BABYLON.Quaternion.Identity();
71
+ // this.scene.activeCamera.updateUpVectorFromRotation = true;
72
+ // this.scene.activeCamera.noRotationConstraint = true;
73
+ // this.scene.activeCamera.inputs.addMouseWheel();
74
+ // this.scene.activeCamera.setTarget(BABYLON.Vector3.Zero());
75
+ // setTimeout(() => {
76
+ // this.scene.activeCamera.setPosition(
77
+ // new BABYLON.Vector3(100, 100, 100),
78
+ // );
79
+ // }, 2000);
80
+ // this.scene.activeCamera.attachControl(gl.canvas, true);
81
+ this.scene.ambientColor = new BABYLON.Color3(1, 1, 1);
42
82
  if (props.defaultLight)
43
- new BABYLON.HemisphericLight('Light', new BABYLON.Vector3(1, 0, 0), this.scene);
83
+ new BABYLON.HemisphericLight("Light", new BABYLON.Vector3(100, 10, 0), this.scene);
84
+ // this.scene.root_node = new BABYLON.TransformNode("rootNode");
85
+ // this.scene.root_node.lookAt(BABYLON.Vector3.Down());
86
+ // this.scene.root_node.addRotation(0, 0, Math.PI / 2);
87
+ // const axis = new BABYLON.AxesViewer(this.scene, 100);
44
88
  }
45
89
  else {
46
90
  this.camera = new THREE.Camera();
@@ -59,13 +103,202 @@ export const Layer3D = (props) => {
59
103
  }
60
104
  this.map = map;
61
105
  props.onAdd && props.onAdd(this.scene, this.map, gl);
106
+ setScene(this.scene);
62
107
  },
63
108
  render(gl, matrix) {
64
109
  if (props.babylon) {
65
- this.scene.activeCamera.freezeProjectionMatrix(worldMatrix.multiply(BABYLON.Matrix.FromArray(matrix)));
66
- const { x, y, z } = this.map.getFreeCameraOptions().position;
67
- this.scene.activeCamera.position =
68
- BABYLON.Vector3.TransformCoordinates(new BABYLON.Vector3(x, y, z), this.scene.activeCamera.getProjectionMatrix().clone().invert());
110
+ this.scene.activeCamera.freezeProjectionMatrix(
111
+ // props.disableProjectionMatrix
112
+ // ? BABYLON.Matrix.FromArray(matrix)
113
+ worldMatrix.multiply(BABYLON.Matrix.FromArray(matrix)));
114
+ // this.scene.activeCamera.position =
115
+ // BABYLON.Vector3.TransformCoordinates(
116
+ // new BABYLON.Vector3(),
117
+ // worldMatrix.multiply(BABYLON.Matrix.FromArray(matrix)).invert(),
118
+ // );
119
+ // this.scene.activeCamera.rotation.z = matrix[0];
120
+ // this.scene.activeCamera.rotation.x = matrix[1];
121
+ // this.scene.activeCamera.rotation.y = matrix[2];
122
+ // console.log(this.scene.activeCamera.getProjectionMatrix(), matrix);
123
+ // const m = matrix;
124
+ // const transform = BABYLON.Matrix.FromArray(matrix);
125
+ // console.log(transform);
126
+ //
127
+ // const center = this.map.getCenter();
128
+ // const zoom = this.map.getZoom();
129
+ // const scale = Math.pow(2, zoom);
130
+ // const centerX = center.lng * scale;
131
+ // const centerZ = center.lat * scale;
132
+ // this.scene.activeCamera.position.x = centerX;
133
+ // this.scene.activeCamera.position.z = centerZ;
134
+ // this.scene.activeCamera.getWorldMatrix().copyFrom(transform);
135
+ const pitch = this.map.getPitch() * (Math.PI / 180);
136
+ const bearing = this.map.getBearing() * (Math.PI / 180);
137
+ // this.scene.activeCamera.rotation.x = Math.asin(pitch);
138
+ // this.scene.activeCamera.rotation.y = Math.atan(bearing / pitch);
139
+ // this.scene.activeCamera.rotation.z = -bearing;
140
+ // this.scene.activeCamera
141
+ // .getWorldMatrix()
142
+ // .invertToRef(this.scene.activeCamera.getViewMatrix());
143
+ // const cameraMatrix = BABYLON.Matrix.FromArray(matrix); //.invert();
144
+ // const scaling = BABYLON.Vector3.Zero(),
145
+ // rotation = BABYLON.Vector3.Zero(),
146
+ // transform = BABYLON.Vector3.Zero();
147
+ // cameraMatrix.decompose(scaling, rotation, transform);
148
+ // const scaling2 = BABYLON.Vector3.Zero(),
149
+ // rotation2 = BABYLON.Vector3.Zero(),
150
+ // transform2 = BABYLON.Vector3.Zero();
151
+ // worldMatrix.decompose(scaling2, rotation2, transform2);
152
+ // const lng2 =
153
+ // props.origin[0] -
154
+ // this.map.getFreeCameraOptions().position.toLngLat().lng;
155
+ // const lat2 =
156
+ // props.origin[1] -
157
+ // this.map.getFreeCameraOptions().position.toLngLat().lat;
158
+ //
159
+ // const pos = this.map.getFreeCameraOptions().position.toLngLat();
160
+ // const orient = this.map.getFreeCameraOptions().orientation;
161
+ // const camPos = latLng2Cartesian(
162
+ // this.map.getFreeCameraOptions().position.toLngLat(),
163
+ // this.map.getFreeCameraOptions().position.toAltitude(),
164
+ // );
165
+ // const orgPos = latLng2Cartesian({
166
+ // lng: props.origin[0],
167
+ // lat: props.origin[1],
168
+ // });
169
+ // const o = this.map.getFreeCameraOptions().orientation;
170
+ // const orient = latLng2Cartesian(
171
+ // new window.MapLib.MercatorCoordinate(
172
+ // ...this.map.getFreeCameraOptions().orientation,
173
+ // ).toLngLat(),
174
+ // );
175
+ // console
176
+ // .log
177
+ // this.map.getFreeCameraOptions().orientation,
178
+ // this.map.getFreeCameraOptions().position.toLngLat(),
179
+ // orgX,
180
+ // camX,
181
+ // camPos,
182
+ // orgPos,
183
+ // x,
184
+ // this.scene.activeCamera.minZ,
185
+ // this.scene.activeCamera.maxZ,
186
+ // this.map.getFreeCameraOptions(),
187
+ // this.map.getFreeCameraOptions().position.toAltitude(),
188
+ // camPos.z,
189
+ // orgPos.z,
190
+ // camPos.z - orgPos.z,
191
+ // this.scene.activeCamera.rotationQuaternion,
192
+ // matrix,
193
+ // camPos.z - orgPos.z,
194
+ // camPos.x - orgPos.x,
195
+ // camPos.y - orgPos.y,
196
+ // camPos.z - orgPos.z,
197
+ // this.index,
198
+ // orient,
199
+ // orient.x - orgPos.x,
200
+ // new BABYLON.Vector3(...orient),
201
+ // camY,
202
+ // camZ,
203
+ // pos.lng,
204
+ // x2,
205
+ // y2,
206
+ // z2,
207
+ // transform,
208
+ // matrix,
209
+ // cameraMatrix._m,
210
+ // cameraMatrix,
211
+ // new mapboxgl.MercatorCoordinate(
212
+ // transform.x,
213
+ // transform.y,
214
+ // transform.z,
215
+ // ).toLngLat(),
216
+ // worldOriginMercator.toLngLat(),
217
+ // this.map.getFreeCameraOptions().position.toLngLat(),
218
+ // this.map.getFreeCameraOptions().orientation,
219
+ // BABYLON.Quaternion.FromArray(
220
+ // this.map.getFreeCameraOptions().orientation,
221
+ // ),
222
+ // this.scene.activeCamera.rotationQuaternion,
223
+ // BABYLON.Vector3.FromArray(
224
+ // this.map.getFreeCameraOptions().orientation,
225
+ // ),
226
+ // ();
227
+ // this.scene.activeCamera.freezeProjectionMatrix(
228
+ // props.disableProjectionMatrix
229
+ // ? BABYLON.Matrix.FromArray(matrix)
230
+ // : worldMatrix.multiply(BABYLON.Matrix.FromArray(matrix)),
231
+ // );
232
+ //
233
+ // const { x, y } = this.map.project(
234
+ // new mapboxgl.MercatorCoordinate(pos.x, pos.y, pos.z).toLngLat(),
235
+ // );
236
+ // this.scene.activeCamera.position.y = 0; //-(camPos.x - orgPos.x);
237
+ // this.scene.activeCamera.position.x = 0; //-(camPos.y - orgPos.y);
238
+ // this.scene.activeCamera.position.z = -camPos.z; // - orgPos.z;
239
+ // console.log(this.scene.activeCamera.position);
240
+ // const [x, y, z, w] = this.map.getFreeCameraOptions().orientation;
241
+ // let rotation_y = Math.atan(z / x);
242
+ // if (x < 0) rotation_y += Math.PI;
243
+ // rotation_y = Math.PI / 2 - rotation_y;
244
+ // const rotation_x = Math.asin(-y);
245
+ // const camera_up_before_rotatez = new BABYLON.Vector3(
246
+ // -Math.cos(rotation_y),
247
+ // 0,
248
+ // Math.sin(rotation_y),
249
+ // );
250
+ // const rotation_z = Math.acos(
251
+ // camera_up.x * camera_up_before_rotatez.x +
252
+ // camera_up.y * camera_up_before_rotatez.y +
253
+ // camera_up.z * camera_up_before_rotatez.z,
254
+ // );
255
+ // rotation_z = Math.PI / 2 - rotation_z;
256
+ // if (camera_up.y < 0) rotation_z = Math.PI - rotation_z;
257
+ //
258
+ // this.scene.activeCamera.rotation.x = rotation_x;
259
+ // this.scene.activeCamera.rotation.y = rotation_y;
260
+ // this.scene.activeCamera.rotationQuaternion =
261
+ // // BABYLON.Quaternion.Identity();
262
+ // // BABYLON.Quaternion.FromEulerAngles(1, 0, 0);
263
+ // BABYLON.Quaternion.FromArray([-x, y, -z, w]);
264
+ // this.scene.activeCamera.alpha = -z;
265
+ // this.scene.activeCamera.alpha = -z;
266
+ // this.scene.activeCamera.radius = x; //Math.PI / 2 + this.index;
267
+ // this.scene.activeCamera.radius = y;
268
+ // this.index += 0.001;
269
+ // BABYLON.Quaternion.RotationYawPitchRoll(-1, 1, -1);
270
+ // BABYLON.Vector3.Zero();
271
+ // BABYLON.Vector3.FromArray(
272
+ // this.map.getFreeCameraOptions().orientation,
273
+ // );
274
+ // this.scene.activeCamera.setTarget(
275
+ // BABYLON.Vector3.Zero(),
276
+ // // new BABYLON.Vector3(
277
+ // // orient.x - orgPos.x,
278
+ // // 0, // orient.y - orgPos.y,
279
+ // // 0, // orient.z - orgPos.z,
280
+ // // ),
281
+ // );
282
+ // const o2 = this.map.project(
283
+ // new mapboxgl.MercatorCoordinate(
284
+ // orient[0],
285
+ // orient[1],
286
+ // orient[2],
287
+ // ).toLngLat(),
288
+ // );
289
+ // this.camera.setTarget(new BABYLON.Vector3(o2.x, o2.y, o2.z));
290
+ // console.log(
291
+ // this.map.getCamera(),
292
+ // this.map.project(
293
+ // new mapboxgl.MercatorCoordinate(pos.x, pos.y, pos.z).toLngLat(),
294
+ // ),
295
+ // this.map.getFreeCameraOptions().orientation,
296
+ // );
297
+ // console.log(this.scene.activeCamera.position);
298
+ // this.camera.position = BABYLON.Vector3.TransformCoordinates(
299
+ // new BABYLON.Vector3(x, y, z),
300
+ // this.scene.activeCamera.getProjectionMatrix().clone().invert(),
301
+ // );
69
302
  this.scene.render(false);
70
303
  }
71
304
  else {
@@ -86,10 +319,12 @@ export const Layer3D = (props) => {
86
319
  props.onRender && props.onRender(gl, matrix);
87
320
  ctx.map.triggerRepaint();
88
321
  },
89
- });
322
+ }, props.beforeId);
90
323
  });
91
324
  onCleanup(() => {
92
325
  ctx.map.getLayer(props.id) && ctx.map.removeLayer(props.id);
93
326
  });
94
- return null;
327
+ return (<LayerContext.Provider value={scene}>
328
+ {scene() && props.children}
329
+ </LayerContext.Provider>);
95
330
  };
@@ -1,12 +1,12 @@
1
- import { onCleanup, createEffect, splitProps } from 'solid-js';
2
- import { useMapContext } from '../MapProvider';
1
+ import { onCleanup, createEffect, splitProps } from "solid-js";
2
+ import { useMapContext } from "../MapProvider";
3
3
  export const Popup = (props) => {
4
4
  if (!props.trackPointer && !props.lngLat)
5
- throw new Error('Popup - lngLat or trackPointer is required');
5
+ throw new Error("Popup - lngLat or trackPointer is required");
6
6
  const [update, create] = splitProps(props, [
7
- 'lngLat',
8
- 'children',
9
- 'trackPointer',
7
+ "lngLat",
8
+ "children",
9
+ "trackPointer",
10
10
  ]);
11
11
  const [ctx] = useMapContext();
12
12
  let popup;
@@ -15,20 +15,20 @@ export const Popup = (props) => {
15
15
  if (!ctx.map)
16
16
  return;
17
17
  popup?.remove();
18
- popup = new window.MAPLIB.Popup({
18
+ popup = new window.MapLib.Popup({
19
19
  closeOnClick: false,
20
20
  focusAfterOpen: false,
21
21
  ...create.options,
22
22
  })
23
- .on('open', () => create.onOpen?.())
24
- .on('close', () => create.onClose?.())
23
+ .on("open", () => create.onOpen?.())
24
+ .on("close", () => create.onClose?.())
25
25
  .addTo(ctx.map);
26
26
  // Update Position
27
27
  createEffect(() => update.trackPointer
28
28
  ? popup.trackPointer()
29
29
  : popup.setLngLat(update.lngLat));
30
30
  // Update Content
31
- createEffect(() => typeof update.children === 'string'
31
+ createEffect(() => typeof update.children === "string"
32
32
  ? popup.setHTML(update.children)
33
33
  : popup.setDOMContent(update.children));
34
34
  });
@@ -1,14 +1,14 @@
1
- export { MapGL as default } from './components/MapGL';
2
- export { MapProvider, useMapContext } from './components/MapProvider';
3
- export { Source, useSourceId } from './components/Source';
4
- export { Layer } from './components/Layer';
5
- export { Layer3D } from './components/Layer3D';
6
- export { Atmosphere } from './components/Atmosphere';
7
- export { Terrain } from './components/Terrain';
8
- export { Control } from './components/Control';
9
- export { Marker } from './components/Marker';
10
- export { Popup } from './components/Popup';
11
- export { MGL_Image as Image, patternList } from './components/Image';
12
- export { Camera } from './components/Camera';
13
- export { Light } from './components/Light';
14
- export { Draw } from './components/Draw';
1
+ export { MapGL as default } from "./components/MapGL";
2
+ export { MapProvider, useMapContext } from "./components/MapProvider";
3
+ export { Source, useSourceId } from "./components/Source";
4
+ export { Layer } from "./components/Layer";
5
+ export { Layer3D, useScene } from "./components/Layer3D";
6
+ export { Atmosphere } from "./components/Atmosphere";
7
+ export { Terrain } from "./components/Terrain";
8
+ export { Control } from "./components/Control";
9
+ export { Marker } from "./components/Marker";
10
+ export { Popup } from "./components/Popup";
11
+ export { MGL_Image as Image, patternList } from "./components/Image";
12
+ export { Camera } from "./components/Camera";
13
+ export { Light } from "./components/Light";
14
+ export { Draw } from "./components/Draw";
@@ -0,0 +1,20 @@
1
+ declare const _default: {
2
+ id: string;
3
+ type: string;
4
+ filter: (string | string[])[];
5
+ layout: {
6
+ "text-field": string[];
7
+ "text-anchor": string[];
8
+ "text-offset": (string | string[] | number[])[];
9
+ "text-size": number;
10
+ "text-allow-overlap": boolean;
11
+ "text-ignore-placement": boolean;
12
+ };
13
+ paint: {
14
+ "text-halo-color": string;
15
+ "text-halo-width": number;
16
+ "text-halo-blur": number;
17
+ "text-color": string;
18
+ };
19
+ }[];
20
+ export default _default;
@@ -1,14 +1,16 @@
1
- import { VoidComponent } from 'solid-js';
2
- import type { drawEventTypes } from '../../events';
1
+ import { VoidComponent } from "solid-js";
2
+ import type { drawEventTypes } from "../../events";
3
3
  type Props = {
4
4
  /** Draw Library */
5
5
  lib: any;
6
6
  /** Draw Options */
7
7
  options?: object;
8
8
  /** Draw Control Position */
9
- position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
9
+ position?: "top-left" | "top-right" | "bottom-left" | "bottom-right";
10
10
  /** Draw Control Instance */
11
11
  getInstance?: (object: any) => void;
12
+ showLength?: boolean;
13
+ showArea?: boolean;
12
14
  } & drawEventTypes;
13
15
  export declare const Draw: VoidComponent<Props>;
14
16
  export {};
@@ -0,0 +1,6 @@
1
+ import draw_point from "./point";
2
+ import draw_polygon from "./polygon";
3
+ import draw_line_string from "./line_string";
4
+ import draw_radius from "./radius";
5
+ import draw_rectangle from "./rectangle";
6
+ export { draw_point, draw_polygon, draw_line_string, draw_radius, draw_rectangle, };
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const MultiPointMode: {};
2
+ export default MultiPointMode;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const _default: any;
2
+ export default _default;
@@ -0,0 +1,2 @@
1
+ declare const RadiusMode: any;
2
+ export default RadiusMode;
@@ -0,0 +1,2 @@
1
+ declare const RectangleMode: any;
2
+ export default RectangleMode;
@@ -0,0 +1,18 @@
1
+ declare const RectangleAssistedMode: {
2
+ onSetup: (opts: any) => {
3
+ rectangle: any;
4
+ currentVertexPosition: number;
5
+ };
6
+ onTap: (state: any, e: any) => void;
7
+ onClick: (state: any, e: any) => any;
8
+ onMouseMove: (state: any, e: any) => void;
9
+ deegrees2meters(px: any): number[];
10
+ meters2degress(px: any): number[];
11
+ calculateOrientedAnglePolygon: (state: any) => void;
12
+ calculatepXY3: (state: any, e: any, tmp: any) => any;
13
+ onKeyUp: (state: any, e: any) => any;
14
+ onStop: (state: any) => void;
15
+ toDisplayFeatures: (state: any, geojson: any, display: any) => any;
16
+ onTrash: (state: any) => void;
17
+ };
18
+ export default RectangleAssistedMode;
@@ -1,4 +1,4 @@
1
- import { VoidComponent } from 'solid-js';
1
+ import { Component, JSX } from "solid-js";
2
2
  declare global {
3
3
  interface Window {
4
4
  BABYLON?: any;
@@ -12,6 +12,11 @@ type Props = {
12
12
  babylon?: boolean;
13
13
  onAdd?: (scene: any, map: any, gl: any) => void;
14
14
  onRender?: (gl: any, matrix: any) => void;
15
+ children?: JSX.Element | JSX.Element[];
16
+ /** A string that specifies the type of layer before which the current layer should be inserted. */
17
+ beforeId?: string;
18
+ disableProjectionMatrix?: boolean;
15
19
  };
16
- export declare const Layer3D: VoidComponent<Props>;
20
+ export declare const useScene: () => any;
21
+ export declare const Layer3D: Component<Props>;
17
22
  export {};
@@ -1,5 +1,5 @@
1
- import { Component } from 'solid-js';
2
- import type { PopupOptions, LngLatLike } from 'mapbox-gl';
1
+ import { Component } from "solid-js";
2
+ import type { PopupOptions, LngLatLike } from "mapbox-gl";
3
3
  type Props = {
4
4
  /** Options for configuring the popup */
5
5
  options?: PopupOptions;
@@ -1,16 +1,16 @@
1
- export { MapGL as default } from './components/MapGL';
2
- export { MapProvider, useMapContext } from './components/MapProvider';
3
- export { Source, useSourceId } from './components/Source';
4
- export { Layer } from './components/Layer';
5
- export { Layer3D } from './components/Layer3D';
6
- export { Atmosphere } from './components/Atmosphere';
7
- export { Terrain } from './components/Terrain';
8
- export { Control } from './components/Control';
9
- export { Marker } from './components/Marker';
10
- export { Popup } from './components/Popup';
11
- export { MGL_Image as Image, patternList } from './components/Image';
12
- export { Camera } from './components/Camera';
13
- export { Light } from './components/Light';
14
- export { Draw } from './components/Draw';
15
- export type { Viewport } from './components/MapGL';
16
- export type { Color } from './components/Image';
1
+ export { MapGL as default } from "./components/MapGL";
2
+ export { MapProvider, useMapContext } from "./components/MapProvider";
3
+ export { Source, useSourceId } from "./components/Source";
4
+ export { Layer } from "./components/Layer";
5
+ export { Layer3D, useScene } from "./components/Layer3D";
6
+ export { Atmosphere } from "./components/Atmosphere";
7
+ export { Terrain } from "./components/Terrain";
8
+ export { Control } from "./components/Control";
9
+ export { Marker } from "./components/Marker";
10
+ export { Popup } from "./components/Popup";
11
+ export { MGL_Image as Image, patternList } from "./components/Image";
12
+ export { Camera } from "./components/Camera";
13
+ export { Light } from "./components/Light";
14
+ export { Draw } from "./components/Draw";
15
+ export type { Viewport } from "./components/MapGL";
16
+ export type { Color } from "./components/Image";
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.11.2",
2
+ "version": "1.12.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.",
@@ -54,19 +54,19 @@
54
54
  ],
55
55
  "devDependencies": {
56
56
  "@rollup/plugin-terser": "^0.4.4",
57
- "@solidjs/testing-library": "^0.8.6",
58
- "@testing-library/jest-dom": "^6.4.2",
59
- "@types/mapbox-gl": "^3.1.0",
60
- "@vitest/coverage-v8": "^1.3.1",
61
- "jsdom": "^24.0.0",
57
+ "@solidjs/testing-library": "^0.8.10",
58
+ "@testing-library/jest-dom": "^6.6.4",
59
+ "@types/mapbox-gl": "^3.4.1",
60
+ "@vitest/coverage-v8": "^3.2.4",
61
+ "jsdom": "^26.1.0",
62
62
  "jsdom-worker": "^0.3.0",
63
- "rollup": "^4.12.1",
64
- "rollup-plugin-import-css": "^3.5.0",
65
- "rollup-preset-solid": "^2.0.1",
66
- "typescript": "^5.4.2",
67
- "vite": "^5.1.5",
68
- "vite-plugin-solid": "^2.10.1",
69
- "vitest": "^1.3.1"
63
+ "rollup": "^4.46.1",
64
+ "rollup-plugin-import-css": "^4.0.1",
65
+ "rollup-preset-solid": "^3.0.0",
66
+ "typescript": "^5.8.3",
67
+ "vite": "^7.0.6",
68
+ "vite-plugin-solid": "^2.11.7",
69
+ "vitest": "^3.2.4"
70
70
  },
71
71
  "peerDependencies": {
72
72
  "@babylonjs/core": "^6.24.0",
@@ -81,5 +81,12 @@
81
81
  "three": {
82
82
  "optional": true
83
83
  }
84
+ },
85
+ "dependencies": {
86
+ "@turf/area": "^7.2.0",
87
+ "@turf/center-of-mass": "^7.2.0",
88
+ "@turf/centroid": "^7.2.0",
89
+ "@turf/length": "^7.2.0",
90
+ "@turf/midpoint": "^7.2.0"
84
91
  }
85
92
  }