Answer the question
In order to leave comments, you need to log in
How to use Leaflet offline?
I want the script to work without the Internet based on Google Maps, Yandex.maps or OpenStreetMaps. How to implement it? How to download? How to register a link to downloaded maps in a script?
Thank you!
Answer the question
In order to leave comments, you need to log in
Can be implemented with an OpenStreetMaps map.
1. Download the desired extract.bbbike.org map fragment in OSM format.
2. Tiles need to be rendered. Here is a list of rendering apps wiki.openstreetmap.org/wiki/EN:Rendering. Easy to use maperitive.net/.
3. Place a folder with tiles on the local web server.
4. link in Leaflet http://localhost/Tiles/{z}/{x}/{y}.png
In general, thanks to ittim 's answer, I managed to get to 3 points from his list.
I just want to elaborate on the first two points for those who are interested.
1. From the site extract.bbbike.org , the fragment of the map you need is downloaded. There in the field:
- "Format" select "OSM XML 7z";
- "Your email adress" enter your email address to which they will send a fragment of the map;
- "Name of area to extract" - name the fragment somehow;
Then comes the Extract button. You are skipping it for now. And you press the button smaller and lower "here". Well, of course, before that, you need to point the map on the right to the desired location. If you miss, no big deal. Click on the appeared button "Select a different area" and everything returns to its original position. Once you've made sure that the orange rectangle covers the desired area, click "Extract". All. Within half an hour, a link will be sent to your mail, by which you will download your fragment.
2. The downloaded fragment is not a picture, but XML data that needs to be converted into tiles. To do this, from maperitive.netdownload the software. Run. Go to File->Open map sources, select the downloaded XML fragment (previously unpacked). The program will think for a while (depending on the file size). Go to Tools->Generate Tiles. After that, the program will think even longer. Upon completion, the very tiles in png format will appear in the Tiles folder inside the program folder.
3. It turned out that the server can not be raised. Just write a link to a folder with tiles. For example: d:/Tiles//{z}/{x}/{y}.png
PS It turned out that you can skip 1 point and make tiles directly from the Maperitive program.
PPS The Maperitive program turned out to be difficult. At the bottom there is a command line field that allows for flexible configuration. For example, by default, five zoom levels are rendered, but if you write generate-tiles minzoom=8 maxzoom=18 on the command line, you can zoom from 8 to 18 levels.
PPPS It turned out that 1 point (ie local loading of a third-party source of maps) is still necessary if you want to modify the map using the so-called Rules. The built-in card does not react to these changes. In particular, I tried to make the names of foreign settlements (well, for example, Turkish) be displayed in Russian or English, but not in Turkish. Or that the airports were signed. So this was done only by loading maps from a local source.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question