forked from nzysoft/TkinterMapView
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathload_offline_tiles.py
More file actions
30 lines (22 loc) · 1.16 KB
/
load_offline_tiles.py
File metadata and controls
30 lines (22 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import tkintermapview
import os
# This scripts creates a database with offline tiles.
# specify the region to load (New York City)
top_left_position = (40.801825, -74.161928)
bottom_right_position = (40.561993, -73.742846)
zoom_min = 0
zoom_max = 15
# specify path and name of the database
script_directory = os.path.dirname(os.path.abspath(__file__))
database_path = os.path.join(script_directory, "offline_tiles_nyc.db")
# create OfflineLoader instance
loader = tkintermapview.OfflineLoader(path=database_path)
# save the tiles to the database, an existing database will extended
loader.save_offline_tiles(top_left_position, bottom_right_position, zoom_min, zoom_max)
# You can call save_offline_tiles() multiple times and load multiple regions into the database.
# You can also pass a tile_server argument to the OfflineLoader and specify the server to use.
# This server needs to be then also set for the TkinterMapView when the database is used.
# You can load tiles of multiple servers in the database. Which one then will be used depends on
# which server is specified for the TkinterMapView.
# print all regions that were loaded in the database
loader.print_loaded_sections()