Your listener id (must be unique for all mouseover events)
Your listener function
// Each time the map is clicked and "layer" interactor is active
JMap.Event.MouseOver.on.beforeContentProcessed("my-listener", params => {
// mouseover "clicked" features for layer id="3"
let features = params.getFeaturesByLayerId(3) // returns an array copy
// remove feature id=17
params.removeFeaturesByLayerId(3, [123, 432])
features = params.getFeaturesByLayerId(3)
// now features id=123 and 432 are not anymore in features array
const newFeature = { id="24553", ...etc } // a geojson feature
params.addFeatureByLayerId(3, newFeature)
features = params.getFeaturesByLayerId(3)
// features contains the new feature and will display it in the mouseover
})
JMap.Event.MouseOver.on.beforeContentProcessed
This event is triggered each time the map is clicked, and before the mouseover content is calculated or popup opened.
This event is a special on, as it offers 3 methods which can change the mouseover behavior:
You can test the event function addFeaturesToLayerSelection, by pasting the following code in the console (adapt for your configuration):
This listener adds a feature on every click on the map, so no matter where you click, the mouseover will contains at least one feature (the one dynamically added by the listener)
Then paste this in the console to remove the previous listener:
You can test that now no mouseover is displayed anymore when we click on an empty area.
Finally you can test the event function removeFeaturesFromLayerSelection by pasting the following code snippet:
Now you can click on the feature id=58, but no mouseover will display for if, as it is automatically removed by the listener.