Improve heuristic for what event targets are considered markers #5885
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
As mentioned in #5635, the current logic for determining what is a marker has flaws (if you add an option called
icon
, it will be considered a marker).As realized by @ghybs, it's not possible to just replace this with an
instanceof
check for technical reasons. Also, my opinion is that this is not the desired effect: what this code tries to accomplish is that layers that denote a specific location, like markers and circle markers, should always get their location as event location; other layers, that show areas (circles, polygons, lines) should get the exact clicked location.This PR addresses this by considering if the layer has a
getLatLng
method (layer has an exact point location) and is missing radius or has a small radius (measured in pixels).As any heuristic, this will have edge cases, but I think it will cover the codes intention better with less risk of doing the wrong thing.