Skip to content

Instantly share code, notes, and snippets.

@tito
Created April 11, 2019 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tito/f4f3d7baea4e145e5d71db528c7b7170 to your computer and use it in GitHub Desktop.
Save tito/f4f3d7baea4e145e5d71db528c7b7170 to your computer and use it in GitHub Desktop.
Mapview without longitude restriction
diff --git a/mapview/downloader.py b/mapview/downloader.py
index f5b9509..c3b1d75 100644
--- a/mapview/downloader.py
+++ b/mapview/downloader.py
@@ -77,7 +77,8 @@ class Downloader(object):
print("Downloader: use cache {}".format(cache_fn))
return tile.set_source, (cache_fn, )
tile_y = tile.map_source.get_row_count(tile.zoom) - tile.tile_y - 1
- uri = tile.map_source.url.format(z=tile.zoom, x=tile.tile_x, y=tile_y,
+ tile_x = tile.tile_x % (tile.map_source.get_col_count(tile.zoom))
+ uri = tile.map_source.url.format(z=tile.zoom, x=tile_x, y=tile_y,
s=choice(tile.map_source.subdomains))
if DEBUG:
print("Downloader: download(tile) {}".format(uri))
diff --git a/mapview/view.py b/mapview/view.py
index a67fc1c..bd25cc0 100644
--- a/mapview/view.py
+++ b/mapview/view.py
@@ -759,14 +759,15 @@ class MapView(Widget):
x_count = int(ceil(w / scale / float(size))) + 1
y_count = int(ceil(h / scale / float(size))) + 1
- tile_x_first = int(clamp(vx / float(size), 0, max_x_end))
+ # tile_x_first = int(clamp(vx / float(size), -padding_x, max_x_end + padding_x))
+ tile_x_first = int(vx // size)
tile_y_first = int(clamp(vy / float(size), 0, max_y_end))
tile_x_last = tile_x_first + x_count
tile_y_last = tile_y_first + y_count
- tile_x_last = int(clamp(tile_x_last, tile_x_first, max_x_end))
+ # tile_x_last = int(clamp(tile_x_last, tile_x_first, max_x_end))
tile_y_last = int(clamp(tile_y_last, tile_y_first, max_y_end))
- x_count = tile_x_last - tile_x_first
+ # x_count = tile_x_last - tile_x_first
y_count = tile_y_last - tile_y_first
return (tile_x_first, tile_y_first, tile_x_last, tile_y_last,
x_count, y_count)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment