[OpenLayers-Users] adding feature to vectorlayer from wkt
karsten vennemann
karsten at terragis.net
Fri Sep 18 13:50:39 EDT 2009
Ok seem's that I'm almost there. Firebug shows geometry, features and bounds ok. But still nothing shows on the map. I have now:
var options1 = {layers: 'basic', units: 'm', projection: "EPSG:102003", maxExtent: new OpenLayers.Bounds(-2500000,-1500000,2500000,1500000)};
vectorlayer = new OpenLayers.Layer.Vector("Vector Layer",options1);
map.addLayer(vectorlayer);
var streetGeom = new OpenLayers.Geometry.fromWKT("LINESTRING(-1930473.64430529 1513488.44352758, -1646969.91778704 1155135.05969326)");
var streetFeature = new OpenLayers.Feature.Vector(streetGeom, null, {});
vectorlayer.addFeatures([streetFeature]);
OI also added
bounds1 = streetFeature.geometry.getBounds();
map.zoomToExtent(bounds1);
And the map zooms to the feature extent but the feature is still not showing. Any ideas what is missing ?
Karsten
> -----Original Message-----
> From: Pavel Iacovlev
> Sent: Friday, September 18, 2009 02:14
> Subject: Re: [OpenLayers-Users] adding feature to vectorlayer from wkt
>
> You need to add features to your layer and geometries to your feature.
>
> var streetGeom = new
> OpenLayers.Geometry.fromWKT("LINESTRING((-1930473.64430529
> 1513488.44352758, -1646969.91778704 1155135.05969326))); var
> streetFeature = new OpenLayers.Feature.Vector(streetGeom,
> null, {}); vectorLayer.addFeatures([streetFeature]);
More information about the Users
mailing list