如果我们在两层中添加不同的样式,则融合表无法显示两层 [英] fusion table can not show two layers if we add different styles to the two layers

查看:73
本文介绍了如果我们在两层中添加不同的样式,则融合表无法显示两层的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于5个融合表层和1个融合表层的5种样式的限制,我不得不尝试:使用5个融合表层,每层使用两种样式,那么我可以达到我的目的:显示10地图中的不同样式.

Due to the limit of 5 fusion table layers and 5 styles of one fusion table layer, I have to try it as: use 5 fusion table layers and each one use two styles, then I can get to my purpose: show 10 different styles in a map.

但是在实施之后,我发现它仅显示第一个融合表层.

But after I implemented, I found it only show the first fusion table layer.

然后我写了一个测试用例来检查原因.并发现: 如果我们在两层中设置样式,则只能显示第一层,而第二层不显示.如果我将样式设置为一层,则效果很好.

Then I wrote a testing case to check why. And found: If we set styles in two layers, only the first layer can be displayed and the second one is gone. If I set style for one layer, it works well.

下面是我的代码,有人可以帮忙吗?现在仅显示一层.如果我们评论它们或其中之一的样式设置,则可以显示两个图层.

Below is my code, can someone help on it? Now only one layer is displayed. If we comment the style setting for them or one of them, both layers can be displayed.

提前谢谢!

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0px; padding: 0px }
#top-box {padding: 10px; background-color:#336699;}
.para-line {font-weight:bold;}
#map_canvas { height: 100% }
</style>
<script type="text/javascript"src="http://maps.google.com/maps/api/js?sensor=false"></script>

<script type="text/javascript">

    var map;

    function initialize() {
        map = new google.maps.Map(document.getElementById("map_canvas"));
        map.setMapTypeId('roadmap');
        map.setCenter(new google.maps.LatLng(38.4985464, -98.3834298));
        map.setZoom(4);

        var tableid1 =  4436842;

        var style = [{
            where: "State in('IL','PA')",
            polygonOptions: 
            {
                fillColor: "#rrggbb",
                fillOpacity: 0.7  
            }
        },{
            where: "State in('AL')",
            polygonOptions: 
            {
                fillColor: "#006400",
                fillOpacity: 0.7
            }
        }
        ];

        var query1 = {
            select: ['geometry','name'],
            from: tableid1,
            where: "State in('IL','PA')"
        }

        var query2 = {
                select: ['geometry','name'],
                from: tableid1,
                where: "State in('AL')"   
            }

        var layer1 = new google.maps.FusionTablesLayer({
            query:query1,
            styles: style,
            suppressInfoWindows: false,
            clickable:true
        }); 

        layer1.setMap(map);

        var layer2 = new google.maps.FusionTablesLayer({
            query:query2,
            styles:style,
            suppressInfoWindows: false,
            clickable:true
        }); 
        layer2.setMap(map);

        return;

    } 
</script>
</head>
<body onload="initialize()">    
<div id="map_canvas" style="width:100%; height:100%"></div>
</body>
</html>

推荐答案

限制为(来自文档您可以使用Maps API向地图添加多达五个Fusion Tables图层,其中一层可以使用多达五个样式规则进行样式设置."

The limit is (from the documentation "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."

您可以使用FusionTable用户界面设置图层的样式,但只能动态设置图层的样式,并且其中只有5条样式规则.

You can style the layers using the FusionTable User Interface, but only one can be styled dynamically and that one can only have 5 styling rules.

这篇关于如果我们在两层中添加不同的样式,则融合表无法显示两层的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆