I am attempting to move to OpenLayers 3 (OL3) and rewriting existing code that used OL2. In OL2, it was easy to get the size of an image layer. However, though it may seem obvious, I just can't seem to retrieve the size of the static image. I declare the layer as such:
imglayer = new ol.layer.Image({ opacity: 0.7, title: 'Layer title', source: new ol.source.ImageStatic({ url: imgUrl, imageSize: [1436,743], imageExtent: [-14965896.875,2359156.947,-6012238.824,6947364.421], projection: imgProj }) });Where imgUrl and imgProj are defined earlier. The image layer displays just fine and looking at the documentation, I had thought I could use something like:
var imgsize = imglayer.getSource().get('imageSize');But, this turns out to be undefined. It appears it should be a ol.source.ImageStatic property in the OL3 docs. I've tried looking in the debugger but can't find anything pointing to the property. I have a few ideas to get around this issue but it's a bit perplexing why I'm unable to easily retrieve this information when it's needed later in the code.
Thanks for any help!
أكثر...
imglayer = new ol.layer.Image({ opacity: 0.7, title: 'Layer title', source: new ol.source.ImageStatic({ url: imgUrl, imageSize: [1436,743], imageExtent: [-14965896.875,2359156.947,-6012238.824,6947364.421], projection: imgProj }) });Where imgUrl and imgProj are defined earlier. The image layer displays just fine and looking at the documentation, I had thought I could use something like:
var imgsize = imglayer.getSource().get('imageSize');But, this turns out to be undefined. It appears it should be a ol.source.ImageStatic property in the OL3 docs. I've tried looking in the debugger but can't find anything pointing to the property. I have a few ideas to get around this issue but it's a bit perplexing why I'm unable to easily retrieve this information when it's needed later in the code.
Thanks for any help!
أكثر...