2

I'm trying to show a tiled image layer on Google Maps, which is currently showing on an OpenLayers / ESRI engine.

OpenLayers has a parameter on a TMS layer to specify tileOrigin (0,0 is different)

http://dev.openlayers.org/docs/files/OpenLayers/Layer/TMS-js.html#OpenLayers.Layer.TMS.serverResolutions

What is the formula to specify this offset in Google Maps?

I have a set of server resolutions and a tileOrigin

var lod = [1322.9166666666667, 661.45833333333337, 396.87500000000006, 264.58333333333337, 198.43750000000003, 132.29166666666669, 66.145833333333343, 39.687500000000007, 26.458333333333336, 19.843750000000004, 13.229166666666668, 6.6145833333333339, 3.9687500000000004, 2.6458333333333335, 1.3229166666666667, 0.66145833333333337, 0.26458333333333334];

"tileOrigin": {"x": 345000.0, "y": 215000.0},

So far I have tried

gmap.mapTypes.set("DOF2014", new google.maps.ImageMapType({
                        getTileUrl: function(coord, zoom) {
                            var row = coord.x;
                            var col = Math.pow(2, zoom) - coord.y - 1;

                            var lod = [1322.9166666666667, 661.45833333333337, 396.87500000000006, 264.58333333333337, 198.43750000000003, 132.29166666666669, 66.145833333333343, 39.687500000000007, 26.458333333333336, 19.843750000000004, 13.229166666666668, 6.6145833333333339, 3.9687500000000004, 2.6458333333333335, 1.3229166666666667, 0.66145833333333337, 0.26458333333333334];

                            var res = lod[14-zoom];
                            var x = Math.round((row - 345000.0/res/256));
                            var y = Math.round((col - 215000.0/res/256));

                            return "http://gistiles4.arso.gov.si/nukleus_tiles/Gis/NukleusTiles/v50/AgccTile.ashx?gcid=lay_AO_DOF_2014&r="+x+"&c="+y+"&lod="+zoom+"&lid=lay_ao_dof_2014&f=jpg";
                        },
                        tileSize: new google.maps.Size(256, 256),
                        name: "DOF2014",
                        maxZoom: 18
                    }));

But I can't get it right.

OpenLayers uses bounds in the getURL function

https://github.com/openlayers/ol2/blob/master/lib/OpenLayers/Layer/TMS.js

getURL: function (bounds) {
    bounds = this.adjustBounds(bounds);
    var res = this.getServerResolution();
    var x = Math.round((bounds.left - this.tileOrigin.lon) / (res * this.tileSize.w));
    var y = Math.round((bounds.bottom - this.tileOrigin.lat) / (res * this.tileSize.h));
    var z = this.getServerZoom();
    var path = this.serviceVersion + "/" + this.layername + "/" + z + "/" + x + "/" + y + "." + this.type; 
    var url = this.url;
    if (OpenLayers.Util.isArray(url)) {
        url = this.selectUrl(path, url);
    }
    return url + path;
},
  • Hi, have you maybe found an answer to this? I'm having the same issue with some other wms hosted on arso website. – MaticDiba Mar 22 '18 at 13:01
  • No, I haven't. :( I'd appreciate if you get back to me, if you manage to solve it. – jean Mar 22 '18 at 14:57
  • I managed to get results from arso wms the way to use bounding box. you can check it out here: www.katasterjam.si (choose Lidar). But I'm not yet happy with it, because tiles are not aligned as they should be. I'm still looking for a solution – MaticDiba Mar 22 '18 at 15:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.