eodaGmbH / py-maplibregl

Python bindings for MapLibre GL JS
https://eodagmbh.github.io/py-maplibregl/
MIT License
27 stars 2 forks source link

Map.add_popup method not working #63

Closed giswqs closed 1 week ago

giswqs commented 2 weeks ago

The MapLibre JS does not seem to have the addPopup method. Ideally, the add_popup() method should accept lon/lat coordinates and HTML string to be displayed on the popup, similar to the JS functionality.

self.add_call("addPopup", layer_id, prop, template)

https://maplibre.org/maplibre-gl-js/docs/examples/popup/

image

crazycapivara commented 2 weeks ago

I do not know what's the usecase for this, but I can add it if needed as Map.add_popup2 :-)

giswqs commented 1 week ago

It works now with this. Not sure why it didn't work earlier.

url = "https://github.com/opengeos/datasets/releases/download/world/world_cities.geojson"
geojson = requests.get(url).json()
source = {
    "type": "geojson",
    "data": geojson
}

layer = {
    "id": "cities",
    "type": "symbol",
    "source": "point",
    "layout": {
        "icon-image": "marker_15",
        "icon-size": 1,
    },
}
m.add_source("point", source)
m.add_layer(layer)
m.add_popup("cities")

image