It looks like redeclaring my map variable was what was causing the
havoc. The following code performs as expected:
path_options.map = map;
path_options.paths = top_path;
var top_shape = new google.maps.Polygon(path_options);
google.maps.event.addListener(top_shape, "click", function()
{ alert("top_shape");});
path_options.map = map;
path_options.paths = bottom_path;
var bottom_shape = new google.maps.Polygon(path_options);
google.maps.event.addListener(bottom_shape, "click", function()
{ alert("bottom_shape");});
(Both shapes are rendered, and clicking on a shape yields the
appropriate shape popup). I guess I've answered my own question, but
I figured I'd post this here in case someone else is running into a
similar issue.
On Dec 11, 3:51 pm, Chris Apolzon <[email protected]> wrote:
> I was able to get both polygons rendered by setting the paths variable
> to Array(path1, path2). I'm not sure if this will work tho, as I need
> to attach a different infowindow to each polygon and I believe this
> solution results in one polygon with 2 paths (which happen to not
> overlap).
>
> On Dec 11, 3:10 pm, Chris Apolzon <[email protected]> wrote:
>
> > I'm not sure exactly what I'm missing here. I have this code
> > executing as an onclick event on a button. When the button is
> > pressed, you see the second polygon (only). If you hit it really
> > fast, you can see both polygons on the map prior to the layer being
> > loaded...I'm guessing thats just a trick of the eye and the first is
> > disappearing as the second is drawn.
>
> > <code>
> > map = new google.maps.Map(document.getElementById("map"),
> > map_options);
> > path_options.paths = top_path;
> > var top_shape = new google.maps.Polygon(path_options);
>
> > top_shape.setMap(map);
>
> > map = new google.maps.Map(document.getElementById("map"),
> > map_options);
> > path_options.paths = bottom_path;
> > var bottom_shape = new google.maps.Polygon(path_options);
>
> > bottom_shape.setMap(map);
> > </code>
>
> > On Dec 1, 5:47 pm, Esa <[email protected]> wrote:
>
> > > You define the map over and over again before each polygon.
>
> > > var map = new google.maps.Map(document.getElementById("map_canvas"),
> > > myOptions);
>
> > > Keep the first of those lines and delete the other ones.
--
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=en.