|
|
@ -29,7 +29,11 @@ export const MapComponent = ({ markers, onMapClick }: InternalMapProps) => { |
|
|
|
.addTo(map); |
|
|
|
.addTo(map); |
|
|
|
|
|
|
|
|
|
|
|
mapRef.current = map; |
|
|
|
mapRef.current = map; |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
return () => { |
|
|
|
|
|
|
|
map.remove(); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
}, []); |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
const map = mapRef.current; |
|
|
|
const map = mapRef.current; |
|
|
@ -56,8 +60,7 @@ export const MapComponent = ({ markers, onMapClick }: InternalMapProps) => { |
|
|
|
for (let i = 0; i < markers.length; i++) { |
|
|
|
for (let i = 0; i < markers.length; i++) { |
|
|
|
const thisMarker = markers[i]; |
|
|
|
const thisMarker = markers[i]; |
|
|
|
const previousMarker = markers[i - 1]; |
|
|
|
const previousMarker = markers[i - 1]; |
|
|
|
if (thisMarker) { |
|
|
|
if (thisMarker && previousMarker) { |
|
|
|
if (previousMarker) { |
|
|
|
|
|
|
|
layers.push( |
|
|
|
layers.push( |
|
|
|
leaflet.polyline([ |
|
|
|
leaflet.polyline([ |
|
|
|
previousMarker.coordinates, |
|
|
|
previousMarker.coordinates, |
|
|
@ -65,13 +68,31 @@ export const MapComponent = ({ markers, onMapClick }: InternalMapProps) => { |
|
|
|
]), |
|
|
|
]), |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
layers.push( |
|
|
|
layers.push( |
|
|
|
leaflet.marker(thisMarker.coordinates, { |
|
|
|
...markers.flatMap((marker, i) => { |
|
|
|
title: `${i + 1}`, |
|
|
|
const circle = leaflet.circleMarker(marker.coordinates, { |
|
|
|
|
|
|
|
color: 'black', |
|
|
|
|
|
|
|
fill: true, |
|
|
|
|
|
|
|
fillOpacity: 100, |
|
|
|
|
|
|
|
radius: 10, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
const tooltip = leaflet |
|
|
|
|
|
|
|
.tooltip( |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
permanent: true, |
|
|
|
|
|
|
|
direction: 'center', |
|
|
|
|
|
|
|
className: 'text', |
|
|
|
|
|
|
|
content: `${i + 1}`, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
circle, |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
.setLatLng(marker.coordinates); |
|
|
|
|
|
|
|
return [circle, tooltip]; |
|
|
|
}), |
|
|
|
}), |
|
|
|
); |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for (const layer of layers) { |
|
|
|
for (const layer of layers) { |
|
|
|
layer.addTo(map); |
|
|
|
layer.addTo(map); |
|
|
|
} |
|
|
|
} |
|
|
|