This is my OSM layer in openlayers 3.9.0.
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
});
And now I want to get the EPSG code
of the layer to check it so I do like
var a = layer.getProjection().getCode();
alert(a);
and I get the error layer.getProjection is not a function
.
What am I missing?
Please help me
You should getProjection
on ol.source.OSM
rather than ol.layer.Tile
, so:
layer.getSource().getProjection().getCode()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With