[英]Legend not corresponding to colours on the Map. Fusion Tables
I am using the fusion tables API to style maps. 我正在使用Fusion Tables API来设置地图样式。 However in the legend, some countries (Uganda and Mozambique) are not showing the correct colours displayed in the legend.
但是,在图例中,某些国家(乌干达和莫桑比克)未显示图例中显示的正确颜色。
Here is the code for displaying the legend 这是显示图例的代码
<style type="text/css">
#legend {
background-color: #FFF;
margin: 10px;
padding: 5px;
width: 150px;
}
#legend p {
font-weight: bold;
margin-top: 3px;
}
#legend div {
clear: both;
}
.color {
height: 12px;
width: 12px;
margin-right: 3px;
float: left;
display: block;
}
#map-canvas{
width: 700px;
height: 650px;
}
</style>
Code fot displaying the map 显示地图的代码
function initialize() {
var map = new google.maps.Map(document.getElementById('map-canvas'), {
center: new google.maps.LatLng(-2.358937, 27.618881),
zoom: 4,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
var layer = new google.maps.FusionTablesLayer({
query: {
select: 'geometry',
from: '1MXudMo9A8yUjpO89hkac74LzGEKPyA_tDzkWJ3hl'
}
});
layer.setMap(map);
initSelectmenu();
for (column in COLUMN_STYLES) {
break;
}
applyStyle(map, layer, column);
addLegend(map);
google.maps.event.addDomListener(document.getElementById('selector'),
'change', function() {
var selectedColumn = this.value;
applyStyle(map, layer, selectedColumn);
updateLegend(selectedColumn);
});
}
The column 'Total No of Points'
has been set to the type Text
, the comparison will be based on strings what will not give the expected results. 'Total No of Points'
列已设置为Text
类型,比较将基于不会提供预期结果的字符串进行。
Simple test: 简单测试:
alert('9'>'10');//true
alert(9>10);//false
Solution: set the type of the column to Number
解决方案:将列的类型设置为
Number
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.