iconStyler for Fusion Tables (Google Maps) won't pull column data

爷,独闯天下 提交于 2019-12-13 08:08:52

问题


I am building a map using the Google Maps API and have hit a snag. In the table I have a column that labels the iconName for each marker ('mStyle', it's col3). In the following code I am trying to set the icon style based on the column values, and I've tried many, many different iterations that haven't worked. Including this one.

What has perplexed me, is that replacing iconStyler:{} with iconName: 'grn_blank' (or whatever) does work. The documentation for markerOptions is here: https://developers.google.com/fusiontables/docs/v1/reference/style

        var layer = new google.maps.FusionTablesLayer();
    layer.setOptions
    (
    {
      query: 
      {
        select: "col0",
        from: "1UtgWf_kgwI3iUtrWvH3vIbxJfBdutl9oR8Wjqhiv",
        where: ""
      },
      styles: 
      [{
       markerOptions:
       { 
        iconStyler:
        {
          kind: 'fromColumn',
          columnName: 'mStyle',
        }               
       }
      }]
    }
    );

The code can be accessed here: https://drive.google.com/file/d/0BxeBEc_dsbUqWVJwbV9JTXRvb2s/edit?usp=sharing

The way the map should look is about 800 flags in the DC area, in various colors (red, purple, blue, green, light blue, and white). They represent schools. I can make it work in the browser-based editor, but I am adding dynamics once I get this piece to work, so I need it to work in Javascript.

Thanks


回答1:


Click on the map tab in the fusion tables UI, select "Publish", "Get HTML and Javascript". In that code grab the layer definition:

    layer = new google.maps.FusionTablesLayer({
      map: map,
      heatmap: { enabled: false },
      query: {
        select: "col0",
        from: "1UtgWf_kgwI3iUtrWvH3vIbxJfBdutl9oR8Wjqhiv",
        where: ""
      },
      options: {
        styleId: 2,
        templateId: 2
      }
    });

you want the styleId and templateId defined there (looks like 2 and 2 to me).



来源:https://stackoverflow.com/questions/22264038/iconstyler-for-fusion-tables-google-maps-wont-pull-column-data

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