Skip to content

Tooltip and Popup don't work in GeoJson with MultiPoint geometryΒ #1520

Open
@martinfleis

Description

@martinfleis

Describe the bug
If you have MultiPoint geometry in your GeoJSON, Tooltip and Popup do not work. Normal Points are fine as well as MultiPolygons.

To Reproduce

import json
import folium

geojson = '{"type": "FeatureCollection", "features": [{"id": "0", "type": "Feature", "properties": {"foo": 0}, "geometry": {"type": "MultiPoint", "coordinates": [[0.0, 0.0]]}}, {"id": "1", "type": "Feature", "properties": {"foo": 1}, "geometry": {"type": "MultiPoint", "coordinates": [[1.0, 1.0]]}}, {"id": "2", "type": "Feature", "properties": {"foo": 2}, "geometry": {"type": "MultiPoint", "coordinates": [[2.0, 2.0]]}}, {"id": "3", "type": "Feature", "properties": {"foo": 3}, "geometry": {"type": "MultiPoint", "coordinates": [[3.0, 3.0]]}}, {"id": "4", "type": "Feature", "properties": {"foo": 4}, "geometry": {"type": "MultiPoint", "coordinates": [[4.0, 4.0]]}}]}'

geojson = json.loads(geojson)

m = folium.Map()
folium.GeoJson(
    geojson,
    tooltip=folium.GeoJsonTooltip(["foo"]),
    popup=folium.GeoJsonTooltip(["foo"]),
    marker=folium.CircleMarker(radius=20)
).add_to(m)
m

Expected behavior
Both tooltip and popup should normally work as with any other geometry type.

Environment (please complete the following information):

  • Browser [e.g. chrome, firefox]: Safari
  • Jupyter Notebook or html files? Jupyter
  • Python version (check it with import sys; print(sys.version_info)): 3.9.6
  • folium version (check it with import folium; print(folium.__version__)): master
  • branca version (check it with import branca; print(branca.__version__)): master

Additional context
xref geopandas/geopandas#2190

Possible solutions
You can explode MultiPoints to Points but that is not a viable solution as it breaks the geometry into pieces.

I can have a look at the fix unless it requires a lot of JavaScript :).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn issue describing unexpected or malicious behaviour

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions