FusionTablesLayer Polygon with styleId click event not firing

三世轮回 提交于 2019-12-11 06:17:03

问题


I have a fusion table that I want to use with a styleid to configure the appearance. It seems that a FusionTablesLayer with a styleid cannot have a click event attached.

Here is an example of the FusionTablesLayerOptions I am using:

settings: {
    query: {
        select: 'geometry',
        from: '<<my table id>>'
    },
    suppressInfoWindows: true,
    styleId: 2
}

And here is the click event that does not fire:

google.maps.event.addListener(<<my FusionTablesLayer obj>>, 'click', function () {
    console.log('layer click');
});

When I change the FusionTablesLayerOptions to this, the event does fire:

settings: {
    query: {
        select: 'geometry',
        from: '<<my table id>>'
    },
    suppressInfoWindows: true
}

So my question is - do you think that layers with a styleId don't support click events? Or am I missing something?


回答1:


There is no "styledId" property in FusionTablesLayerOptions. https://developers.google.com/maps/documentation/javascript/3.exp/reference#FusionTablesLayerOptions

Please check the official document: https://developers.google.com/maps/documentation/javascript/layers#fusion_table_styles




回答2:


There is a styleId property documented here, doesn't seem to have made it into the Google Maps API v3 Documentation yet.

See this thread in the Fusion Tables Users Group for more information. Seems like others are having the same issue.

How many maps tabs do you have in the new look? Maybe you need a different styleId number.




回答3:


Ok I solved it:

  1. There is a "styledId" property in FusionTablesLayerOptions and its documented here

  2. This issue was being caused by the opacity of the polygon fill color. Seems that if the opacity of a polygon fill is set to 0% then no click events attached to the layer will fire. Setting the opacity to 1% fixed this issue straight away. I have added an image here to demonstrate.



来源:https://stackoverflow.com/questions/13812749/fusiontableslayer-polygon-with-styleid-click-event-not-firing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!