From 35666047e54eae562113c5215b3dcce738fa9b48 Mon Sep 17 00:00:00 2001 From: Stefan Kuethe Date: Fri, 24 May 2024 19:08:11 +0200 Subject: [PATCH] Add example --- docs/examples/layer_order/app.html | 31 ++++++++++++++++++++++++++++++ docs/examples/layer_order/app.py | 19 +++++++++++++++--- docs/examples/layer_order/index.md | 13 +++++++++++++ mkdocs.yml | 1 + 4 files changed, 61 insertions(+), 3 deletions(-) create mode 100644 docs/examples/layer_order/app.html create mode 100644 docs/examples/layer_order/index.md diff --git a/docs/examples/layer_order/app.html b/docs/examples/layer_order/app.html new file mode 100644 index 00000000..9e2d5d26 --- /dev/null +++ b/docs/examples/layer_order/app.html @@ -0,0 +1,31 @@ + + + +Pymaplibregl + + + + +
+ + + \ No newline at end of file diff --git a/docs/examples/layer_order/app.py b/docs/examples/layer_order/app.py index 7d8c7c8a..e5560158 100644 --- a/docs/examples/layer_order/app.py +++ b/docs/examples/layer_order/app.py @@ -1,3 +1,5 @@ +# Shiny Express App + import requests as req from maplibre import Layer, LayerType, Map, MapOptions, render_maplibregl from maplibre.basemaps import Carto, construct_carto_basemap_url @@ -15,21 +17,32 @@ ) m = Map( - MapOptions(style=style, center=(-88.13734351262877, 35.137451890638886), zoom=4) + MapOptions( + style=style, + center=(-89.928, 35.204), + # center=(-88.13734351262877, 35.137451890638886), + zoom=9, + hash=True, + ) ) m.add_layer( Layer( id="urban-areas-fill", type=LayerType.FILL, source=urban_areas, - paint={"fill-color": "#f08", "fill-opacity": 1.0}, + paint={"fill-color": "pink", "fill-opacity": 1.0}, ), before_id=symbol_ids[0], ) for symbol_id in symbol_ids: - m.set_paint_property(symbol_id, "text-color", "darkblue") + m.set_paint_property(symbol_id, "text-color", "purple") @render_maplibregl def render_map(): return m + + +if __name__ == "__main__": + with open("docs/examples/layer_order/app.html", "w") as f: + f.write(m.to_html()) diff --git a/docs/examples/layer_order/index.md b/docs/examples/layer_order/index.md new file mode 100644 index 00000000..ea15168c --- /dev/null +++ b/docs/examples/layer_order/index.md @@ -0,0 +1,13 @@ +Add a data layer below the labels of the basemap. + + + +```python +-8<-- "layer_order/app.py" +``` + +Run example: + +```bash +poetry run shiny run docs/examples/layer_order/app.py +``` diff --git a/mkdocs.yml b/mkdocs.yml index aed1096b..56aeae12 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -33,6 +33,7 @@ nav: - H3 Grid UK Road Safety: examples/road_safety/index.md - Where is the ISS: examples/where_is_the_iss/index.md - WMS: examples/wms/index.md + - Layer Order: examples/layer_order/index.md plugins: - search: