Replies: 2 comments
-
Hi All, Minimal code: import leafmap
import numpy as np
import pandas as pd
import plotly.express as px
import solara
center_default = (53.2305799, 6.5323552)
zoom_default = 5
df=pd.DataFrame(data={'class': [1, 2,3,25], 'name':['A1','A2','A3','A4'],'Time': [10, 20,30,40],'lat':[40.741895,40.73098527339601,40.66905379201422,-0.22470045920182688],'lon':[-73.989308,-74.12560713330078,-74.1163374189453,114.96660935839847]},dtype=np.int8)
df
zoom = solara.reactive(zoom_default)
#center = solara.reactive(center_default)
marker_location = solara.reactive(center_default)
#map_name = solara.reactive(list(maps)[0])
@solara.component
def Page():
solara.Title("Test")
with solara.Column():
filter, _set_filter = solara.use_cross_filter(id(df))
with solara.Sidebar():
solara.Markdown("## Test")
solara.Markdown(f"Market set to: {marker_location.value}", style={"color": "#6e6e6e"})
def location_changed(location):
# do things with the location
marker_location.set(location)
def goto_marker():
center.value = marker_location.value
zoom.value = 13
def reset_view():
center.value = center_default
zoom.value = zoom_default
solara.SliderInt(label="Zoom level", value=zoom, min=1, max=16)
with solara.Row():
solara.Button(label="Zoom to marker", on_click=goto_marker)
solara.Button(label="Reset view", on_click=reset_view)
with solara.Card("Test Filter"):
with solara.Columns([2, 2]):
filter, _set_filter = solara.use_cross_filter(id(df))
solara.CrossFilterSelect(df, "class")
solara.CrossFilterSelect(df, "name")
solara.CrossFilterSlider(df, "Time", mode=">=")
dff = df.loc[filter] if filter is not None else df
with solara.Columns([2, 2]):
class Map(leafmap.Map):
def __init__(self, **kwargs):
super().__init__(**kwargs)
self.add_points_from_xy(
dff,
x="lon",
y="lat",
spin=True,
add_legend=True,
)
solara.CrossFilterDataFrame(dff)
solara.FigurePlotly(px.histogram(dff, "Time"))
with solara.Card("map"):
with solara.Columns([1, 2],style={"min-width": "500px", "height": "500px"}):
solara.Markdown("map")
Map.element( # type: ignore
#zoom=zoom.value,
#on_zoom=zoom.set,
#center=center.value,
# on_center=center.set,
scroll_wheel_zoom=True,
#crs=my_projection,
toolbar_control=False,
#layers=[
)
@solara.component
def Layout(children):
route, routes = solara.use_route()
return solara.AppLayout(children=children) Select or filter first data work normal but when select the rest data for example clas 2, 3 or 25 from the sample data) filter on map will not work and trigger error like this: If anyone have suggestion for that issue, kindly please give some advise or hint. thanks |
Beta Was this translation helpful? Give feedback.
-
Hi, thanks you for opening this. Please make sure next time to have your code properly formatted, and ready to copy paste. I needed to guess the import and default values for center_default and zoom_default myself. Regards, Maarten |
Beta Was this translation helpful? Give feedback.
-
Dear All,
I have submit the same issue in the leafmap github:
opengeos/leafmap#580
Probably this is related with the issue in solara instead of in leafmap.
If anyone have suggestion for that issue, kindly please give some advise or hint.
thanks
Beta Was this translation helpful? Give feedback.
All reactions