Skip to content

Popup works with Polyline but not GeoData line #910

Open
@afonit

Description

@afonit

I searched in the issues - it seems like there are several which mention geojson not working but not the combination I mentioned above.

Is it expected that the popup would not work on a line drawn from GeoData?

Here is the example:

from ipyleaflet import Map, Polyline, CircleMarker, GeoData
from shapely.geometry import LineString
import pandas as pd
import geopandas
import ipywidgets as widgets
import numpy as np

m = Map(center = (42.5, -41), zoom =2)

polyline_data = [
        [45.51, -122.68],
        [37.77, -122.43],
        [34.04, -118.22]
    ]
geodata_data =   [
         [1, 35.51, -122.68],
         [1, 27.77, -122.43],
         [1, 24.04, -118.22]
     ]

line = Polyline(
        locations=polyline_data,
        color="green" ,
        fill=False
    )
    
line.popup = widgets.HTML(value=f"""Truck: a, green""")
m.add_layer(line)

df = pd.DataFrame(geodata_data, columns=['seq', 'latitude', 'longitude'])
gdf = geopandas.GeoDataFrame(
    df, geometry=geopandas.points_from_xy(df.longitude, df.latitude))
geo_string = df.groupby('seq')['geometry'].apply(lambda x: LineString(x.tolist()))
geo_base = geopandas.GeoDataFrame(geo_string)
geo_done = GeoData(
                geo_dataframe=geo_base,
                style={'color': 'red'},
                fill=False
            )
geo_done.popup = widgets.HTML(value=f"""Truck: b, red""")
m.add_layer(geo_done)
m

When the PolyLine is clicked on (it is in green), the popup shows up:
image

When the GeoData line is clicked on, no popup shows up:
image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions