On Aug 3, 8:01 am, Lenius <cars...@lenius.dk> wrote: > Hi, > > I think you can use this example : > > map = new > google.maps.Map(document.getElementById("map_canvas"),myOptions); > > ctaLayer = new google.maps.KmlLayer(''http://www.xxxx.xx.uk/xml/ > newbinsgr.kml',{suppressInfoWindows:true,preserveViewport:true}); > google.maps.event.addListener(ctaLayer, 'click', function(obj) { > var marker = new google.maps.Marker({position: obj.position}); > infowindow.setContent(obj.position); > infowindow.setPosition(obj.position); > infowindow.open(map); > }); > > ctaLayer.setMap(map); > > /carsten > > On 2 Aug., 15:52, fastapps <de...@suttonbond.co.uk> wrote: > > > I would like to display the infoWindow for a kml polygon automatically > > on loading the layer. To do this I am trying to trigger a click on > > the polygon. In order to specify the location I pass the LatLng to > > the trigger. > > > map = new google.maps.Map(document.getElementById("map_canvas"), > > myOptions); > > ctaLayer = new google.maps.KmlLayer('http://www.xxxx.xx.uk/xml/ > > newbinsgr.kml'); > > > google.maps.event.addListener(ctaLayer,'click',function(kmlEvent) > > { > > }); > > > var aLatLng = new google.maps.LatLng(51.5, 0.15); > > google.maps.event.addListener(map,'click',aLatLng) > > > There are 2 problems 1) the infowindow does not dsplay 2) the only > > data that gets passed to the listener is that which is passed to the > > trigger call ie I only get what I already know ! > > > Is this correct ? > > > (If I click on the polygon with the mouse I get the infowindow > > displayed and the listener receives the data for the polygon.) > > > Thanks
Hi there, In your example, how does obj get populated with the placemark data from the kml file ? If I initiate a trigger, google.maps.event.trigger(ctaLayer ,'click'); then obj is undefined (as there is no parameter after the 'click' parameter. If I add a 3rd parameter google.maps.event.trigger(ctaLayer ,'click',null); then obj is null ie the listener only receives what is sent by the trigger. This does not appear to be the correct behaviour. Thanks -- 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...@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.