KML tag trigger click event on Google Maps

I have a map that loads into dynamic external KML using labels labeled like this:

<Placemark id="MapZoneID_23443"> <name>Name Here</name> <description>Text Here</description> <styleUrl>#ff8080ff</styleUrl> <Polygon> <outerBoundaryIs> <LinearRing> <coordinates> .... </coordinates> </LinearRing> </outerBoundaryIs> </Polygon> </Placemark> 

What I would like to do is to have a link / drop-down list / all that can be clicked or selected to basically trigger a click on $('#MapZoneID_23443') ... but I cannot figure out how to trigger this click or if it is even possible. Maps can be quite complex, so I would rather not preload everything using gmaps JS markers. Thanks!

+7
source share
2 answers

This is currently not possible.

Name the problem in the error tracker to vote for it and follow it: https://code.google.com/p/gmaps-api-issues/issues/detail?id=3006

+2
source

I found a workaround.

Add this to your label in the <style> section

 <BalloonStyle><text>TEXT</text></BalloonStyle> 

You will be able to access this value after clicking on .js callback as

 event.featureData.info_window_html 

So in your KML file

 <Placemark id="MapZoneID_23443"> <BalloonStyle><text>TEXT</text></BalloonStyle> ... </Placemark> 

And in javascript

 google.maps.event.addListener(kmlLayer, 'click', function(event) { var content = event.featureData.info_window_html; console.log(content); }); 
+1
source

All Articles