Last active
April 26, 2022 21:55
-
-
Save EdoardoVignati/83a125b30546bf26d4ac28000863dfc5 to your computer and use it in GitHub Desktop.
JS OpenLayers intercept click on marker and get coordinates with button cursor.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
map.on("singleclick", function(e) { | |
feature = map.forEachFeatureAtPixel(e.pixel, function(feature) { | |
return feature; | |
}); | |
var coord = feature.getGeometry().getCoordinates(); | |
coord = ol.proj.transform(coord,"EPSG:3857","EPSG:4326"); | |
console.log(coord); | |
}); | |
map.on("pointermove", function (evt) { | |
var hit = this.forEachFeatureAtPixel(evt.pixel, function(feature, layer) { | |
return true; | |
}); | |
if (hit) { | |
this.getTargetElement().style.cursor = "pointer"; | |
} else { | |
this.getTargetElement().style.cursor = ""; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment