dimfeld / svelte-maplibre

Svelte bindings for the MapLibre mapping library
https://svelte-maplibre.vercel.app
MIT License
318 stars 39 forks source link

Stop propagation of clicks on Markers #157

Closed dabreegster closed 5 months ago

dabreegster commented 5 months ago

Related to #155. If you want to be able to click an empty part of the map and distinguish that from clicking an existing Marker, then I think this is necessary. I don't know if this is reasonable default behavior, or if it should be configurable though.

Testing in an external project, https://acteng.github.io/inspectorate_tools/route_check/critical_issues_log (subject to change). https://github.com/acteng/inspectorate_tools/blob/main/src/routes/route_check/critical_issues_log/%2Bpage.svelte I can modify an example here to demonstrate the change, if it's helpful

changeset-bot[bot] commented 5 months ago

🦋 Changeset detected

Latest commit: fca0f889a2752f854b7491b09dce13a63a9da7d7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | --------------- | ----- | | svelte-maplibre | Minor |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

vercel[bot] commented 5 months ago

@dabreegster is attempting to deploy a commit to the Daniel Imfeld's projects Team on Vercel.

A member of the Team first needs to authorize it.

dimfeld commented 5 months ago

Yeah this makes sense. Clicking on a marker is fundamentally different from a regular map click.

I think where this could become a problem is if you set a click handler on the Map, but don't actually care about marker clicks specifically and so aren't handling them there. Unfortunately Svelte 4 doesn't let you detect if the Marker has an event listener hooked up, but this is possible with Svelte 5 style event handlers since they're just regular props.

That said, I think this change is still the right one to make since it handles the regular case better, and in the case above you can just add click handlers to your markers too.

dimfeld commented 5 months ago

Published in v0.9.0