It seems like getting onDrag for Markers on OpenLayers isn't possible (this and this, as examples)
So I would like to use a vector layer, and then add points to it instead of markers.
My problem is that the vector points doesn't look like the markers.
Can I assign an icon to a point feature?
I want the functionality of a vector point, with the look of a marker.
forEach(layer => map. removeLayer(layer)); Alternatively, you can also use the layer collection's internal forEach() method for similar results.
Add style object with externalGraphic property to your vector layer config:
var layer= new OpenLayers.Layer.Vector("example", {
maxExtent: new OpenLayers.Bounds(-200,-200,200,200),
style: {
externalGraphic: 'http://www.openlayers.org/dev/img/marker.png',
graphicWidth: 21,
graphicHeight: 25,
graphicYOffset: -24
}
});
The graphicYOffset
shifts the marker appropriately so that the perceived tip of it corresponds to the location on the map.
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