I have points layer, displayed in OpenLayers map. I want to make them clickable, so when I click on every point I get the property I want (ex: coordinates).

I'm newbie in OpenLayers and don't know where to start from.

Points :

Here is my code :

map.on("pointermove", function (evt) {
    var hit = this.forEachFeatureAtPixel(evt.pixel, function(feature, layer) {
        return true;
    if (hit) {
        this.getTargetElement().style.cursor = 'pointer';

        //click event
        map.on('singleclick', function (event) {
        var outpout = event.coordinate; 


    } else {
        this.getTargetElement().style.cursor = '';

when I click on a point I get the coordinates of all the points

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.