2

Im trying to build map with OMS under Linux (Ubuntu) to made an offline apps. Im working with Ionic and building just for Android for write now. I have the base code:

 var map;
        function init(){
            map = new OpenLayers.Map('map',
                    { maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
                      numZoomLevels: 19,
                      maxResolution: 156543.0399,
                      units: 'm',
                      projection: new OpenLayers.Projection("EPSG:900913"),
                      displayProjection: new OpenLayers.Projection("EPSG:4326")
                    });
            var newLayer = new OpenLayers.Layer.OSM("New Layer", "/tiles/${z}/${x}/${y}.png", {numZoomLevels: 19});
            map.addLayer(newLayer);
            map.addControl(new OpenLayers.Control.LayerSwitcher());
            var lonLat = new OpenLayers.LonLat(1.145, 51.865).transform(map.displayProjection,  map.projection);
            if (!map.getCenter()) map.setCenter (lonLat, 11);
            }

I got my tiles made with Maperative here:

/home/in/Android/offline/tiles/12

Inside 12 folder there are three more folders, where the png files are they are called 2223, 2224, 2225.

How does the argument "/tiles/${z}/${x}/${y}.png" really work? I have search a lot but I havens see a clear explanation. Shall I need to put the files in a special folder? If I use a complete path (Windows example):

  var newLayer = new OpenLayers.Layer.OSM("New Layer", "file://localhost/C:/Users/Ed/Downloads/Maperitive/Maperitive-1141/Tiles/${z}/${x}/${y}.png"

when I turn build to an Android apps will break the link. So maybe a relative path is a better option?

Its seems t be an easy task but Im stuck with it. Some one could help me please.

thanks in advance.

--in

  • 1
    It's the Tile map Service - wiki.osgeo.org/wiki/Tile_Map_Service_Specification - /z/ is the zoom level, /x/ is the longitude and I think is used as a directory name. Then within that directory there's y.jpeg, which has the y coordinates as the filename. – GIS-Jonathan Dec 19 '14 at 15:02
  • I see, Jonathan, I was speculating in my mind with the same idea. So with this url /tiles/${z}/${x}/${y}.png, all the tiles must be loaded even if I got one folder inside "tiles" folder or hundreds of them. But I try to load images using the code and doesnt load them, did I miss something? – Ignacio Nieto Larrain Dec 19 '14 at 15:35
  • The tiles need to be served from a webserver; not FROM the file system – Devdatta Tengshe Dec 19 '14 at 16:10
  • And there is a way to loaded locally – Ignacio Nieto Larrain Dec 19 '14 at 16:51
  • Thanks Devdatta Tengshe. Is there is a way to loaded locally using openlayers and then change it to other machine (Android) or you must use a server? I think that leafleft doenst require a server? – Ignacio Nieto Larrain Dec 19 '14 at 17: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.