3
votes

I have a google map that uses a fusion table layer for dynamic styling of a large number of Polygons. On top of this layer, I'm also generating a set of markers at specific LatLng positions within the polygons themselves. I'm looking to have the following behavior:

  • When you click anywhere on a polygon, an infoWindow should pop up, populated by data from the fusion table. This is working.
  • When you click on a marker, it should pass the click event through to the fusion table layer and create the same popup as if a natural click occurred at the LatLng of the marker. This is what I'm struggling with, and isn't currently working. I'm adding a click listener to each marker, then using that to trigger a click on my fusion table layer, more or less as suggested here:

Here's the code I'm using to add a listener to each marker:

function addMarkerListener(city, LatLng){
    google.maps.event.addListener(city, "click", function(e) {
      google.maps.event.trigger(layer, 'click', {
        latLng: LatLng
      });
    });
}

In this case, layer is my fusion table layer.

Using this, the click triggers, but I don't actually get any of the data from my fusion table (stored in the row variable of the mouse event object). Instead, my mouse event is passed directly though to my listener on the fusion table layer that would normally handle clicks.

How can I create a click event on the fusion table layer, programmatically, that will pull data from the fusion table as a natural click would?

1
Did you ever figure this out? The example from @wf9a5m75 doesn't emulate arbitrary clicks to the FusionTableLayer, it loads a copy of the data set and only allows for 'clicks' of coordinates already in the data set. - Nick Strupat

1 Answers

1
votes

This is an example of Fusion Table Layer that click markers from sidebar programmatically. enter image description here

See the entire code from this page. http://googlemaps.googlermania.com/google_maps_api_v3/en/fusion-tables-sidebar.html