Streamlit app for searching and loading basemaps

This app is a demonstration of searching and loading basemaps from xyzservices and Quick Map Services (QMS). Selecting from 1000+ basemaps with a few clicks.


Such a great app , thank you for sharing . :balloon:


1 Like

great app for reference. Thanks Mr. Wu

Hi, I found when I tried to import kml file, asia area kml file is not supported to show on the map but America and Africa area kml files are able to show.
In addition, how to set the middle coordinate to let map window range can move to the kml area.
Can you figured out why and how to solve these problem, thank you.
Here is code I copied from your app

import os
import geopandas as gpd
import streamlit as st
import leafmap.foliumap as leafmap
data = st.file_uploader("Upload a vector dataset", type=["geojson", "kml", "zip"])

def save_uploaded_file(file_content, file_name):
    Save the uploaded file to a temporary directory
    import tempfile
    import os
    import uuid

    _, file_extension = os.path.splitext(file_name)
    file_id = str(uuid.uuid4())
    file_path = os.path.join(tempfile.gettempdir(), f"{file_id}{file_extension}")

    with open(file_path, "wb") as file:

    return file_path

if data is not None:

    width = 800
    height = 600

    file_path = save_uploaded_file(data,
    layer_name = os.path.splitext([0]
    m = leafmap.Map(draw_export=True)
    m.add_vector(file_path, layer_name=layer_name)
    m.to_streamlit(width, height)[正在处理:africa.kml…]()

I used the polygon draw function to generate kml file in google earth.

I have updated the app. The map can now zoom to the center of the uploaded datasets automatically. KML files of Asian regions work fine on my end.

thank you so much, now we can see the kml in asia area.
Have you try to read and add mapinfo file format like TAB to the online map?
And if we draw a new polygon, can we export it as a kml file and open it in google earth?

GeoPanas should be able to read MapInfo Tab file. I have added “Tab” format to the upload app. Try it out. To draw and export polygons, you need to use the folium plotting backend. See this demo.