@vinctus/react-maplibre 1.1.0 → 1.2.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.
- package/dist/Marker.d.ts +6 -0
- package/dist/Marker.js +9 -3
- package/package.json +1 -1
package/dist/Marker.d.ts
CHANGED
|
@@ -11,5 +11,11 @@ export type MarkerProps = {
|
|
|
11
11
|
popupClassName?: string;
|
|
12
12
|
closeOnClick?: boolean;
|
|
13
13
|
closeButton?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Lets the marker sit between whole pixels. MapLibre rounds a marker's position every time
|
|
16
|
+
* `setLngLat` is called, which keeps static markers crisp but makes a marker that is being
|
|
17
|
+
* animated move a whole pixel at a time.
|
|
18
|
+
*/
|
|
19
|
+
subpixelPositioning?: boolean;
|
|
14
20
|
};
|
|
15
21
|
export declare const Marker: FC<MarkerProps>;
|
package/dist/Marker.js
CHANGED
|
@@ -3,7 +3,7 @@ import maplibre from 'maplibre-gl';
|
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
4
|
import ReactDOMServer from 'react-dom/server';
|
|
5
5
|
import { MapContext } from './Map';
|
|
6
|
-
export const Marker = ({ children, longitude, latitude, className, anchor, color, popup, popupClassName, closeOnClick = false, closeButton = false, }) => {
|
|
6
|
+
export const Marker = ({ children, longitude, latitude, className, anchor, color, popup, popupClassName, closeOnClick = false, closeButton = false, subpixelPositioning = false, }) => {
|
|
7
7
|
const { map, mapLoaded } = useContext(MapContext);
|
|
8
8
|
const [marker, setMarker] = useState(null);
|
|
9
9
|
// The DOM element the `children` are rendered into. It is created once and reused for the
|
|
@@ -17,7 +17,13 @@ export const Marker = ({ children, longitude, latitude, className, anchor, color
|
|
|
17
17
|
if (!map || !mapLoaded) {
|
|
18
18
|
return;
|
|
19
19
|
}
|
|
20
|
-
const newMarker = new maplibre.Marker({
|
|
20
|
+
const newMarker = new maplibre.Marker({
|
|
21
|
+
anchor,
|
|
22
|
+
className,
|
|
23
|
+
color,
|
|
24
|
+
element,
|
|
25
|
+
subpixelPositioning,
|
|
26
|
+
})
|
|
21
27
|
.setLngLat(coordinates.current)
|
|
22
28
|
.addTo(map);
|
|
23
29
|
setMarker(newMarker);
|
|
@@ -30,7 +36,7 @@ export const Marker = ({ children, longitude, latitude, className, anchor, color
|
|
|
30
36
|
}
|
|
31
37
|
setMarker(null);
|
|
32
38
|
};
|
|
33
|
-
}, [anchor, className, color, element, map, mapLoaded]);
|
|
39
|
+
}, [anchor, className, color, element, map, mapLoaded, subpixelPositioning]);
|
|
34
40
|
useEffect(() => {
|
|
35
41
|
if (marker) {
|
|
36
42
|
marker.setLngLat([longitude, latitude]);
|