Spaces:
Runtime error
Runtime error
Commit
·
a6ef7f1
1
Parent(s):
d6ae08e
Add separate color for original clicked point
Browse files- Original clicked point shows up in red with text ("Clicked point" and coordinates)
- Nearby points (fetched from backend) show up in green
frontend/src/components/Map.js
CHANGED
@@ -235,7 +235,17 @@ const Map = ( { onMapClick, searchQuery, contentType, setSearchQuery, setSubmitt
|
|
235 |
title: page.title,
|
236 |
distance: page.dist
|
237 |
}));
|
238 |
-
setExplorationMarkers(markers);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
239 |
console.log(`Found ${markers.length} nearby pages`);
|
240 |
} else {
|
241 |
console.error('Failed to fetch nearby pages');
|
@@ -695,11 +705,31 @@ const Map = ( { onMapClick, searchQuery, contentType, setSearchQuery, setSubmitt
|
|
695 |
<Marker
|
696 |
key={`exploration-${index}`}
|
697 |
position={marker.position}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
698 |
>
|
699 |
<Popup>
|
700 |
<div>
|
701 |
<strong>{marker.title}</strong><br />
|
702 |
-
|
|
|
|
|
|
|
|
|
|
|
703 |
</div>
|
704 |
</Popup>
|
705 |
</Marker>
|
|
|
235 |
title: page.title,
|
236 |
distance: page.dist
|
237 |
}));
|
238 |
+
// setExplorationMarkers(markers);
|
239 |
+
// Now adding the main clicked point
|
240 |
+
setExplorationMarkers([
|
241 |
+
{
|
242 |
+
position: [lat, lon],
|
243 |
+
title: 'Clicked Location',
|
244 |
+
distance: 0,
|
245 |
+
isClickedPoint: true
|
246 |
+
},
|
247 |
+
...markers
|
248 |
+
]);
|
249 |
console.log(`Found ${markers.length} nearby pages`);
|
250 |
} else {
|
251 |
console.error('Failed to fetch nearby pages');
|
|
|
705 |
<Marker
|
706 |
key={`exploration-${index}`}
|
707 |
position={marker.position}
|
708 |
+
icon={marker.isClickedPoint ? new L.Icon({
|
709 |
+
iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-red.png',
|
710 |
+
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-shadow.png',
|
711 |
+
iconSize: [25, 41],
|
712 |
+
iconAnchor: [12, 41],
|
713 |
+
popupAnchor: [1, -34],
|
714 |
+
shadowSize: [41, 41]
|
715 |
+
}) : new L.Icon({
|
716 |
+
iconUrl: 'https://raw.githubusercontent.com/pointhi/leaflet-color-markers/master/img/marker-icon-green.png',
|
717 |
+
shadowUrl: 'https://cdnjs.cloudflare.com/ajax/libs/leaflet/1.7.1/images/marker-shadow.png',
|
718 |
+
iconSize: [25, 41],
|
719 |
+
iconAnchor: [12, 41],
|
720 |
+
popupAnchor: [1, -34],
|
721 |
+
shadowSize: [41, 41]
|
722 |
+
})}
|
723 |
>
|
724 |
<Popup>
|
725 |
<div>
|
726 |
<strong>{marker.title}</strong><br />
|
727 |
+
{!marker.isClickedPoint && (
|
728 |
+
<small>Distance: {marker.distance.toFixed(1)}m</small>
|
729 |
+
)}
|
730 |
+
{marker.isClickedPoint && (
|
731 |
+
<small>Pos: {marker.position[0].toFixed(4)}, {marker.position[1].toFixed(4)}</small>
|
732 |
+
)}
|
733 |
</div>
|
734 |
</Popup>
|
735 |
</Marker>
|