You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello!
I am struggling for several hours to solve this, would appreciate any help. Tried using any possible AI for help, with no success.
I have offline machine where I need to display some maps. I downloaded tiles (zoom 0-7). The server with tiles seems to be running well, and I can access each tile via URL in the browser. When I try to run the PyDeck client (I try to visualize it with streamlit), there is only black screen instead of the map. I see that server does send the .png images to the client! But they don't display.
What am I doing wrong?
Thanks!!
PS. I attached the Tiles files for your convenience tiles.zip
Server Code:
from pathlib import Path
from flask import Flask, abort, send_file
from flask_cors import CORS
# Root directory where downloaded tiles are stored
TILE_ROOT = Path(__file__).parent / "tiles"
app = Flask(__name__)
CORS(app)
@app.route("/tiles/<int:z>/<int:x>/<int:y>.png")
def get_tile(z: int, x: int, y: int):
tile_path = TILE_ROOT / str(z) / str(x) / f"{y}.png"
if not tile_path.is_file():
abort(404, description="Tile not found")
response = send_file(tile_path, mimetype="image/png", conditional=True)
# Prevent long-lived browser caching so offline tests reflect server state
response.headers["Cache-Control"] = "no-store, no-cache, must-revalidate, max-age=0"
response.headers["Pragma"] = "no-cache"
return response
if __name__ == "__main__":
# Bind to all interfaces so other devices on the network can access it
app.run(host="0.0.0.0", port=5000)
Client code
import pydeck as pdk
import streamlit as st
# URL for tiles served by offline_tile_server.py
TILE_URL = "http://localhost:5000/tiles/{z}/{x}/{y}.png"
st.set_page_config(page_title="Offline Tiles Viewer", layout="wide")
st.title("Offline Tiles + pydeck")
# Build layers
layers = []
# NEW: Enhanced TileLayer for better offline coverage/debug
layers.append(
pdk.Layer(
"TileLayer",
data=TILE_URL,
min_zoom=0,
tile_size=256,
extent=4096,
tile_format="png",
pickable=True, # NEW: Enables interaction
)
)
view_state = pdk.ViewState(latitude=0,
longitude=0,
zoom=0,
pitch=0,
bearing=0)
r = pdk.Deck(
map_style=None,
map_provider=None,
layers=layers,
initial_view_state=view_state,
)
st.pydeck_chart(r, use_container_width=True)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello!
I am struggling for several hours to solve this, would appreciate any help. Tried using any possible AI for help, with no success.
I have offline machine where I need to display some maps. I downloaded tiles (zoom 0-7). The server with tiles seems to be running well, and I can access each tile via URL in the browser. When I try to run the PyDeck client (I try to visualize it with streamlit), there is only black screen instead of the map. I see that server does send the .png images to the client! But they don't display.
What am I doing wrong?
Thanks!!
PS. I attached the Tiles files for your convenience
tiles.zip
Thank you in advance!!!
Beta Was this translation helpful? Give feedback.
All reactions