开发者

Problem with event listener in google maps (with fusion tables)

开发者 https://www.devze.com 2023-03-25 01:15 出处:网络
I am trying to use google maps inside a jquery mobile app. The map has a fusion table layer, the layer loads properly, and the click listener gets called, but the value given to the callback function

I am trying to use google maps inside a jquery mobile app. The map has a fusion table layer, the layer loads properly, and the click listener gets called, but the value given to the callback function is null. I need to use values associated with the marker clicked.

Setting the layer and adding the event listener.

var layer = new google.maps.FusionTablesLayer({
     query: {
         s开发者_JAVA技巧elect: 'Address',
         from: table_id
     }
});

// map is an instance of google.maps.Map
layer.setMap(map)

google.maps.event.addListener(layer, 'click', function(e) {
     console.log(e);
     $.mobile.changePage(...);
});

Am I using the addListener properly?

Relevant documentation.

Relevant example.


I had a similar issue until I allowed the Fusion Table Layer do display the infowindow,

layer = new google.maps.FusionTablesLayer({
    query: {
      select: 'location',
      from: tableid
    },
//    options: {suppressInfoWindows: true}, // don't suppress or you lose the event 
    map: map
  }

Hope this helps.


Code works properly. Restarted my computer and the problem appears to have disappeared. (Clearing a cache perhaps?)

0

精彩评论

暂无评论...
验证码 换一张
取 消