@vinctus/react-maplibre 0.1.2 → 0.1.3

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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import React, { FC, RefAttributes, ReactNode, CSSProperties } from 'react';
2
- import maplibre, { MapLibreEvent, StyleSpecification } from 'maplibre-gl';
2
+ import maplibre, { MapLibreEvent, MapOptions, StyleSpecification } from 'maplibre-gl';
3
3
  export type ViewState = {
4
4
  longitude: number;
5
5
  latitude: number;
@@ -45,5 +45,6 @@ export type MapProps = {
45
45
  ref?: RefAttributes<maplibre.Map | null>;
46
46
  style?: CSSProperties;
47
47
  zoom: number;
48
+ options?: MapOptions;
48
49
  };
49
50
  export declare const Map: React.ForwardRefExoticComponent<Omit<MapProps, "ref"> & React.RefAttributes<maplibre.Map | null>>;
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((_a, ref) => {
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vinctus/react-maplibre",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Minimalist MapLibre GL JS React wrapper library",
5
5
  "types": "dist/index.d.ts",
6
6
  "publishConfig": {