[OpenLayers-Users] WKT output of constructed Geometry

Christopher Schmidt crschmidt at metacarta.com
Sun Mar 15 00:27:07 EDT 2009


On Sat, Mar 14, 2009 at 08:52:52PM -0600, John Cartwright wrote:
> Hello All,
> 
> I'm constructing a geometry w/ a pair of points and then trying to 
> output it as a WKT text string.  However, the parser is complaining that 
> "geometry is undefined" so I'm assuming that I'd doing something wrong 
> in the Geometry construction.  Can someone please help me here?
> 
> Thanks!
> 
> --john
> 
> 
> var parser = new OpenLayers.Format.WKT({
>                'internalProjection': map.baseLayer.projection,
>                'externalProjection': map.baseLayer.projection
>            });
> 
> var geom = new 
> OpenLayers.Geometry.Point(parseFloat(coords[0]),parseFloat(coords[1]));
> var str = parser.write(geom, true);

Just call geom.toString(); it has a built in WKT format, and you're not
actually reprojecting at all with using the same things. The reason
you're getting the error is because parser.write() takes a feature, not
a geometry, I assume.

> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users

-- 
Christopher Schmidt
MetaCarta



More information about the Users mailing list