aboutsummaryrefslogtreecommitdiff
path: root/modern/src/MainMap.js
diff options
context:
space:
mode:
authorAnton Tananaev <anton.tananaev@gmail.com>2020-09-13 15:59:21 -0700
committerAnton Tananaev <anton.tananaev@gmail.com>2020-09-13 15:59:21 -0700
commit6ef7e13621d746482ad906955675541fdd7f0705 (patch)
tree6ed1a28163bd0d7bfeb71c8dac686ad984cb1d88 /modern/src/MainMap.js
parent0c53e226ef1b5ea4f40f0768d20809fac473dccc (diff)
downloadtrackermap-web-6ef7e13621d746482ad906955675541fdd7f0705.tar.gz
trackermap-web-6ef7e13621d746482ad906955675541fdd7f0705.tar.bz2
trackermap-web-6ef7e13621d746482ad906955675541fdd7f0705.zip
Add marker callback
Diffstat (limited to 'modern/src/MainMap.js')
-rw-r--r--modern/src/MainMap.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/modern/src/MainMap.js b/modern/src/MainMap.js
index f2ac1b7b..fadfe9e7 100644
--- a/modern/src/MainMap.js
+++ b/modern/src/MainMap.js
@@ -1,5 +1,6 @@
import React, { useRef, useLayoutEffect, useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
+import mapboxgl from 'mapbox-gl';
import mapManager from './mapManager';
@@ -52,13 +53,17 @@ const MainMap = () => {
mapManager.registerListener(() => setMapReady(true));
}, []);
+ const markerClickHandler = (event) => {
+ // TODO
+ };
+
useEffect(() => {
if (mapReady) {
mapManager.map.addSource('positions', {
'type': 'geojson',
'data': positions,
});
- mapManager.addLayer('device-icon', 'positions', 'icon-marker', '{name}');
+ mapManager.addLayer('device-icon', 'positions', 'icon-marker', '{name}', markerClickHandler);
const bounds = mapManager.calculateBounds(positions.features);
if (bounds) {
@@ -69,8 +74,7 @@ const MainMap = () => {
}
return () => {
- mapManager.map.removeLayer('device-icon');
- mapManager.map.removeSource('positions');
+ mapManager.removeLayer('device-icon', 'positions');
};
}
}, [mapReady]);