2

I can add the marker on the openlayer map using Openlayers.Layer.markers . But i cannot do this using OpenLayers.Feature.Vector ? . Any one may help me..please...thanks in advance

Regards, Boomiraj.P

1
  • 1
    can you post an example of what you've already tried? Commented Aug 4, 2011 at 14:27

2 Answers 2

8

here's a simple example that should work.

var point = new OpenLayers.Feature.Vector(
    new OpenLayers.Geometry.Point(-111.04, 45.68));

var layer = new OpenLayers.Layer.Vector("My Layer", {
    style: OpenLayers.Feature.Vector.style["default"]
});

map.addLayer(layer);
layer.addFeatures([point]);
Sign up to request clarification or add additional context in comments.

1 Comment

Np. I suggest you start selecting correct answers for your questions because if you don't, people won't want to help you anymore.
0

This also does the trick:

var point = new OpenLayers.LonLat( -0.1279688 ,51.5077286 ).transform(
    new OpenLayers.Projection("EPSG:4326"),
    map.getProjectionObject());

var markers = new OpenLayers.Layer.Markers("Markers");
map.addLayer(markers);

markers.addMarker(new OpenLayers.Marker(point));

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.