eoda-dev / py-maplibregl

Python bindings for MapLibre GL JS
https://eoda-dev.github.io/py-maplibregl/
MIT License
43 stars 5 forks source link

Map.add_popup method not working #63

Closed giswqs closed 5 months ago

giswqs commented 5 months 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 5 months ago

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

giswqs commented 5 months 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