Good to hear! I just figured out what was possibly going wrong, but too late! :)
.nikolajp On Feb 5, 4:55 am, Dave <davidt...@gmail.com> wrote: > FIXED! > > The problem was that I was using a global variable for paths and > obviously this is just used by reference when initialising a polygon - > so any change to it for one polygon affects all those previously > created. > > Making it a local MVCarray fixes it. > > On Feb 5, 1:18 pm, Dave <davidt...@gmail.com> wrote: > > > > > > > > > I am just porting from v2 to v3. Currently only working in Firefox > > (http://boca.org.au/component/boca_birding_locations/sitelist/16), but > > I have a problem in that I am drawing a set of markers (all fine) and > > polygons, and I thought only the last polygon was being displayed. > > Digging around in the data structures using Firebug it appears that > > they are all being displayed - but with the same co-ordinates. Firebug > > confirms they are all being created with different coordinates, so it > > appears that somehow the last polygon created overwrites the paths of > > all the earlier ones. > > > The relevant JS code (called when I am parsing the XML file I > > download) is: (polys is a global array to hold the polygons so I can > > easily remove them all) > > > /* > > Function to add a polygon (or polyline if b_polygon is false) to the > > map. > > > We store a reference to the map in the polys array so that we can > > easily clear all polygons > > > The parameters are as for add_marker. > > > Note we also set a marker in the centre of the polygon and retunr a > > reference to that marker > > */ > > function > > add_polygon(lat,lng,map,colour,text,text_colour,star_colour,polystring,b_po > > lygon,title) > > { > > var poly=polys.length; > > logit("POLY",poly,polystring); > > // poly_points holds the lat/lng pairs > > poly_points.clear(); > > // parse the string to add the points to the array > > var points=polystring.split(","); > > // should validate the zoom level and number of points I suppose but > > ignore for now > > // Create the vertices of the polygon as LatLng points and add to the > > poly_points array at the end > > for (var i=0;i<points.length;i+=2) > > { > > var point=new > > google.maps.LatLng(parseFloat(points[i]),parseFloat(points[i+1])); > > // logit("POLY ",title,parseFloat(points[i]),parseFloat(points[i+1])) > > poly_points.insertAt(poly_points.length, point); > > } > > // create the polygon or polyline using the path defined > > if (b_polygon) > > { > > polys[poly] = new google.maps.Polygon({ > > strokeWeight: 1, > > fillColor: '#FFDEAD', > > fillOpacity:0.1, > > paths:poly_points > > }); > > } > > else > > { > > polys[poly] = new google.maps.Polyline({ > > strokeWeight: 1, > > path:poly_points > > }); > > } > > // and update the map with the polygon. > > polys[poly].setMap(map); > > // OK - now for the central marker > > var marker = new StyledMarker({styleIcon:new > > StyledIcon(StyledIconTypes.MARKER, > > {color:colour,text:text}),position:new > > google.maps.LatLng(lat,lng),title:title}); > > marker.setMap(map); > > return(marker); > > > } -- 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 google-maps-js-api-v3@googlegroups.com. To unsubscribe from this group, send email to google-maps-js-api-v3+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.