mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
cluster as last marker in it
This commit is contained in:
parent
64b057c708
commit
9532a333be
1 changed files with 7 additions and 7 deletions
|
@ -1,5 +1,4 @@
|
||||||
import { divIcon, LatLngLiteral, Marker, marker, DivIcon } from "leaflet";
|
import { divIcon, LatLngLiteral, Marker, marker, DivIcon } from "leaflet";
|
||||||
import { dist2 } from "$utils/geom";
|
|
||||||
|
|
||||||
export const createArrow = (latlng: LatLngLiteral, angle: number): Marker => marker(latlng, {
|
export const createArrow = (latlng: LatLngLiteral, angle: number): Marker => marker(latlng, {
|
||||||
draggable: false,
|
draggable: false,
|
||||||
|
@ -21,11 +20,12 @@ export const createArrow = (latlng: LatLngLiteral, angle: number): Marker => mar
|
||||||
export const arrowClusterIcon = (cluster): DivIcon => {
|
export const arrowClusterIcon = (cluster): DivIcon => {
|
||||||
const markers = cluster.getAllChildMarkers();
|
const markers = cluster.getAllChildMarkers();
|
||||||
|
|
||||||
const nearest = markers.sort((a, b) => (
|
// search for nearest marker to cluster (slow)
|
||||||
dist2(a.getLatLng(), cluster.getLatLng()) - dist2(b.getLatLng(), cluster.getLatLng())
|
// const nearest = markers.sort((a, b) => (
|
||||||
));
|
// dist2(a.getLatLng(), cluster.getLatLng()) - dist2(b.getLatLng(), cluster.getLatLng())
|
||||||
|
// ));
|
||||||
|
|
||||||
cluster.setLatLng(nearest[0].getLatLng());
|
// faster way
|
||||||
|
cluster.setLatLng(markers[markers.length - 1].getLatLng());
|
||||||
return nearest[0].options.icon;
|
return markers[markers.length - 1].options.icon;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue