Skip to content

Commit

Permalink
Make prop optional
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan Kuethe committed Jan 24, 2024
1 parent de99f37 commit b78a266
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
5 changes: 3 additions & 2 deletions docs/examples/geopandas/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
def create_map():
m = Map(map_options)
m.add_layer(wilderness_layer)
# m.add_tooltip(LAYER_ID, "NAME")
m.add_tooltip(LAYER_ID, None)
m.add_tooltip(LAYER_ID, "NAME")
# m.add_tooltip(LAYER_ID)
# m.add_popup(LAYER_ID, "NAME")
return m


Expand Down
8 changes: 4 additions & 4 deletions maplibre/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,21 +158,21 @@ def add_marker(self, marker: Marker) -> None:
"""
self.add_call("addMarker", marker.to_dict())

def add_popup(self, layer_id: str, prop: str) -> None:
def add_popup(self, layer_id: str, prop: str = None) -> None:
"""Add a popup to the map
Args:
layer_id (str): The layer to which the popup is added.
prop (str): The property of the source to be displayed.
prop (str): The property of the source to be displayed. If `None`, all properties will be displayed.
"""
self.add_call("addPopup", layer_id, prop)

def add_tooltip(self, layer_id: str, prop: str) -> None:
def add_tooltip(self, layer_id: str, prop: str = None) -> None:
"""Add a tooltip to the map
Args:
layer_id (str): The layer to which the tooltip is added.
prop (str): The property of the source to be displayed.
prop (str): The property of the source to be displayed. If `None`, all properties will be displayed.
"""
self.add_call("addTooltip", layer_id, prop)

Expand Down
2 changes: 1 addition & 1 deletion maplibre/srcjs/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion srcjs/pymaplibregl.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ export default class PyMapLibreGL {
const popup = new maplibregl.Popup(popupOptions);
this._map.on("click", layerId, (e) => {
const feature = e.features[0];
const text = feature.properties[property];
// const text = feature.properties[property];
const text = getTextFromFeature(feature, property);
popup.setLngLat(e.lngLat).setHTML(text).addTo(this._map);
});
}
Expand Down

0 comments on commit b78a266

Please sign in to comment.