Nice and simple tool to create Maptiles - jahed / maptiles
tldr: found a nice tool to cut big maps into tiles to view them like a google map
Hi, i created a world map for my dnd campaign and found it its a bit big to share with my players via our tools (discord FoundryVTT) as it is about 90MB
i found a nice little (linux) command line tool to create tiles from my one very lage file
https://github.com/jahed/maptiles/blob/master/maptiles
You need to install ImageMagick and if you want to optimize the exported files ( pngquant (lossy) or optipng (lossless) or jpegtran (lossless) for JPG)
If you run into problems with ImageMagick failing with a big file, it is most probably memory consumption related. There is a file under Linux "/etc/ImageMagick-6/policy.xml" in which you can search for the values called memory, map, area and disk and put it on a hight value like 4GB and check the values width and height and change them to fit your image, i put a very lage numer of 64KP (Kilopixel) in there and then everything when smooth (but slow) - be aware when you change these values they are changed for every user and you may open up some security issues, so use a local machine and do not do this on a webserver without knowing what you are doing (if you know, there is a env variable to override the policy file path so you can use a sepperate from the system one)
"maptiles myverylageworldmap.png -f png -o lossless -s mytilesfoldername"
all the parameters are explained in the script
i then wrote myself a small html files that uses the leaflet.js library to display the tiles like a google maps
you can view the sourcecode and "steal" all the html for your own map if you dont want to write anything yourself (you'll see a variable called maxZoom: 6 - you may need to change this value, when you look into the tiles folder generated from the maptiles script there are numberd folders for me there a folders 0 to 6, so the maximum value of folders will be your maxZoom level)
You can also use this in obsidian with the obsidian-leaflet plugin.
Just set the tileServer
parameter and disable the default osmLayer via osmLayer: false
Hope this helps someone to show a big map to the world
Add comment