[OpenLayers-Users] How do I get my polygon coordinates?

Nathan Gerber ngerber999 at gmail.com
Thu Sep 11 08:17:04 EDT 2008


I use a different method for getting the polygons as a text string, keep in
mind this is for catching all polygons in the given layer and not for a
selected or recently drawn polygon.

//put in your map init() function
wkt = new OpenLayers.Format.WKT();

//Put this where you desire it to be and modify as necessary
for (var i=0;i<vectors.features.length;i++) {
    //if (selFeatureID == vectors.features[i].id) {}
    var str = wkt.write(vectors.features[i]);
    ajaxSendParams += "&bdySegment="+escape(str);
}




--
Nathan Gerber


On Thu, Sep 11, 2008 at 7:31 AM, Bijoy <bijoya at rediff.co.in> wrote:

>
> Hey GeoUser,
>
> Instead of using getComponentsString(), I use toString()... and, I get the
> result... but the format is different. Might have to do some string
> manipulation... However, this is good to go for now...
>
> Thanks man!!
> <BIJOY>
>
>
> Bijoy wrote:
> >
> > Hi GeoUser,
> >
> > I tried it as shown below:-
> > function check(obj){
> >       var points = vectors.features[0].geometry.getComponentsString();
>  //
> > where vectors is myVectorLayer
> >         alert(points);
> >       polycontrol.deactivate();
> > }
> > It doesn't work. I get error like "this.components[i].toShortString is
> not
> > a function" in the
> >
> OpenLayers.Util.applyDefaults(geometry,t...sh(this.components[i].toShortString());}
> >
> > It seems so close... and yet so far... :)
> > <BIJOY>
> >
> >
> >
> >
> > GeoUser wrote:
> >>
> >> Try with something like this:
> >>
> >> var points = myVectorLayer.features[0].geometry.getComponentsString();
> >>
> >> does it work for you?
> >>
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/How-do-I-get-my-polygon-coordinates--tp19413142p19432872.html
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20080911/8edebc43/attachment.html


More information about the Users mailing list