Trigger click event on a Fusion table layer

845 views
Skip to first unread message

Anders E

unread,
Feb 6, 2011, 2:35:50 PM2/6/11
to Google Maps JavaScript API v3
I have a map that shows a Fusion Tables layer based on kml polygons
that are in the Fusion table.

What I want to do is trigger a click event on that layer with a
certain LatLong in order to get the Fusion tables row back and display
that info using my own function openInfoWindow() (with default
infowindows suppressed)

Short version of code:
-------

layer = new google.maps.FusionTablesLayer(ELK.table_id);
layer.setOptions({suppressInfoWindows : true});
var query = ["select geo from ",table_id," where '",category,"' >
0"].join('');
layer.setQuery(query);
layer.setMap(mymap);

google.maps.event.addListener(layer, 'click',
function(e){
infoWindow.close()
openInfoWindow(e);
});
-----------
The event is triggered like this:

google.maps.event.trigger(layer, 'click', new
google.maps.LatLng(64.9227249653748,13.49316406250001));
--------

The problem is that the e object returned by the click event is not a
"fusion tables row" object, but an object consisting only of the
latlng that was "clicked"

Is there a way to trigger the "real click on a FT layer" so that the
FT feature object will be returned (with row/columns)?

Anders

geoco...@gmail.com

unread,
Feb 6, 2011, 3:18:53 PM2/6/11
to Google Maps JavaScript API v3
On Feb 6, 11:35 am, Anders E <anders.grimsrud.erik...@gmail.com>
wrote:
> I have a map that shows a Fusion Tables layer based on kml polygons
> that are in the Fusion table.
>
> What I want to do is trigger a click event on that layer with a
> certain LatLong in order to get the Fusion tables row back and display
> that info using my own function openInfoWindow() (with default
> infowindows suppressed)

I don't think you can do that. But you can write your own click
handler that queries the Fusion Table for results (at least I would
think you could, haven't tried it myself), and display it however you
like.

>
> Short version of code:

No thanks.
READ THIS FIRST: Posting Guidelines
http://groups.google.com/group/google-maps-js-api-v3/t/2b3f101fd509919e

> The problem is that the e object returned by the click event is not a
> "fusion tables row" object, but an object consisting only of the
> latlng that was "clicked"

Shouldn't be. Should be a FusionTablesMouseEvent
http://code.google.com/apis/maps/documentation/javascript/reference.html#FusionTablesMouseEvent

-- Larry

Randy Majors

unread,
Aug 24, 2011, 2:12:05 PM8/24/11
to google-map...@googlegroups.com
Hi,

Did you ever figure out how to do this?  I'm trying to do the exact same thing.

Thanks for any help

All the best,
Randy

Chris Broadfoot

unread,
Aug 26, 2011, 1:26:05 AM8/26/11
to google-map...@googlegroups.com
Hi Randy,

The only way I can think that this would be possible would be to send off a spatial query to the Fusion Tables API (using your own server, of course) and return the results back to your JavaScript application.

You can read more about the FT API here:

--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-maps-js-api-v3/-/jGKed95V2d4J.

To post to this group, send email to google-map...@googlegroups.com.
To unsubscribe from this group, send email to google-maps-js-a...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Randy Majors

unread,
Aug 26, 2011, 7:37:53 AM8/26/11
to google-map...@googlegroups.com
Hi Chris,
Thanks for the reply.

However, I think this IS possible with javascript using the JSONP interface, according to the following couple of examples I've found in this group:



Am I missing something?




Chris Broadfoot

unread,
Aug 29, 2011, 3:25:58 AM8/29/11
to google-map...@googlegroups.com
Hi Randy,

The JSONP interface you referenced is not documented, therefore not supported, so I would heavily discourage you from using it.

Chris

--


--
You received this message because you are subscribed to the Google Groups "Google Maps JavaScript API v3" group.

jackotonye

unread,
Oct 8, 2017, 6:28:49 PM10/8/17
to Google Maps JavaScript API v3
Hi Anders,


To access the row object you can get that from the event object passed to the callback,

google.maps.event.addListener(layer, 'click', function (e) {
let row = e.row;
let address = row.address.value;
let longitude = row.longitude.value;
let latitude = row.latitude.value;
});
 
Reply all
Reply to author
Forward
0 new messages