aboutsummaryrefslogtreecommitdiff
path: root/modern/src/map/main/GeofenceMap.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-05-22 09:57:51 -0700
committerAnton Tananaev <anton@traccar.org>2022-05-22 09:57:51 -0700
commit67d7ce8e0f428c521d3d032e8145108c9b2a5f45 (patch)
tree9f350497ebc64951ce2070723ab2b66e1a0f5472 /modern/src/map/main/GeofenceMap.js
parent111347e3f40640aa4c43c0bc2666d7a92ce03bb2 (diff)
downloadtrackermap-web-67d7ce8e0f428c521d3d032e8145108c9b2a5f45.tar.gz
trackermap-web-67d7ce8e0f428c521d3d032e8145108c9b2a5f45.tar.bz2
trackermap-web-67d7ce8e0f428c521d3d032e8145108c9b2a5f45.zip
Rename map plugins
Diffstat (limited to 'modern/src/map/main/GeofenceMap.js')
-rw-r--r--modern/src/map/main/GeofenceMap.js84
1 files changed, 0 insertions, 84 deletions
diff --git a/modern/src/map/main/GeofenceMap.js b/modern/src/map/main/GeofenceMap.js
deleted file mode 100644
index c0912cb2..00000000
--- a/modern/src/map/main/GeofenceMap.js
+++ /dev/null
@@ -1,84 +0,0 @@
-import { useEffect } from 'react';
-import { useSelector } from 'react-redux';
-
-import { map } from '../core/Map';
-import { geofenceToFeature } from '../core/mapUtil';
-
-const GeofenceMap = () => {
- const id = 'geofences';
-
- const geofences = useSelector((state) => state.geofences.items);
-
- useEffect(() => {
- map.addSource(id, {
- type: 'geojson',
- data: {
- type: 'FeatureCollection',
- features: [],
- },
- });
- map.addLayer({
- source: id,
- id: 'geofences-fill',
- type: 'fill',
- filter: [
- 'all',
- ['==', '$type', 'Polygon'],
- ],
- paint: {
- 'fill-color': '#3bb2d0',
- 'fill-outline-color': '#3bb2d0',
- 'fill-opacity': 0.1,
- },
- });
- map.addLayer({
- source: id,
- id: 'geofences-line',
- type: 'line',
- paint: {
- 'line-color': '#3bb2d0',
- 'line-width': 2,
- },
- });
- map.addLayer({
- source: id,
- id: 'geofences-title',
- type: 'symbol',
- layout: {
- 'text-field': '{name}',
- 'text-font': ['Roboto Regular'],
- 'text-size': 12,
- },
- paint: {
- 'text-halo-color': 'white',
- 'text-halo-width': 1,
- },
- });
-
- return () => {
- if (map.getLayer('geofences-fill')) {
- map.removeLayer('geofences-fill');
- }
- if (map.getLayer('geofences-line')) {
- map.removeLayer('geofences-line');
- }
- if (map.getLayer('geofences-title')) {
- map.removeLayer('geofences-title');
- }
- if (map.getSource(id)) {
- map.removeSource(id);
- }
- };
- }, []);
-
- useEffect(() => {
- map.getSource(id).setData({
- type: 'FeatureCollection',
- features: Object.values(geofences).map(geofenceToFeature),
- });
- }, [geofences]);
-
- return null;
-};
-
-export default GeofenceMap;