Friday 31 May 2019

Viewing map tiles from Maperitive in leaflet or openlayers


I generated tiles in Maperative. Created following html file:

















, but do not see a map - only a form for map with +- buttons. What could be a problem?


I configured both the openlayers and leaflet, but it seems that this programs seek wrong folder/folder/file.png names on coordinates I provide. But I have no idea how to set this names in Maperative, I see many people generate tiles using mapnik, but as I understand, to do this I need to set up a database and something else. Maybe there is an easier method?



Answer



You better specify the full path to the tiles. In Openlayers I added these lines:


    var MyMapnikLayer = new OpenLayers.Layer.OSM("myMapnik", "file:///D:/Tiles/myMapnik/${z}/${x}/${y}.png", {numZoomLevels: 16, alpha: true, isBaseLayer: true, visibility: false});
map.addLayer(MyMapnikLayer);


This is for Windows; Linux and Mac might have different ways to give absolute paths.


You can also take a look at the error console of your browser to see if something else is wrong.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...