From 67d7ce8e0f428c521d3d032e8145108c9b2a5f45 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 22 May 2022 09:57:51 -0700 Subject: Rename map plugins --- modern/src/map/main/GeofenceMap.js | 84 -------------------------------------- 1 file changed, 84 deletions(-) delete mode 100644 modern/src/map/main/GeofenceMap.js (limited to 'modern/src/map/main/GeofenceMap.js') 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; -- cgit v1.2.3