@vinctus/react-maplibre 0.1.2 → 0.1.4
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/Map.d.ts +1 -0
- package/dist/Map.js +2 -14
- package/package.json +1 -1
package/dist/Map.d.ts
CHANGED
package/dist/Map.js
CHANGED
|
@@ -1,14 +1,3 @@
|
|
|
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 { jsx as _jsx } from "react/jsx-runtime";
|
|
13
2
|
import React, { useRef, useEffect, useState, useContext, useImperativeHandle, useMemo, } from 'react';
|
|
14
3
|
import maplibre from 'maplibre-gl';
|
|
@@ -48,8 +37,7 @@ export const MapProvider = ({ children }) => {
|
|
|
48
37
|
function addEventHandler(map, type, handler) {
|
|
49
38
|
map.on(type, (ev) => handler(Object.assign({ viewState: viewStateFromMap(map) }, ev)));
|
|
50
39
|
}
|
|
51
|
-
export const Map = React.forwardRef((
|
|
52
|
-
var { reuseMaps = true, children, style, id, longitude, latitude, maxPitch = DISABLE_PITCH, mapStyle = DEFAULT_STYLE, zoom, onDragEnd, onLoad, onMoveEnd, onZoomEnd, fallback } = _a, options = __rest(_a, ["reuseMaps", "children", "style", "id", "longitude", "latitude", "maxPitch", "mapStyle", "zoom", "onDragEnd", "onLoad", "onMoveEnd", "onZoomEnd", "fallback"]);
|
|
40
|
+
export const Map = React.forwardRef(({ reuseMaps, children, style, id, longitude, latitude, maxPitch = DISABLE_PITCH, mapStyle = DEFAULT_STYLE, zoom, onDragEnd, onLoad, onMoveEnd, onZoomEnd, fallback, options = {}, }, ref) => {
|
|
53
41
|
const mapContainer = useRef(null);
|
|
54
42
|
const { mapRef, mapLoaded, setMapLoaded } = useMap();
|
|
55
43
|
useImperativeHandle(ref, () => mapRef.current, [
|
|
@@ -64,7 +52,7 @@ export const Map = React.forwardRef((_a, ref) => {
|
|
|
64
52
|
}
|
|
65
53
|
return;
|
|
66
54
|
}
|
|
67
|
-
if (mapContainer.current && !mapRef.current) {
|
|
55
|
+
if (!reuseMaps || (mapContainer.current && !mapRef.current)) {
|
|
68
56
|
const m = new maplibre.Map(Object.assign({ container: mapContainer.current, style: mapStyle, center: [longitude, latitude], zoom }, options));
|
|
69
57
|
if (onDragEnd)
|
|
70
58
|
addEventHandler(m, 'dragend', onDragEnd);
|