Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am trying to show a regional map on top of base map but without success. While debugging I noticed that my regional map has a different set of resolutions from the base. Is this allowed in OpenLayers?

See http://jsfiddle.net/Sq9hE/15/

If you change the map options to use yorkLayer's resolutions array then the regional tiles will load but no the base map's.

share|improve this question
add comment

2 Answers 2

up vote 3 down vote accepted
+50

maybe there is an easy way for solving this but if we choose to go the hard way, you can write your own cache mechanism for overlaping certain zoom levels with your yorkLayer and your baseLayer.

File and Folder Mechanisms:

z = zoom
x = folder name
y = file name

Google Map: z/x/y.jpg

ArcGIS Cache: z/y/x.jpg

Example Image Adress:

http://ww4.yorkmaps.ca/ArcGIS/rest/services/CacheMaps/YR_StreetMap/MapServer/tile/0/633/286

TMS Cache: z/x/((2**z - 1) -y).jpg

and you can use this:

var yorkUrl = 'http://ww4.yorkmaps.ca/ArcGIS/rest/services/CacheMaps/
               YR_StreetMap/MapServer/tile/';

....

function get_my_url (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.top - bounds.top) / (res * this.tileSize.h));
        var z = this.map.getZoom();

        var path = z + "/" + x + "/" + y + "." + this.type;
        var url = this.url;
        if (url instanceof Array) {
            url = this.selectUrl(path, url);
        }
        return url + path;       
    };   



var yorkLayer = new OpenLayers.Layer.TMS("YorkLayer", yorkUrl , { 'type':'png', 
                'getURL':get_my_url });
    yorkLayer.isBaseLayer = false;

but dont forget you have to beat your brains out to get true result...The point to focus on is that get_my_url function...

i hope it helps you...

share|improve this answer
add comment

This is an annoying behaviour of ArcGIS: to start the zoom level number at the first scale level of the map service, instead of just align it to the defacto zoom/scale matching of full-world services.

If possible (i.e. if you have control and can make changes to the YR_StreetMap service), I would recommend changing the defined scale range to match the standard like World_Street_Map (i.e. level zero = 1:591M). You don't need to create the extra tiles for those top zoom levels, or you could create simple placeholders tiles.

I'm not sure of the specifics of OpenLayers -- there may be an easier way to do it. Changing the URL to various tiles (as in Aragon's answer) is certainly another way to fix the zoom level discrepancy. I think making everything the same is nicer: that way the tile references (e.g. z/y/x) are the same between services.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.