我试图通过api v3将多边形的融合层导入谷歌地图。地图和融合图层正常,但fillOpacity和fillColour在保存融合表或地图api后没有生效:
var fusionTableId = "1Rd2LBEusHQsjsMAVsgYm_E_4OlpqgSb07ojJRL3O";
fusionLayer = new google.maps.FusionTablesLayer(fusionTableId,{
suppressInfoWindows: true,
map: map,
styles: [{
polygonOptions: {
fillColor: "#00FF00",
fillOpacity: 0.3
}
}]
});
fusionLayer.setMap(map);
多边形以默认的红色显示,似乎没有我可以改变颜色的组合。
理想情况下,我只是希望不透明度降低到1%,但我尝试改变颜色(如上所述),没有任何乐趣。
任何提示/提示?
非常感谢
答案 0 :(得分:1)
你正在使用" old" FusionTablesLayer语法FusionTablesLayer(FusionTableId, options:FusionTablesLayerOptions)
var fusionTableId = "1Rd2LBEusHQsjsMAVsgYm_E_4OlpqgSb07ojJRL3O";
fusionLayer = new google.maps.FusionTablesLayer(fusionTableId,{
suppressInfoWindows: true,
map: map,
styles: [{
polygonOptions: {
fillColor: "#00FF00",
fillOpacity: 0.3
}
}]
});
fusionLayer.setMap(map);
current syntax是:
FusionTablesLayer(options:FusionTablesLayerOptions)
(支持您尝试使用的动态样式)将是:
var fusionTableId = "1Rd2LBEusHQsjsMAVsgYm_E_4OlpqgSb07ojJRL3O";
fusionLayer = new google.maps.FusionTablesLayer({
suppressInfoWindows: true,
map: map,
query: {
from: fusionTableId,
select: "geometry"
},
styles: [{
polygonOptions: {
fillColor: "#00FF00",
fillOpacity: 0.3
}
}]
});
fusionLayer.setMap(map);
(正如你发现的那样)
答案 1 :(得分:0)
似乎答案是盯着我的脸 - 代码稍微改变了一下,它起了作用:
var fusionTableId = "1Rd2LBEusHQsjsMAVsgYm_E_4OlpqgSb07ojJRL3O";
fusionLayer = new google.maps.FusionTablesLayer({
map: map,
suppressInfoWindows: true,
query: {
select: "geometry",
from: fusionTableId
},
styles: [{
polygonOptions: {
fillColor: "#00FF00",
fillOpacity: 0.3
}
}]
});