Skip to content

Markers - On Events#162

Open
Aadlei wants to merge 3 commits intoYet-another-solution:mainfrom
Aadlei:marker-events
Open

Markers - On Events#162
Aadlei wants to merge 3 commits intoYet-another-solution:mainfrom
Aadlei:marker-events

Conversation

@Aadlei
Copy link
Contributor

@Aadlei Aadlei commented Dec 22, 2025

I added event handling support for the markers, so basically click, drag, dragstart and dragend events through marker options.
I put some remarks telling cases when the handlers does not work, for instance "OnClick" will override Popup content as an example. Also obviously OnDrag won't work together when Draggable is set to false, but I put them as remarks either way.

image

Let me know if there is some confusion or any changes that has to be done.

Overall changelog:

  • Added MarkerEvent (with Type and LngLat)
  • Added onMarker in MapLibre.razor.js, which takes in an event type for the marker and registers it
  • Added OnClick & OnClickAsync
  • Added OnDragStart + OnDragStartAsync
  • Added OnDrag + OnDragAsync
  • Added OnDragEnd + OnDragEndAsync
  • Updated Marker example to show Latitude, Longitude when dragging (using OnDragEnd)

@Aadlei
Copy link
Contributor Author

Aadlei commented Dec 22, 2025

Oh dear, I realised that I accidentally formatted some of the javascript with empty lines... It can be ignored if other changes are approved.

@MatejMa2ur
Copy link
Member

MatejMa2ur commented Dec 22, 2025

Hi, can you please link me to an original MapLibre documentation, where it is used in this kind of way?

It can be the MapLibre GL JS, js / ts file of the options implementation, thank you!

@Aadlei
Copy link
Contributor Author

Aadlei commented Dec 22, 2025

Hi, can you please link me to an original MapLibre documentation, where it is used in this kind of way?

It can be the MapLibre GL JS, js / ts file of the options implementation, thank you!

It is not directly bound to the options object of MarkerOptions for the maplibre ts, on the documentation (line 127 on marker.ts) it seems it inherits all event methods through "Marker extends Evented". Within Marker it has a listens() method that checks whether there are any instances of Evented:
image

MarkerOptions seemed to be the main thing we access when we want to customize it, so it felt right to add it as an option parameter that can be bound to directly. Otherwise it would be for the Marker object itself, which is empty at the moment.

Thoughts? Do you think we should follow a more 1:1 approach instead?

@Aadlei
Copy link
Contributor Author

Aadlei commented Dec 30, 2025

Did the thumbs up mean that it is good enough as an implementation or that we should follow the second approach mentioned? @MatejMa2ur

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants