From e18db9c9d72caa65bc019cec73848a1572e37112 Mon Sep 17 00:00:00 2001 From: Jason Liu Date: Thu, 27 Jun 2024 10:13:08 -0400 Subject: [PATCH 1/2] remove e.stopPropagation and popup handling --- src/ui/RadarMarker.ts | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/ui/RadarMarker.ts b/src/ui/RadarMarker.ts index df0945f..eaecef6 100644 --- a/src/ui/RadarMarker.ts +++ b/src/ui/RadarMarker.ts @@ -145,10 +145,6 @@ class RadarMarker extends maplibregl.Marker { const element = this.getElement(); if (element) { element.addEventListener('click', (e) => { - e.stopPropagation(); // stop propagation to map - if (this._popup) { - this.togglePopup(); - } this.fire('click', e); }); } From 1ff0a78a8a3d6f4927a28d83436b575751d6a55f Mon Sep 17 00:00:00 2001 From: Jason Liu Date: Thu, 27 Jun 2024 11:16:11 -0400 Subject: [PATCH 2/2] marker mouse event class --- src/ui/RadarMarker.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/ui/RadarMarker.ts b/src/ui/RadarMarker.ts index eaecef6..19d19fb 100644 --- a/src/ui/RadarMarker.ts +++ b/src/ui/RadarMarker.ts @@ -7,13 +7,28 @@ import type RadarMap from './RadarMap'; import type { RadarMarkerOptions } from '../types'; +class RadarMarkerMouseEvent { + type: 'click'; + target: RadarMarker; + originalEvent: MouseEvent; + lngLat: maplibregl.LngLat; + point: maplibregl.Point2D; + + constructor(type: 'click', marker: RadarMarker, originalEvent: MouseEvent) { + this.target = marker; + this.originalEvent = originalEvent; + this.point = marker._pos; + this.lngLat = marker.getLngLat(); + this.type = type; + } +} + interface ImageOptions { url?: string; width?: number | string; height?: number | string; } - const createImageElement = (options: ImageOptions) => { const element = document.createElement('img'); element.src = options.url!; @@ -145,7 +160,7 @@ class RadarMarker extends maplibregl.Marker { const element = this.getElement(); if (element) { element.addEventListener('click', (e) => { - this.fire('click', e); + this.fire('click', new RadarMarkerMouseEvent('click', this, e)); }); } }