step 8: harden docs and prepare rebuilt beta
This commit is contained in:
@@ -21,17 +21,39 @@ def main() -> None:
|
||||
dpg.create_context()
|
||||
dpg.create_viewport(title="dpg-map cache stress", width=1000, height=700)
|
||||
|
||||
def clear_memory() -> None:
|
||||
dpgm.clear_memory_cache(map_tag="cache-map")
|
||||
|
||||
def clear_disk() -> None:
|
||||
dpgm.clear_disk_cache(map_tag="cache-map")
|
||||
|
||||
def refresh_stats() -> None:
|
||||
stats = dpgm.get_cache_stats(map_tag="cache-map")
|
||||
dpg.set_value(
|
||||
"cache-stats",
|
||||
(
|
||||
f"memory {stats.memory_tiles}/{stats.memory_max_tiles} tiles | "
|
||||
f"disk {stats.disk_bytes // 1024} KiB | "
|
||||
f"hits m:{stats.memory_hits} d:{stats.disk_hits}"
|
||||
),
|
||||
)
|
||||
|
||||
with (
|
||||
dpg.window(label="Cache Stress", width=-1, height=-1),
|
||||
dpgm.map_widget(
|
||||
):
|
||||
with dpg.group(horizontal=True):
|
||||
dpg.add_button(label="Clear Memory", callback=clear_memory)
|
||||
dpg.add_button(label="Clear Disk", callback=clear_disk)
|
||||
dpg.add_button(label="Stats", callback=refresh_stats)
|
||||
dpg.add_text("", tag="cache-stats")
|
||||
with dpgm.map_widget(
|
||||
tag="cache-map",
|
||||
center=(47.9029, 1.9093),
|
||||
zoom=14,
|
||||
width=-1,
|
||||
height=-1,
|
||||
),
|
||||
):
|
||||
dpgm.add_marker("start", lat=47.9029, lon=1.9093, label="Orleans")
|
||||
):
|
||||
dpgm.add_marker("start", lat=47.9029, lon=1.9093, label="Orleans")
|
||||
|
||||
dpg.setup_dearpygui()
|
||||
dpg.show_viewport()
|
||||
|
||||
52
examples/custom_provider.py
Normal file
52
examples/custom_provider.py
Normal file
@@ -0,0 +1,52 @@
|
||||
from typing import Any
|
||||
|
||||
import dearpygui.dearpygui as _dpg
|
||||
|
||||
import dpg_map as dpgm
|
||||
|
||||
dpg: Any = _dpg
|
||||
|
||||
|
||||
def main() -> None:
|
||||
dpgm.configure(user_agent="dpg-map custom_provider example")
|
||||
provider = dpgm.TileProvider(
|
||||
name="carto-light",
|
||||
url_template="https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png",
|
||||
subdomains=("a", "b", "c", "d"),
|
||||
attribution="(c) OpenStreetMap contributors (c) CARTO",
|
||||
file_extension="png",
|
||||
)
|
||||
if "carto-light" not in dpgm.list_providers():
|
||||
dpgm.register_provider(provider)
|
||||
|
||||
dpg.create_context()
|
||||
dpg.create_viewport(title="dpg-map custom provider", width=900, height=600)
|
||||
|
||||
def use_osm() -> None:
|
||||
dpgm.set_provider("osm", map_tag="custom-provider-map")
|
||||
|
||||
def use_carto() -> None:
|
||||
dpgm.set_provider("carto-light", map_tag="custom-provider-map")
|
||||
|
||||
with dpg.window(label="Custom Provider", width=-1, height=-1):
|
||||
with dpg.group(horizontal=True):
|
||||
dpg.add_button(label="OSM", callback=use_osm)
|
||||
dpg.add_button(label="Carto", callback=use_carto)
|
||||
with dpgm.map_widget(
|
||||
tag="custom-provider-map",
|
||||
provider="carto-light",
|
||||
center=(47.9029, 1.9093),
|
||||
zoom=13,
|
||||
width=-1,
|
||||
height=-1,
|
||||
):
|
||||
dpgm.add_marker("orleans", lat=47.9029, lon=1.9093, label="Orleans")
|
||||
|
||||
dpg.setup_dearpygui()
|
||||
dpg.show_viewport()
|
||||
dpg.start_dearpygui()
|
||||
dpg.destroy_context()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user