Use "Select" interaction for selecting features.
authorPhilipp Spitzer <philipp@spitzer.priv.at>
Sat, 2 Jan 2021 13:53:19 +0000 (14:53 +0100)
committerPhilipp Spitzer <philipp@spitzer.priv.at>
Sat, 2 Jan 2021 13:53:19 +0000 (14:53 +0100)
wrmap.js

index b52b51119844b60adbb27fcc08ae8ce1bd10c560..1aa99268cb58375d07c1d417f118218dbbc6675e 100644 (file)
--- a/wrmap.js
+++ b/wrmap.js
@@ -363,7 +363,12 @@ function init_wrmap(i, jq_map) {
                style: style_function_selected,
        });
        map.addInteraction(select_hover);
                style: style_function_selected,
        });
        map.addInteraction(select_hover);
-       map.on('singleclick', function(event) {
+
+       var select_click = new ol.interaction.Select({
+               condition: ol.events.condition.click,
+       });
+       map.addInteraction(select_click);
+       select_click.on('select', function(event) {
                popup_content.innerHTML = '<p>You clicked</p>';
                popup_overlay.setPosition(event.coordinate);
        });
                popup_content.innerHTML = '<p>You clicked</p>';
                popup_overlay.setPosition(event.coordinate);
        });