I have located a point on a map
var layer = new ol.layer.Vector({
source: new ol.source.Vector({
features: [
new ol.Feature({
geometry: new ol.geom.Point(ol.proj.fromLonLat(cord)),
label: 'Label'
})
]
}),
style: (feature) => {
myStyle.getText().setText(feature.get('label'));
return [myStyle];
}
});
I just wanted to make a link to the label (or the point) that takes me to another page. Any help.
Put a click event handler on your map and use getFeaturesAtPixel to find the feature (if any) that has been clicked on. For example:
map.on("click", (event) => {
const features = map.getFeaturesAtPixel(event.pixel);
if (features && features.length > 0) {
// ...
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With