Google Maps中FusionTables图层的局限性 [英] Limitations on FusionTables layers in google maps

查看:66
本文介绍了Google Maps中FusionTables图层的局限性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是KML融合表格样式,以一种独特的颜色对英国地区进行颜色编码.我已经成功用颜色编码了4个区域,但是不允许我从表格中添加更多区域.我已经添加了第二层,但是再次没有对区域进行颜色编码.这是否与KML融合表的局限性有关?任何建议将不胜感激. 这是我的代码:

I am using the KML fusion tables styling to colour-code the regions of the UK with a distinct colour. I have successfuly colour-coded 4 regions, but it does not allow me to add more regions from the table. I have added and a second layer, but again the regions are not colour-coded. Does this have to do with the limitation of KML fusion tables? Any suggestions would be much appreciated. Here is my code:

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Fusion Tables styling</title>
<style>
  html, body, #map-canvas {
    height: 100%;
    margin: 0px;
    padding: 0px
  }
</style>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
<script>
var map, layer, layer2;

function initialize() {

var leicester = new google.maps.LatLng(52.62, -1.13);

map = new google.maps.Map(document.getElementById('map-canvas'), {
  center: leicester,
  zoom: 6
});
layerMap();
secondLayerMap();
}

function layerMap(){
layer = new google.maps.FusionTablesLayer({
query: {
  select: 'geometry',
  from: '1vBKVuQNY4d8ncgg0fbgaXxDxsSdPtJMka2KsxnUZ'
},
styles: [{
  polygonOptions: {
    fillColor: '#00FF00',
    fillOpacity: 1.0
  }
}, {
  where: 'HECTARES = 7877200',
  polygonOptions: {
    fillColor: '#0000FF'
  }
}, {
  where: 'HECTARES = 159469.844',
  polygonOptions: {
    fillColor: '#FF4000'
  }
}, {
  where: 'HECTARES = 1300379.625',
  polygonOptions: {
    fillColor: '#FFFFFF'
  }
}, {
  where: 'HECTARES = 1940521.5',
  polygonOptions: {
    fillColor: '#FFFF00'
 }
}]
});
layer.setMap(map);
}
function secondLayerMap(){
layer2 = new google.maps.FusionTablesLayer({
query: {
  select: 'geometry',
  from: '1xtYFs7V7qYTwNfb2xRweXO7pY_0Y83Vom5NnYQ4-'
},
styles: [{
  polygonOptions: {
    fillColor: '#00FF00',
    fillOpacity: 1.0
  }
}, {
  where: 'HECTARES = 2122463.25',
  polygonOptions: {
    fillColor: '#0404B4'
  }
}, {
  where: 'HECTARES = 1556405.5',
  polygonOptions: {
    fillColor: '#61380B'
  }
}]
});
layer2.setMap(map);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>

推荐答案

FusionTables最多可将5个表映射到地图,最多5个动态样式可将一个用于这些图层.

FusionTables allows a maximum of 5 tables to a map, a maximum of 5 dynamic styles to one of those layers.

https://developers.google.com/maps/documentation/javascript/fusiontableslayer#limits

您可以使用Maps API将最多五个Fusion Tables图层添加到地图,其中一层可以使用多达五个样式规则进行样式设置.

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.

如果您通过FusionTables UI应用颜色(将颜色从列分配给多边形),则可以在任意多个图层中使用任意多的颜色.只有通过javascript动态分配的样式具有一层限制的5种.

If you apply the colors via the FusionTables UI (assign a color from a column to the polygons), you can use as many colors as you like in as many of those layers as you like. It is only the styles assigned dynamically via javascript that have the 5 in one layer limitation.

这篇关于Google Maps中FusionTables图层的局限性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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