这是我下面的代码。出于某种原因,正确渲染的唯一样式是笔触(它是白色)和不透明度(设置为 0.4)。但是,我的渐变似乎没有加载。相反,它全是红色的。为什么是这样?
<html>
<head>
<meta charset="UTF-8">
<title>Customizing Fusion Tables map using Fusion Tables' Javascript API</title>
<style type="text/css">
#map-canvas {
height: 800px;
width: 800px;
}
</style>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script> <!-- Google Maps API -->
<script type="text/javascript">
var locationColumn = "geometry";
var tableId = "1FbzvoRkdJzXvIxMJg2mGYVz5Q1BW2-4feMolgVc"; // California Census Tracts FT
var condition = "'Median income (dollars)'>0";
var mapOptions = {
mapTypeId: google.maps.MapTypeId.ROADMAP
};
function initialize() {
var geocoder = new google.maps.Geocoder();
var gmap = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);
var layer = new google.maps.FusionTablesLayer({
query: {
select: locationColumn,
from: tableId,
where: condition
},
styles: [
{
polygonOptions: {
strokeColor: "#ffffff",
strokeOpacity: 0.4,
strokeWeight: 1,
fillColorStyler: {
kind: "fusiontables#gradient",
columnName: "Median income (dollars)",
gradient: {
min: 28183.65,
max: 122762.9,
colors: [
{
color:"#990000",
opacity:0.4
},
{
color:"ffd966",
opacity:0.4
},
{
color:"#274e13",
opacity:0.4
}
]
}
}
}
}
]
});
geocoder.geocode(
{
'address':'California'
},
function(results,status){
var sw = results[0].geometry.viewport.getSouthWest();
var ne = results[0].geometry.viewport.getNorthEast();
var bounds = new google.maps.LatLngBounds(sw,ne);
gmap.fitBounds(bounds)
}
);
layer.setMap(gmap);
}
google.maps.event.addDomListener(window, 'load', initialize);
</script>
</head>
<body>
<div id="map-canvas"></div>
</body>
</html>