lolochristen / OpenLayers.Blazor

An Map component for Blazor based on OpenLayers with support for swisstopo swiss maps.
MIT License
37 stars 13 forks source link

OnMapClick does not trigger if clicked on feature #73

Closed Horndev closed 3 weeks ago

Horndev commented 4 weeks ago

In openlayers_interop.js, the onMapClick method sets the variable invokeMethod to false if the user clicks on any shape or feature.

This means that the OnInternalClick (Map OnClick) method is never triggered (and the application can never receive the clicked coordinates).

However, it is sometimes desirable to still trigger the OnClick method for the map with coordinates. Ideally, this could be configurable, but at least, I would expect that the OnClick method still triggers even if clicked on a feature.

Proposed fix: Remove the invokeMethod=false (line 620) before the invocation of feature clicks.

I suspect this was added to deal with when a user clicks on popups or other items, but it is problematic if there are any VectorLayers (i.e. GeoJSON) on the map that are for overlays or visualizations while still wanting to retain coordinate click detection for the underlying map.

lolochristen commented 3 weeks ago

The intention was to reduce the number of events. I will change the logic to trigger OnClick in any case. With OnFeatureClick/OnShapeClick you will not get the exact coordinate of the click, so it makes sense to trigger OnClick always. It will be soon in a PR