@vinctus/react-maplibre 0.2.3 → 0.2.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/dist/GeolocateControl.d.ts +2 -1
- package/dist/GeolocateControl.js +4 -17
- package/dist/NavigationControl.d.ts +8 -0
- package/dist/NavigationControl.js +19 -0
- package/dist/ScaleControl.d.ts +2 -0
- package/dist/ScaleControl.js +4 -17
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/package.json +1 -1
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
+
import { GeolocateControlOptions } from 'maplibre-gl';
|
|
2
3
|
import { ControlPosition } from './types';
|
|
3
4
|
export type GeolocateControlProps = {
|
|
4
5
|
position?: ControlPosition;
|
|
5
|
-
|
|
6
|
+
options?: GeolocateControlOptions;
|
|
6
7
|
};
|
|
7
8
|
export declare const GeolocateControl: FC<GeolocateControlProps>;
|
package/dist/GeolocateControl.js
CHANGED
|
@@ -1,29 +1,16 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
1
|
import { useEffect } from 'react';
|
|
13
2
|
import maplibre from 'maplibre-gl';
|
|
14
3
|
import { useMap } from './Map';
|
|
15
|
-
export const GeolocateControl = (
|
|
16
|
-
var { position = 'top-right' } = _a, options = __rest(_a, ["position"]);
|
|
4
|
+
export const GeolocateControl = ({ position = 'bottom-right', options = { showUserLocation: false }, }) => {
|
|
17
5
|
const { map } = useMap();
|
|
18
|
-
const optionsString = JSON.stringify(options);
|
|
19
6
|
useEffect(() => {
|
|
20
|
-
const control = new maplibre.GeolocateControl(
|
|
21
|
-
if (map) {
|
|
7
|
+
const control = new maplibre.GeolocateControl(options);
|
|
8
|
+
if (map && position) {
|
|
22
9
|
map.addControl(control, position);
|
|
23
10
|
}
|
|
24
11
|
return () => {
|
|
25
12
|
map === null || map === void 0 ? void 0 : map.removeControl(control);
|
|
26
13
|
};
|
|
27
|
-
}, [position,
|
|
14
|
+
}, [position, options, map]);
|
|
28
15
|
return null;
|
|
29
16
|
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { NavigationControlOptions } from 'maplibre-gl';
|
|
3
|
+
import { ControlPosition } from './types';
|
|
4
|
+
export type NavigationControlProps = {
|
|
5
|
+
position?: ControlPosition;
|
|
6
|
+
options?: NavigationControlOptions;
|
|
7
|
+
};
|
|
8
|
+
export declare const NavigationControl: FC<NavigationControlProps>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import maplibre from 'maplibre-gl';
|
|
3
|
+
import { useMap } from './Map';
|
|
4
|
+
export const NavigationControl = ({ position = 'bottom-right', options = {
|
|
5
|
+
showZoom: true,
|
|
6
|
+
showCompass: false,
|
|
7
|
+
}, }) => {
|
|
8
|
+
const { map } = useMap();
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
const control = new maplibre.NavigationControl(options);
|
|
11
|
+
if (map && position) {
|
|
12
|
+
map.addControl(control, position);
|
|
13
|
+
}
|
|
14
|
+
return () => {
|
|
15
|
+
map === null || map === void 0 ? void 0 : map.removeControl(control);
|
|
16
|
+
};
|
|
17
|
+
}, [position, options, map]);
|
|
18
|
+
return null;
|
|
19
|
+
};
|
package/dist/ScaleControl.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
|
+
import { ScaleControlOptions } from 'maplibre-gl';
|
|
2
3
|
import { ControlPosition } from './types';
|
|
3
4
|
export type ScaleControlProps = {
|
|
4
5
|
position?: ControlPosition;
|
|
6
|
+
options?: ScaleControlOptions;
|
|
5
7
|
};
|
|
6
8
|
export declare const ScaleControl: FC<ScaleControlProps>;
|
package/dist/ScaleControl.js
CHANGED
|
@@ -1,29 +1,16 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
1
|
import { useEffect } from 'react';
|
|
13
2
|
import maplibre from 'maplibre-gl';
|
|
14
3
|
import { useMap } from './Map';
|
|
15
|
-
export const ScaleControl = (
|
|
16
|
-
var { position = 'top-right' } = _a, options = __rest(_a, ["position"]);
|
|
4
|
+
export const ScaleControl = ({ position = 'bottom-right', options, }) => {
|
|
17
5
|
const { map } = useMap();
|
|
18
|
-
const optionsString = JSON.stringify(options);
|
|
19
6
|
useEffect(() => {
|
|
20
|
-
const control = new maplibre.ScaleControl();
|
|
21
|
-
if (map) {
|
|
7
|
+
const control = new maplibre.ScaleControl(options);
|
|
8
|
+
if (map && position) {
|
|
22
9
|
map.addControl(control, position);
|
|
23
10
|
}
|
|
24
11
|
return () => {
|
|
25
12
|
map === null || map === void 0 ? void 0 : map.removeControl(control);
|
|
26
13
|
};
|
|
27
|
-
}, [position,
|
|
14
|
+
}, [position, options, map]);
|
|
28
15
|
return null;
|
|
29
16
|
};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED