Right Nathan.

 

Or, if anyone likes to save the current polygon as it gets created, instead
of saving all polygon coordinates using a loop. You might also use the below
technique.

 

polycontrol = new OpenLayers.Control.DrawFeature(vectors,
OpenLayers.Handler.Polygon, {'featureAdded': setPolygonLocation});

map.addControl(polycontrol);

polycontrol.activate();

 

and, on completion of polygon draw. setPolygonLocation is fired with an
object

 

function setPolygonLocation(obj){

            var points = obj.geometry.toString();

            document.getElementById("polygon_location").value=points;   //
Save this point

            polycontrol.deactivate();

}

 

Thanks,

With Regards,

BIJOY K. ANUPAM

 (NASDAQ: REDF)

Mahalaxmi Engineering Estate, L. J. Road #1, Mahim (W), Mumbai, INDIA. Pin -
400 016

 

  _____  

From: Nathan Gerber [mailto:[EMAIL PROTECTED] 
Sent: Thursday, September 11, 2008 5:47 PM
To: Bijoy
Cc: [email protected]
Subject: Re: [OpenLayers-Users] How do I get my polygon coordinates?

 

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 <[EMAIL PROTECTED]> 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].toShortStri
ng());}
>
> 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--tp19413142p194328
72.html

Sent from the OpenLayers Users mailing list archive at Nabble.com.

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

 

<<image002.gif>>

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

Reply via email to