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!
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
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);
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With