From 8cb4302c70905372bea96c0a44432ba1af315ed3 Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Sat, 28 Jun 2025 11:12:48 -0500 Subject: [PATCH] dont pan map on popup --- assets/js/map.ts | 4 +- assets/js/types/leaflet.d.ts | 169 ++++++++++++++++++----------------- 2 files changed, 90 insertions(+), 83 deletions(-) diff --git a/assets/js/map.ts b/assets/js/map.ts index a74d1df..a74f57f 100644 --- a/assets/js/map.ts +++ b/assets/js/map.ts @@ -800,7 +800,7 @@ let MapAPRSMap = { // Add popup if content provided if (data.popup) { - marker.bindPopup(data.popup); + marker.bindPopup(data.popup, { autoPan: false }); } // Handle marker click @@ -921,7 +921,7 @@ let MapAPRSMap = { existingMarker.setPopupContent(data.popup); // Force popup to refresh by unbinding and rebinding existingMarker.unbindPopup(); - existingMarker.bindPopup(data.popup); + existingMarker.bindPopup(data.popup, { autoPan: false }); } } else { // Marker doesn't exist, create it diff --git a/assets/js/types/leaflet.d.ts b/assets/js/types/leaflet.d.ts index 0cdbb5b..94c3e86 100644 --- a/assets/js/types/leaflet.d.ts +++ b/assets/js/types/leaflet.d.ts @@ -1,96 +1,103 @@ declare namespace L { - class Map { - constructor(element: string | HTMLElement, options?: MapOptions); - setView(center: LatLngExpression, zoom: number, options?: ZoomOptions): this; - getCenter(): LatLng; - getZoom(): number; - getBounds(): LatLngBounds; - remove(): void; - invalidateSize(options?: { animate?: boolean; pan?: boolean }): this; - whenReady(callback: () => void): this; - on(event: string, handler: (e: any) => void): this; - } + class Map { + constructor(element: string | HTMLElement, options?: MapOptions); + setView(center: LatLngExpression, zoom: number, options?: ZoomOptions): this; + getCenter(): LatLng; + getZoom(): number; + getBounds(): LatLngBounds; + remove(): void; + invalidateSize(options?: { animate?: boolean; pan?: boolean }): this; + whenReady(callback: () => void): this; + on(event: string, handler: (e: any) => void): this; + } - interface MapOptions { - zoomControl?: boolean; - attributionControl?: boolean; - closePopupOnClick?: boolean; - } + interface MapOptions { + zoomControl?: boolean; + attributionControl?: boolean; + closePopupOnClick?: boolean; + } - interface ZoomOptions { - animate?: boolean; - duration?: number; - } + interface ZoomOptions { + animate?: boolean; + duration?: number; + } - class LatLng { - lat: number; - lng: number; - constructor(lat: number, lng: number); - } + class LatLng { + lat: number; + lng: number; + constructor(lat: number, lng: number); + } - type LatLngExpression = LatLng | [number, number]; + type LatLngExpression = LatLng | [number, number]; - class LatLngBounds { - constructor(southWest: LatLngExpression, northEast: LatLngExpression); - getNorth(): number; - getSouth(): number; - getEast(): number; - getWest(): number; - } + class LatLngBounds { + constructor(southWest: LatLngExpression, northEast: LatLngExpression); + getNorth(): number; + getSouth(): number; + getEast(): number; + getWest(): number; + } - class Marker { - constructor(latLng: LatLngExpression, options?: MarkerOptions); - setLatLng(latLng: LatLngExpression): this; - bindPopup(content: string | HTMLElement): this; - setPopupContent(content: string | HTMLElement): this; - setIcon(icon: DivIcon): this; - getLatLng(): LatLng; - } + class Marker { + constructor(latLng: LatLngExpression, options?: MarkerOptions); + setLatLng(latLng: LatLngExpression): this; + bindPopup(content: string | HTMLElement, options?: PopupOptions): this; + unbindPopup(): this; + openPopup(): this; + closePopup(): this; + setPopupContent(content: string | HTMLElement): this; + setIcon(icon: DivIcon): this; + getLatLng(): LatLng; + } - interface MarkerOptions { - icon?: DivIcon; - } + interface MarkerOptions { + icon?: DivIcon; + } - class DivIcon { - constructor(options: DivIconOptions); - } + interface PopupOptions { + autoPan?: boolean; + } - interface DivIconOptions { - html?: string | HTMLElement; - className?: string; - iconSize?: [number, number]; - iconAnchor?: [number, number]; - } + class DivIcon { + constructor(options: DivIconOptions); + } - class LayerGroup { - addTo(map: Map): this; - clearLayers(): this; - removeLayer(layer: Layer): this; - } + interface DivIconOptions { + html?: string | HTMLElement; + className?: string; + iconSize?: [number, number]; + iconAnchor?: [number, number]; + } - interface Layer { - _leaflet_id?: number; - } + class LayerGroup { + addTo(map: Map): this; + clearLayers(): this; + removeLayer(layer: Layer): this; + } - class TileLayer { - constructor(urlTemplate: string, options?: TileLayerOptions); - addTo(map: Map): this; - } + interface Layer { + _leaflet_id?: number; + } - interface TileLayerOptions { - attribution?: string; - maxZoom?: number; - } + class TileLayer { + constructor(urlTemplate: string, options?: TileLayerOptions); + addTo(map: Map): this; + } - function map(element: string | HTMLElement, options?: MapOptions): Map; - function marker(latLng: LatLngExpression, options?: MarkerOptions): Marker; - function tileLayer(urlTemplate: string, options?: TileLayerOptions): TileLayer; - function latLngBounds(southWest: LatLngExpression, northEast: LatLngExpression): LatLngBounds; - function divIcon(options: DivIconOptions): DivIcon; - function layerGroup(): LayerGroup; - function latLng(lat: number, lng: number): LatLng; - function DomUtil(): { - get(id: string): HTMLElement | null; - remove(el: HTMLElement): void; - }; -} \ No newline at end of file + interface TileLayerOptions { + attribution?: string; + maxZoom?: number; + } + + function map(element: string | HTMLElement, options?: MapOptions): Map; + function marker(latLng: LatLngExpression, options?: MarkerOptions): Marker; + function tileLayer(urlTemplate: string, options?: TileLayerOptions): TileLayer; + function latLngBounds(southWest: LatLngExpression, northEast: LatLngExpression): LatLngBounds; + function divIcon(options: DivIconOptions): DivIcon; + function layerGroup(): LayerGroup; + function latLng(lat: number, lng: number): LatLng; + function DomUtil(): { + get(id: string): HTMLElement | null; + remove(el: HTMLElement): void; + }; +}