function get_WKTMulitpolygon(polygon) {

     var numPoints = polygon.getVertexCount();
     var mp = "MULTIPOLYGON (((";

     for(var i=0; i < numPoints; i++) {
        var lat = polygon.getVertex(i).lat();
        var lng = polygon.getVertex(i).lng();

        mp += lng + " "+ lat + ",";

     }

     mp = mp.replace(/,$/,"");
     mp += ")))"

     return mp;

};

Not tested. You'd better provide an array of polygons as parameter...


----- Original Message ----- 
From: <[email protected]>
To: "Google Maps API" <[email protected]>
Sent: Friday, January 30, 2009 4:42 PM
Subject: GPolygon to WKT


>
> Hello
> I have a GPolygon on my map. I need to save it to my PostGIS DB. I get
> it coordinates in this way:
>
<> function get_polylatlng(polygon) {
>
>
>     var numPoints = polygon.getVertexCount();
>
>
> var latlng=[];
>
>     for(var i=0; i < numPoints; i++) {
>         var lat = polygon.getVertex(i).lat();
>         var lng = polygon.getVertex(i).lng();
>
> latlng[i]= lat + " " + lng;
>
>         }
>
>
>     return latlng;
>
> };
>
> So I have an array of coordinates in latlng. BUT I need to save it as
> WKT Polygon! How can I convert it to WKT?
>
> >
>
----- Original Message ----- 
From: <[email protected]>
To: "Google Maps API" <[email protected]>
Sent: Friday, January 30, 2009 4:59 PM
Subject: Re: GPolygon to WKT


>
> Sorry, not PostGIS. But PostgreSQL. All in all I need WKT
> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
[email protected]
> For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
> -~----------~----~----~----~------~----~------~--~---
>
>


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to