Reputation: 485
I have a map in Openlayer and added some markers to it as a new layer using the Vector feature. However, as a default I get a beige circle, I wanted to change the appearance using the styling, but even though I checked the documentation, I didnt manage to get it working. Basically I would like to have various apperance for each marker, so I need to set this for each individually. The code for adding the marker is:
var point = new OpenLayers.Geometry.Point(16.373056, 48.208333);
point = point.transform(proj, map.getProjectionObject());
var pointFeature = new OpenLayers.Feature.Vector(point, null, null);
pointLayer.addFeatures([pointFeature]);
According to the documentation, the last "null" should refer to the styling, but no matter what I replace it with, it is still just the default beige circle... any ideas?
Thanks
Upvotes: 2
Views: 4139
Reputation: 831
Here's code that using vector layer with point looking as marker (image style):
var point = new OpenLayers.Geometry.Point(16.373056, 48.208333);
var style = {
externalGraphic: 'http://www.openlayers.org/dev/img/marker.png',
graphicWidth: 21,
graphicHeight: 25,
graphicYOffset: -24
};
var pointFeature = new OpenLayers.Feature.Vector(point, null, style);
Upvotes: 2