Reputation: 1
I am new in Open Layers. I want to get location from user by setting marker or icon in Open Layers and get location using Angular.
Upvotes: 0
Views: 869
Reputation: 169
This will create a marker on click and you can read the location of it
let vectorLayer = new ol.layer.Vector({
source: new ol.source.Vector(),
});
map.addLayer(vectorLayer);
map.on('click', function (evt) {
let marker = new ol.Feature(new ol.geom.Point(evt.coordinate));
marker.setStyle(
new ol.style.Style({
image: new ol.style.Circle({
radius: 50,
fill: new ol.style.Fill({color: 'red'})
})
})
);
vectorLayer.getSource().addFeature(marker);
});
Upvotes: 0