farmOS / farmOS-map

farmOS-map is an OpenLayers wrapper library designed for agricultural mapping needs. It can be used in any project that has similar requirements.
https://farmOS.github.io/farmOS-map
MIT License
35 stars 21 forks source link

Pass click coordinate into farmOS-map.popup event #176

Open mstenta opened 1 year ago

mstenta commented 1 year ago

We provide an addPopup() method on map instances, which initializes a new Popup and dispatches a custom farmOS-map.popup event when a singleclick is performed on the map. However, it doesn't pass the click coordinate into the farmOS-map.popup, so that coordinate isn't available to other behaviors who want to hook into the popup display.

For example, the event on this line:

https://github.com/farmOS/farmOS/blob/fc77c86abe6b142702e7b103cd85e0c207333b79/modules/core/ui/map/js/farmOS.map.behaviors.asset_type_layers.js#L91

Is NOT the same event as this one: https://github.com/farmOS/farmOS-map/blob/777758f7218499e2211c5d75c1faf3dbea87904a/src/instance/methods/popup.js#L16

... so event.coordinate is not accessible in the downstream behavior.

paul121 commented 1 year ago

@symbioquine mentioned we might be able to just change the event.type to be `farmOS-map.popup' and pass on the original event attributes. We just need to make sure we don't loose any of the existing attributes at the same time

paul121 commented 1 year ago

Ha - related: https://github.com/walkermatt/ol-popup/issues/145#issuecomment-910896745