[OpenLayers-Users] WMS does not work / Wrong getImageSize method gets called

joaorodr84 joaorodr84 at gmail.com
Thu Nov 6 03:53:18 PST 2014


Hi
I am using this "minified" version of OpenLayers recently. But it does not
work with WMS layers.
OpenLayers.js
<http://osgeo-org.1560.x6.nabble.com/file/n5171621/OpenLayers.js>  

Here is what I get in the Chrome Dev Tools, on map initialization:

Uncaught TypeError: Cannot read property 'getWidth' of undefined
OpenLayers.js:9037
OpenLayers.Layer.Grid.OpenLayers.Class.getImageSize OpenLayers.js:9037
OpenLayers.Tile.Image.IFrame.createRequestForm OpenLayers.js:31236
OpenLayers.Tile.Image.IFrame.setImgSrc OpenLayers.js:31245
OpenLayers.Tile.Image.OpenLayers.Class.initImage OpenLayers.js:8733
OpenLayers.Tile.Image.OpenLayers.Class.renderTile OpenLayers.js:8674
OpenLayers.Tile.Image.OpenLayers.Class.draw OpenLayers.js:8665
OpenLayers.Tile.Image.IFrame.draw OpenLayers.js:31198
OpenLayers.TileManager.OpenLayers.Class.drawTilesFromQueue
OpenLayers.js:27135
(anonymous function) OpenLayers.js:27095
(anonymous function) OpenLayers.js:169


It seems that the error comes from the fact that there are 3 methods called
getImageSize

In line 31236, we have:
        this.layer.getImageSize();

And I this it uses the wrong getImageSize method, because it uses this one
(from line 9036):
    getImageSize: function(a) {
        var b =
OpenLayers.Layer.HTTPRequest.prototype.getImageSize.apply(this, arguments);
        this.singleTile && (b = new OpenLayers.Size(Math.round(a.getWidth()
/ this.gridResolution), b.h));
        return b
    },
As you can see, this one has an argument, and the one we called, doesn't.

I think the getImageSize method that should be called is this one (line
4660):
    getImageSize: function() {
        return this.imageSize || this.tileSize
    },

I renamed the one from line 9036 to getImageSize2, and it worked. I know
this is not a solution, but I think there might be a bug there and I come
here to ask how I could correct it.

Note: I downloaded OpenLayers from GitHub, created a minified version and
this problem was also present.

I hope you can help me.

Thanks.

João



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/WMS-does-not-work-Wrong-getImageSize-method-gets-called-tp5171621.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.


More information about the Users mailing list