Google Maps Fusion Table 图层不应用基于文本列的条件样式

发布于 2025-01-03 21:16:12 字数 1358 浏览 3 评论 0原文

我想根据具有三个不同字符串值的列应用不同的标记样式。查询工作正常,如果脚本中没有定义样式,它会使用 FT 样式,但如果实现了条件逻辑 - 地图会获取带有“数据仍可能正在加载”标签的图层,并且不会产生错误。

代码是:

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
        var map,layer;
        google.load('maps', '3', { other_params: 'sensor=false' });
        google.setOnLoadCallback(function(){
        var cp = new google.maps.LatLng(42.87, 74.57);
        map = new google.maps.Map(document.getElementById('map'), {
          center: cp,
          zoom: 7,
          mapTypeId: 'roadmap'
        });
        layer = new google.maps.FusionTablesLayer({
          query: { select: 'Locations (oblast, rayon, village)', from: '2825956' },
          // if the styles definition below exists map doesn't get any data layer applied
          styles: [
            { markerOptions: { iconName: 'wht_blank'} },
                { where: "'Thematic area' = 'Environment and Sustainable development'", markerOptions: { iconName: 'grn_blank' }},
                { where: "'Thematic area' = 'Democratic Governance Programme'", markerOptions: { iconName: 'blu_blank' }},
                { where: "'Thematic area' = 'Poverty Reduction'", markerOptions: { iconName: 'red_blank' }}
            ]
        });
        layer.setMap(map);
    });
</script>

I'd like to apply different marker styles depends on the column with three different string values. Query works fine, it uses FT styles if no styles defined in the script, but if there is conditional logic implemented - map gets the layer with "Data still maybe loading" label and no error produced.

The code is:

<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
        var map,layer;
        google.load('maps', '3', { other_params: 'sensor=false' });
        google.setOnLoadCallback(function(){
        var cp = new google.maps.LatLng(42.87, 74.57);
        map = new google.maps.Map(document.getElementById('map'), {
          center: cp,
          zoom: 7,
          mapTypeId: 'roadmap'
        });
        layer = new google.maps.FusionTablesLayer({
          query: { select: 'Locations (oblast, rayon, village)', from: '2825956' },
          // if the styles definition below exists map doesn't get any data layer applied
          styles: [
            { markerOptions: { iconName: 'wht_blank'} },
                { where: "'Thematic area' = 'Environment and Sustainable development'", markerOptions: { iconName: 'grn_blank' }},
                { where: "'Thematic area' = 'Democratic Governance Programme'", markerOptions: { iconName: 'blu_blank' }},
                { where: "'Thematic area' = 'Poverty Reduction'", markerOptions: { iconName: 'red_blank' }}
            ]
        });
        layer.setMap(map);
    });
</script>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

审判长 2025-01-10 21:16:12

很高兴看到您正在使用 FT 造型。这是一个很棒的功能。

您的代码只有一个问题。您在表格中查找的列实际上称为Locations

将您的查询更改为:

query: { select: 'Locations', from: '2825956' },

一切正常。

Cool to see that you're using FT styling. It's a great feature.

There's only one problem with your code. The column you're looking for in your table is actually called Locations.

Change your query to this:

query: { select: 'Locations', from: '2825956' },

and everything works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文