Reputation: 7197
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.
Upvotes: 7
Views: 6244
Reputation: 2224
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.
Upvotes: 10