谷歌地图中FusionTables图层的限制

时间:2014-09-04 09:20:26

标签: google-maps

我正在使用KML融合表样式来对英国地区进行颜色编码,颜色鲜明。我已经成功地对4个区域进行了颜色编码,但它不允许我从表中添加更多区域。我添加了第二层,但区域再次没有颜色编码。这是否与KML融合表的限制有关?任何建议将不胜感激。 这是我的代码:

<!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>

1 个答案:

答案 0 :(得分:0)

FusionTables允许最多5个表格到地图,最多5个动态样式到一个这些图层。

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

  

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

如果您通过FusionTables UI应用颜色(将颜色从列指定为多边形),您可以根据需要在任意多个图层中使用任意数量的颜色。只有通过javascript动态分配的样式才具有5层一层的限制。