diff --git a/src/utils/arrow.ts b/src/utils/arrow.ts index ce050f6..7d7fa5a 100644 --- a/src/utils/arrow.ts +++ b/src/utils/arrow.ts @@ -1,5 +1,4 @@ import { divIcon, LatLngLiteral, Marker, marker, DivIcon } from "leaflet"; -import { dist2 } from "$utils/geom"; export const createArrow = (latlng: LatLngLiteral, angle: number): Marker => marker(latlng, { draggable: false, @@ -21,11 +20,12 @@ export const createArrow = (latlng: LatLngLiteral, angle: number): Marker => mar export const arrowClusterIcon = (cluster): DivIcon => { const markers = cluster.getAllChildMarkers(); - const nearest = markers.sort((a, b) => ( - dist2(a.getLatLng(), cluster.getLatLng()) - dist2(b.getLatLng(), cluster.getLatLng()) - )); + // search for nearest marker to cluster (slow) + // const nearest = markers.sort((a, b) => ( + // dist2(a.getLatLng(), cluster.getLatLng()) - dist2(b.getLatLng(), cluster.getLatLng()) + // )); - cluster.setLatLng(nearest[0].getLatLng()); - - return nearest[0].options.icon; + // faster way + cluster.setLatLng(markers[markers.length - 1].getLatLng()); + return markers[markers.length - 1].options.icon; };