views:

229

answers:

2

Hello all PostGis WKT format of Multipolygon is:

MULTIPOLYGON(
((20.229 39.409,20.2241 39.401,20.220 39.410,20.229 39.409)),
((20.209 39.407,20.223 39.400,20.211 39.402,20.209 39.4076))
)

Google Maps api v3 Polygon is:

var triangleCoords = [
    new google.maps.LatLng(25.774252, -80.190262),
    new google.maps.LatLng(18.466465, -66.118292),
    new google.maps.LatLng(32.321384, -64.75737)
  ];

The question is: Can i create a multipolygon in google maps?

+1  A: 

PostGIS supports a number of output formats directly:

http://postgis.refractions.net/documentation/manual-1.5/ch08.html

*See the ST_As*() funcs.

The Google Maps API supports a number of these as well (SVG, KML, etc.). You should try using a format that both speak. Now I'm not sure if Google Maps accepts multipolygons in any of these formats. But you could always use the ST_Simplify() func.

xanadont
A: 
var multipolygon=[
[new google.maps.LatLng(x1,y1),new google.maps.LatLng(x2,y2),new google.maps.LatLng(x3,y3)],
.
.
.
[new google.maps.LatLng(x4,y4),new google.maps.LatLng(x5,y5),new google.maps.LatLng(x6,y6)]
];
Argiropoulos Stavros
You shouldn't have to build your shapes by hand since the data's already in PostGIS. Just query PostGIS and have it output the format you need.
xanadont