Hi everybody,
I'm building an application based on OpenLayers but, strange enough, I'm facing a problem with zoom and resolutions.
Though I googled a lot and searched through the mailing list, I still haven't found the correct answer to how to calculate resolutions.
Here's how I calculate them:
- having 4 zoom levels
- knowing the exact size of the map at each zoom level, say w0, w1, w2, w3, being w0 the outer zoom level
the resolutions array is calculated as [w0/w3, w0/w2, w0/w1, w0/w0].
I even tried to overestimate the wi's to make them multiple of the tile size (256 pixels), with no luck.

I use a WMS-like layer and, to retrieve the correct tile, having coordinates x and y, I override the getUrl function:


    getURL: function (bounds) {
        bounds = this.adjustBounds(bounds);
        var res = this.map.getResolution();

        var x = Math.round ((bounds.left - this.maxExtent.left) / (res * this.tileSize.w));
        var y = Math.round((this.maxExtent.bottom + bounds.bottom ) / (res * this.tileSize.h));
        var z = this.serverResolutions != null ?
            OpenLayers.Util.indexOf(this.serverResolutions, res) :
            this.map.getZoom();
        var imageSize = this.getImageSize();
        var newParams = {
            'X': x,
            'Y': y,
            'Z': z,
            'WIDTH': imageSize.w,
            'HEIGHT': imageSize.h
        };
        var requestString = this.getFullRequestString(MyOpenLayers.Configuration.MAP_TILE_PATH, newParams);
        return requestString;
    }

where:
- maxExtent is an OpenLayers bound set to [0,0,w0,h0] (w0 and h0 are the width and height at the outer zoom level)
- this.tileSize.w and this.tileSize.h are equal to 256.

Now, when zooming in, two weird behaviours occur:
- the zoomed map is not centered at the point of the map I was expecting;
- more than the necessary tiles are retrieved, even tiles with negative coordinates.

Note that I'm not using the "standard" coordinates' system used by OpenLayers, in fact the tile (0,0) is placed at the bottom left corner of the viewpoint.
Thanks in advance,
regards,
franz
_______________________________________________
Users mailing list
Users@openlayers.org
http://openlayers.org/mailman/listinfo/users

Reply via email to