Fusion Table and Google Maps API: Only first classes are used for rendering features

吃可爱长大的小学妹 提交于 2019-12-12 05:28:31

问题


I use queries for filtering features from a Google Fusion Table with the Google Maps API. It works very well with this code:

    var column = getColumn();

    layer = new google.maps.FusionTablesLayer({
        suppressInfoWindows: true,
        query: {
          select: 'geometry',
          from: tableno
        },
        styles: [{
          polygonOptions: {
            fillOpacity: 0.8,
            strokeColor: '#000000',
            strokeOpacity: 0.2,
            strokeWeight: 2
          }
        }, {
          where: "'$fool' <= '5.24'".replace('$fool', column),
          polygonOptions: {
            fillColor: '#FEE5D9'
          }
        }, {
          where: "'$fool' > '5.24'".replace('$fool', column),
          polygonOptions: {
            fillColor: '#FCAE91'
          }
        }, {
          where: "'$fool' > 5.83".replace('$fool', column),
          polygonOptions: {
            fillColor: '#FB6A4A'
          }
        }, {
          where: "'$fool' > 6.49".replace('$fool', column),
          polygonOptions: {
            fillColor: '#DE2D26'
          }
        }, {
          where: "'$fool' > 7.37".replace('$fool', column),
          polygonOptions: {
            fillColor: '#A50F15'
          }
        }]
    });

The problem is, that I cannot add another class. If I add something like

        {
          where: "'$fool' = '0'".replace('$fool', column),
          polygonOptions: {
            fillColor: '#ffffff'
          }
        },

only the first 3-4 classes are rendered. All following features will be coloured in the last (3rd/4th) class.

This becomes more serious when I want to highlight the selected feature, where I create another query

  var NumVal = e.row['name'].value;

for an additional class

        {
          where: "'name' = " + NumVal,
                polygonOptions: {
                    strokeColor: '#88d32f',
                    strokeOpacity: 1,
                    strokeWeight: 4
                }
        },

Suddenly only this and the following class are used. All features are coloured in the following class only.

Can anybody help? Why are suddenly queries/classes ignored when additional classes are added?


回答1:


According to the documentation under "Limits", you can only apply 5 styling rules to a FusionTablesLayer:

You can use the Maps API to add up to five Fusion Tables layers to a map, one of which can be styled with up to five styling rules.



来源:https://stackoverflow.com/questions/20814235/fusion-table-and-google-maps-api-only-first-classes-are-used-for-rendering-feat

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