diff options
author | Anton Tananaev <anton@traccar.org> | 2023-02-02 15:34:48 -0800 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2023-02-02 15:34:48 -0800 |
commit | 5d3d2df0d0ee2d95cc6e0f855f9f163be48d5ddd (patch) | |
tree | 6358da297316e105de55aa80e22953e3feb10c2d /modern/src/map/MapCamera.js | |
parent | cdfa3e5a8fca1b3b8ed59881adcaa8c3d686de50 (diff) | |
download | trackermap-web-5d3d2df0d0ee2d95cc6e0f855f9f163be48d5ddd.tar.gz trackermap-web-5d3d2df0d0ee2d95cc6e0f855f9f163be48d5ddd.tar.bz2 trackermap-web-5d3d2df0d0ee2d95cc6e0f855f9f163be48d5ddd.zip |
Base combined report
Diffstat (limited to 'modern/src/map/MapCamera.js')
-rw-r--r-- | modern/src/map/MapCamera.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/modern/src/map/MapCamera.js b/modern/src/map/MapCamera.js index 46936513..afb52f89 100644 --- a/modern/src/map/MapCamera.js +++ b/modern/src/map/MapCamera.js @@ -3,11 +3,13 @@ import maplibregl from 'maplibre-gl'; import { map } from './core/MapView'; const MapCamera = ({ - latitude, longitude, positions, + latitude, longitude, positions, coordinates, }) => { useEffect(() => { - if (positions) { - const coordinates = positions.map((item) => [item.longitude, item.latitude]); + if (coordinates || positions) { + if (!coordinates) { + coordinates = positions.map((item) => [item.longitude, item.latitude]); + } if (coordinates.length) { const bounds = coordinates.reduce((bounds, item) => bounds.extend(item), new maplibregl.LngLatBounds(coordinates[0], coordinates[0])); const canvas = map.getCanvas(); @@ -22,7 +24,7 @@ const MapCamera = ({ zoom: Math.max(map.getZoom(), 10), }); } - }, [latitude, longitude, positions]); + }, [latitude, longitude, positions, coordinates]); return null; }; |