Browse Source

Fixing map markers data structure bug

master
GabrielTrettel 3 years ago
parent
commit
c0e76efa8c
  1. 7
      src/app/components/MapMarkerList.js
  2. 18
      src/app/components/map/OpenStreetMap.js

7
src/app/components/MapMarkerList.js

@ -15,10 +15,9 @@ function isRequestedValue(item, renderOptions) {
function MapMarkerList({ markers, renderOptions }) {
if (!markers) return null;
return [...markers.markers].filter(([_, item]) => {
return isRequestedValue(item, renderOptions);
});
return [...markers.markers]
.filter(([_, item]) => isRequestedValue(item, renderOptions))
.map(a => a[1]);
}
export { MapMarkerList };

18
src/app/components/map/OpenStreetMap.js

@ -56,24 +56,18 @@ export default function OpenStreetMap({
renderOptions: dataOptionsToShow,
});
// markersList &&
// mapRef &&
// notEmpy(markersList) &&
// markersList.forEach((val, _) => {
// // console.log(val);
// insertMarker(mapRef, val.ID, val.coordinate, val.image);
// });
// console.log(markersList)
useEffect(() => {
if (markersList && mapRef) {
deleteAllMarkers(mapRef);
notEmpy(markersList) &&
markersList.forEach((val, k) => {
if (val[1].name == "susceptibilityAreas") {
insertPolygon(mapRef, val[1].ID, val[1].coordinate);
markersList.forEach((val) => {
if (val.name == "susceptibilityAreas") {
insertPolygon(mapRef, val.ID, val.coordinate);
} else {
insertMarker(mapRef, val[1].ID, val[1].coordinate, val[1].image);
insertMarker(mapRef, val.ID, val.coordinate, val.image);
}
});
}
@ -104,7 +98,7 @@ export default function OpenStreetMap({
<MapModal
showModal={markerListener}
setShowModal={setMarkerListener}
markers={markersList}
markers={markers.markers}
/>
<MapDataMenu

Loading…
Cancel
Save