Reputation: 21175
I have a map that is loading in dynamic external KML with placemarks defined like so:
<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'd like to do is have a link / dropdown / whatever that can be clicked or selected to basically trigger a click on $('#MapZoneID_23443')
... but I can't figure out how to trigger that click or if this is even possible. The maps can be quite complex, so I would prefer to not have to preload everything using JS gmaps markers. Thanks!
Upvotes: 8
Views: 2381
Reputation: 113
I have found a workaround.
Add this to your placemark in the <style>
section
<BalloonStyle><text>TEXT</text></BalloonStyle>
You will be able to access this value after click in .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);
});
Upvotes: 1
Reputation: 14411
It's not currently possible.
Star the issue on the bug tracker to both vote for it and follow it's progress: https://code.google.com/p/gmaps-api-issues/issues/detail?id=3006
Upvotes: 2