You'll need to convert your [lat1, lng1] pairs to a LatLng.

Example: polygon with hole
(http://gmaps-samples-v3.googlecode.com/svn/trunk/poly/pentagon.html)
  var paths = [[
    new google.maps.LatLng(38.872886, -77.054720),
    new google.maps.LatLng(38.872602, -77.058046),
    ...
  ], [
    new google.maps.LatLng(38.871684, -77.056780),
    new google.maps.LatLng(38.871867, -77.055449),
    ...
  ]];

  var poly = new google.maps.Polygon({
    paths: paths,
    strokeWeight: 3,
    fillColor: '#55FF55',
    fillOpacity: 0.5
  });

  poly.setMap(map);

To edit the polygon you simply edit the paths array, like:

  poly.getPaths().removeAt(1)  // Remove the hole

Or insert a new hole:

  poly.getPaths().insertAt(1, new MVCArray([ ... some LatLngs ... ]))

On Wed, Nov 18, 2009 at 7:53 AM, arclyte <[email protected]> wrote:
> I've been working on a polygon drawing app and I've gotten the basics
> of it down, but now I've gotten myself all mixed up trying to support
> polygon exclusions.  I swear that I got a proof of concept working at
> one point, but now I can't seem to figure out the proper syntax.
>
> I've put up an example of what I'm working on at:
>
> http://arclyte.netdojo.com/geo/edit_poly.php
>
> Some of the functionality is missing or doesn't work in this example,
> but it should at least give you an idea of what I'm talking about.
> The blue polygon in this example is for zip code 10022.  It has a
> square exclusion in it that I'm currently loading as a separate
> polygon.
>
> Here's the trick... When you click on the colored squares at the
> bottom of the page next to the polygon name, it should load the
> markers for that particular polygon's points so that you can edit it.
> So, I have to have a separate array of those points (I believe)
> outside of the polygon description that separates the polygon proper
> from its exclusions so I can edit either.  But I also want the polygon
> to load with those exclusions included into the polygon so that they
> will load as a proper "hole".
>
> And the next rabbit I'm trying to pull out of my hat is to actually
> inject new "holes" into an already defined polygon so that an
> exclusion can be added to it.  Any assistance you can give in this
> regard would be greatly appreciated.  Just a few hints on the
> formatting of such a thing would help me out a lot.
>
> I've tried doing something like this, with no luck (untested example
> only):
>
> points[0][0] = [[lat1, lng1]...[latn, lngn]];
> points[0][1] = [[lat1, lng1]...[latn, lngn]];
> path[0] = new google.maps.MVCArray([points[0]]);
> poly = new google.maps.Polygon();
> poly.setPaths(new google.maps.MVCArray([path[0]]));
>
> That gives me an invalid constructor parameter error, saying path[0]
> is an object...
>
> --
>
> You received this message because you are subscribed to the Google Groups 
> "Google Maps JavaScript API v3" 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-js-api-v3?hl=.
>
>
>

--

You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" 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-js-api-v3?hl=.


Reply via email to