Ah, ignore me, I've got it now. For reference, I am now checking the
length of the gpolygons array onclick, if it is more than one, we've
got a polygon KML file, otherwise it's a standard marker:
$('.item').click(function() {
if (geoXml.docs[0].gpolygons.length > 1) {
google.maps.event.trigger(geoXml.docs[0].gpolygons[this.id],"click");
} else {
google.maps.event.trigger(geoXml.docs[0].markers[this.id],"click");
}
return false;
});
Thanks again, sometimes all you need is a shove in the right
direction! :)
On Jun 28, 2:28 am, "[email protected]" <[email protected]>
wrote:
> On Jun 27, 1:49 pm, pezholio <[email protected]> wrote:> Hi,
>
> > I'm currently working on a map which shows various KML files. Once a
> > file is loaded, the layers show up in a sidebar, and, when a sidebar
> > item is clicked, the associated marker's infowindow opens. This works
> > fine for points, but not for polygons - any ideas? Here's my code (I'm
> > using a bit of jQuery too):
>
> <snip> the link is all that is really needed
>
>
>
>
>
>
>
>
>
> > function useTheData(doc) {
>
> > console.log(doc);
>
> > var markers = [];
> > var sidebarHtml = "";
>
> > for (var i = 0; i < doc[0].placemarks.length; i++) {
> > sidebarHtml += '<li><a href="#" class="item" id="'+i
> > +'">'+doc[0].placemarks[i].name+'</a></li>';
> > }
>
> > $('#item').html(sidebarHtml);
>
> > $('.item').click(function() {
> >
> > google.maps.event.trigger(geoXml.docs[0].markers[this.id],"click");
> > return false;
> > });
>
> > }
>
> > You can see a working version here:
>
> >http://www2.lichfielddc.gov.uk/myarea/map/100031702357
>
> > All the layers bar Council Wards (which is a polygon KML file) work
> > fine.
>
> > Any ideas?
>
> Your sidebar click handler doesn't handle polygons (or polylines) only
> markers.
>
> -- Larry
--
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.