gpt4 book ai didi

openlayers-3 - 从 openlayers 3 层获取 EPSG 代码

转载 作者:行者123 更新时间:2023-12-04 14:11:04 24 4
gpt4 key购买 nike

这是我在 openlayers 3.9.0 中的 OSM 层。

var layer = new ol.layer.Tile({
source: new ol.source.OSM(

{
attributions: [
new ol.Attribution({
html: 'All maps © ' +
'<a href="http://www.opencyclemap.org/">OpenCycleMap</a>'
})
]
}

),
opacity: 0.8,
brightness: 0.8
});

现在我想得到 EPSG code层的检查它所以我喜欢
var a = layer.getProjection().getCode();
alert(a);

我收到错误 layer.getProjection is not a function .

我错过了什么?

请帮我

最佳答案

您应该 getProjection ol.source.OSM而不是 ol.layer.Tile , 所以:

layer.getSource().getProjection().getCode()

关于openlayers-3 - 从 openlayers 3 层获取 EPSG 代码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32766126/

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