Hi,

You shoud add a feature not a geometry

var vectorLayer = new OpenLayers.Layer.Vector("layer");

//as the funtion says, you get a geometry

var p = new OpenLayers.Bounds(0,0,10,10).transform(
    new OpenLayers.Projection("EPSG:4326"),
    new OpenLayers.Projection("EPSG:900913")
).toGeometry();  

//console.log(p.CLASS_NAME);

var ft = new OpenLayers.Feature.Vector(p);

map.addLayer(vectorLayer);
vectorLayer.addFeatures([ft]);  

Arnd


-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Mr. Puneet
Kishor
Gesendet: Donnerstag, 19. Januar 2012 14:59
An: [email protected]
Betreff: [OpenLayers-Users] struggling to draw a simple rectange

This is just not obvious to me, apologies for that. I am trying to draw a
rectangle on a Google Maps base layer.

    var vectorLayer = new OpenLayers.Layer.Vector("layer");
    var p = new OpenLayers.Bounds(0,0,10,10).transform(
        new OpenLayers.Projection("EPSG:4326"),
        new OpenLayers.Projection("EPSG:900913")
    ).toGeometry();
    
    map.addLayer(vectorLayer);
    vectorLayer.addFeatures([p]); 

The above does nothing for me. Please set me right.

--
Puneet Kishor_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to