Skip to content

Commit

Permalink
marker mouse event class
Browse files Browse the repository at this point in the history
  • Loading branch information
jaspk06 committed Jun 27, 2024
1 parent e18db9c commit 1ff0a78
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/ui/RadarMarker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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!;
Expand Down Expand Up @@ -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));
});
}
}
Expand Down

0 comments on commit 1ff0a78

Please sign in to comment.