Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Downloading offline tiles #89

Open
always1hungry1 opened this issue Apr 3, 2023 · 8 comments
Open

Downloading offline tiles #89

always1hungry1 opened this issue Apr 3, 2023 · 8 comments

Comments

@always1hungry1
Copy link

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

@tanmayyb
Copy link

tanmayyb commented Jun 2, 2023

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.

@tanmayyb
Copy link

tanmayyb commented Jun 2, 2023

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.

@Painkiller675
Copy link

Painkiller675 commented Jun 6, 2023

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

@Burak111
Copy link

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!.

@tanmayyb
Copy link

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

@atulsdharan
Copy link

atulsdharan commented Apr 15, 2024

hi i am new to sql database editing. i followed the steps using DB Browser for SQL lite however i could not resolve the issue. when i use the exact code made by TomSchimansky to load offline maps and to display the map in a map_widget, im getting a blank map. When im running load_offline_tiles.py , it shows that the tiles have been successfuly downloaded. a picture is attached (I have changed the lat long selection values)

mapview

however later when i try the map_with_offline_tiles.py i get a blank box with just white colour no matter which tile server i select .

I tried to carry out the instructions by @tanmayyb and @Burak111 but could not succeed. How to remove the foreign key ? im new to sql , it would be very helpful if any of you can help me to use sattellite image tiles

@mannetu
Copy link

mannetu commented Apr 15, 2024

Hi all, could this issue be related to #68? There is a typo in offline_loading.py. My PR was not merged.

@Burak111
Copy link

@atulsdharan have you edit line 18 in load_tiles.py. You should edit it to download satellite database. Zoom levels can be configured too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants