Openlayers 3 从openlayers 3层获取EPSG代码
这是我在openlayers 3.9.0中的OSM层Openlayers 3 从openlayers 3层获取EPSG代码,openlayers-3,Openlayers 3,这是我在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.opencyclema
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
});
我得到了错误层。getProjection不是一个函数
我错过了什么
请帮助我您应该在ol.source.OSM
上而不是ol.layer.Tile
,因此:
layer.getSource().getProjection().getCode()
成功了。出于好奇,我无法理解为什么我需要getSource
,因为我用getProjection
获得了层的投影。有什么帮助吗?谢谢,因为ol.layer.Tile对投影一无所知。
layer.getSource().getProjection().getCode()