gpt4 book ai didi

javascript - 在哪里添加可见性 : false in openlayers code?

转载 作者:行者123 更新时间:2023-11-28 16:26:52 24 4
gpt4 key购买 nike

我想知道在下面的代码中哪里可以添加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
}
);

第二个代码:

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);

关于javascript - 在哪里添加可见性 : false in openlayers code?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7700448/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com