ol2 icon indicating copy to clipboard operation
ol2 copied to clipboard

WMS does not work / Wrong getImageSize method gets called

Open joaorodr84 opened this issue 11 years ago • 0 comments

Hi I am using this "minified" version of OpenLayers recently. But it does not work with WMS layers. http://www.filedropper.com/openlayers

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

joaorodr84 avatar Nov 06 '14 11:11 joaorodr84