On Jan 4, 8:08 pm, sam <[email protected]> wrote: > I have a map with a KML layer that displays a simple crosshair in the center > of the screen. As it stands the crosshair blocks clicks from registering on > the map. My attempt to forward clicks on the KmlLayer to the map looks like > this: > > // Init crosshairs > var crosshairsLayer = new > google.maps.KmlLayer('http://madan.org/treksee/crosshairs.kml', { > map: g_map, > preserveViewport: true, > suppressInfoWindows: true > }); > // Forward click events on the crosshairs to the map (except it doesn't > work) > google.maps.event.addListener(crosshairsLayer, 'click', > function(kmlEvent) { > alert('Why did you click on the crosshairs?'); > google.maps.event.trigger(g_map, 'click', kmlEvent.latLng); > }); > > But this doesn't work. You can see it in action (inaction?) here: > > http://madan.org/treksee > > Clicking on the map will draw a marker. Clicking on the crosshair should > show an alert and draw a marker, but it currently does nothing.
I suspect it isn't going to work, I did a quick test and the KmlLayer doesn't seem to fire a click event on the screenoverlay. I'm not sure if that is intentional or not. I would think that if you weren't going to fire click events that you should pass them on to the map, it may be a bug in the KmlLayer. I searched the v2 and found this: http://groups.google.com/group/google-maps-api/browse_frm/thread/20ad4ddbed6ba822/d6fdaf090c016887?lnk=gst&q=crosshairs#d6fdaf090c016887 GEvent.addListener(map, 'move', function() { var center = map.getCenter(); cMarker.setPoint(center); }); (where cMarker is the crosshairs marker) I'm thinking that you might be able to do something with MVC objects, to make the marker stay at the center. http://code.google.com/apis/maps/articles/mvcfun.html I don't have time to investigate it right now. Maybe someone else has an implementation or an idea for you. -- 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.
