TomSchimansky / TkinterMapView

A python Tkinter widget to display tile based maps like OpenStreetMap or Google Satellite Images.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Downloading offline tiles

always1hungry1 opened this issue · comments

First of all, I want to express great gratitude to TomSchimansky, who made this code. Thanks to you, I am inspired to work.
The main problem is how to change tile server for downloading. I changed in offline_loading.py tile_server from https://a.tile.openstreetmap.org/{z}/{x}/{y}.png to https://mt0.google.com/vt/lyrs=m&hl=en&x={x}&y={y}&z={z}&s=Ga. After run the code I get message that work is done. But when I want to use offline_tile to display in tkinter, its empty. But If I use default code, its work fine. Can someone help me with this problem.
P/s Sorry for my English and coding level. I am a new to this field. Thanks for your time

Same issue. The database seems to be downloading files from the satellite alright,; but the loader(def request_image) in tkintermapview/map_widget.py does not seem to load map tile, it returns an empty tile to the map. If someone has some time pleassseee help resolve this bug.

Okay I resolved it. The database(.db) uses SQLite, and the satellite imagery tiles downloaded from google are saved the same way as the osm ones due to the parsing method of the OfflineLoader i.e. the zoom, x and y columns are preserved the same way for the google maps as for the osm ones.

But the server column/table attribute contains a string like:
http://mt0.google.com/vt/lyrs=y&hl=en&x={x}&y={y}&z={z}&s=Ga
Which causes a problem for the map_widget.py in loading the tiles (the widget returns empty tiles).

An easy fix is to edit the downloaded google satellite imagery database's server attribute and replace the previous string with the default osm one:
https://a.tile.openstreetmap.org/{z}/{x}/{y}.png
This should let you load google satellite imagery in tkinter mapview.
TLDR: the downloaded database downloads the files correctly but the server string column has to replaced with default osm tileserver string to make it work with tkintermapview. Hope this helps.

tanmayyb
I downloaded .db
I opened it in DB Browser
What should I do then??
I didn't get it sorry

tanmayyb I downloaded .db I opened it in DB Browser What should I do then?? I didn't get it sorry

It took me time to understand problem. I haven't solve the problem in python script. However, quick fix for downloaded maps is possible.

  1. Install a program that you can edit the ".db" files. I used SQLiteStudio but it doesn't matter.
  2. ".db" files has 3 tables in it (sections, server, and tiles). Go to tiles and remove FOREIGN key set for the server. Go to sections and remove FOREIGN key set for the server. Finally you can edit url's and server.
  3. Set (UPDATE) url and servers to https://a.tile.openstreetmap.org/{z}/{x}/{y}.png.
  4. Save the .db file.

Now you should run and test with map_with_offline_tiles.py. If you haven't download all map for all zoom levels you might not see map directly. Try zooming in and out.

A better solution would be editing the request_image function in the map_widget.py. It is not so complicated. However, I didn't test it!.

Yes exactly @Burak111 . Sorry I don't know how I missed @Painkiller675's comment.