Javascript 在openlayers代码中的何处添加可见性:false?
我想知道在下面的代码中在哪里可以添加可见性:false: 就像第二个代码一样Javascript 在openlayers代码中的何处添加可见性:false?,javascript,openlayers,openstreetmap,Javascript,Openlayers,Openstreetmap,我想知道在下面的代码中在哪里可以添加可见性:false: 就像第二个代码一样 var line_10 = new OpenLayers.Layer.GML("Line nr-10", "lines/line_10.kml", { format: OpenLayers.Format.KML, style: {strokeWidth: 4, strokeColor: "#f08080", fillOpacity: 1 }, proje
var line_10 = new OpenLayers.Layer.GML("Line nr-10",
"lines/line_10.kml",
{
format: OpenLayers.Format.KML,
style: {strokeWidth: 4, strokeColor: "#f08080", fillOpacity: 1 },
projection: map.displayProjection
}
);
第二个代码:
var linja4_2 = new OpenLayers.Layer.Vector("Line nr-4 stations", {
projection: map.displayProjection,
strategies: [new OpenLayers.Strategy.Fixed()],
protocol: new OpenLayers.Protocol.HTTP({
url: "/data/linja-nr4.kml",
format: new OpenLayers.Format.KML({
extractStyles: true,
extractAttributes: true
})
}),
visibility: false
});
如果我没记错的话,我会把
可见性
放在这里:
var line_10 = new OpenLayers.Layer.GML("Line nr-10",
"lines/line_10.kml",
{
format: OpenLayers.Format.KML,
style: {strokeWidth: 4, strokeColor: "#f08080", fillOpacity: 1 },
projection: map.displayProjection
}, {
visibility: false
}
);
或如评论中所建议的:
var line_10 = new OpenLayers.Layer.GML("Line nr-10",
"lines/line_10.kml",
{
format: OpenLayers.Format.KML,
style: {strokeWidth: 4, strokeColor: "#f08080", fillOpacity: 1 },
projection: map.displayProjection
}
);
line_10.setVisibility(false);
如果我没记错的话,我会把
可见性
放在这里:
var line_10 = new OpenLayers.Layer.GML("Line nr-10",
"lines/line_10.kml",
{
format: OpenLayers.Format.KML,
style: {strokeWidth: 4, strokeColor: "#f08080", fillOpacity: 1 },
projection: map.displayProjection
}, {
visibility: false
}
);
或如评论中所建议的:
var line_10 = new OpenLayers.Layer.GML("Line nr-10",
"lines/line_10.kml",
{
format: OpenLayers.Format.KML,
style: {strokeWidth: 4, strokeColor: "#f08080", fillOpacity: 1 },
projection: map.displayProjection
}
);
line_10.setVisibility(false);
尝试在GML上使用
setVisibility()
。对不起,我不知道该放在哪一行!?在变量行_10的声明后面的代码之外。我不能在这里测试它,但我想这应该是可行的:line_10.setVisibility(false)代码>尝试在GML上使用setVisibility()
。对不起,我不知道该放在哪一行!?在变量行_10的声明后面的代码之外。我不能在这里测试它,但我想这应该是可行的:line_10.setVisibility(false)你救了我!添加.setVisibility(false);对我来说,每个基本层对加载性能都有巨大的影响。你救了我!添加.setVisibility(false);对我来说,每个基本层对加载性能都有巨大的影响。