S
Solara5mo ago
Julien

What is ipyleaflet.Map.element() ?

Hi, I hope this is not a silly question, but in the two Solara examples using ipyleaflet, it is called with ipyleaflet.Map.element(...), for example:
ipyleaflet.Map.element( # type: ignore
zoom=zoom.value,
on_zoom=zoom.set,
center=center.value,
on_center=center.set,
scroll_wheel_zoom=True,
layers=[
ipyleaflet.TileLayer.element(url=url),
ipyleaflet.Marker.element(location=marker_location.value, draggable=True, on_location=location_changed),
],
)
ipyleaflet.Map.element( # type: ignore
zoom=zoom.value,
on_zoom=zoom.set,
center=center.value,
on_center=center.set,
scroll_wheel_zoom=True,
layers=[
ipyleaflet.TileLayer.element(url=url),
ipyleaflet.Marker.element(location=marker_location.value, draggable=True, on_location=location_changed),
],
)
But there doesn't seem to be any element attribute to ipyleaflet.Map, and if I try to call it directly in Python I get an error:
>>> ipyleaflet.Map.element()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: type object 'Map' has no attribute 'element'
>>> ipyleaflet.Map.element()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: type object 'Map' has no attribute 'element'
So is this element attribute Solara-related ? Or is there something simpler I don't understand ? Thanks in advance for your help !
2 Replies
Julien
Julien5mo ago
Ok, sorry, replying to myself, but I just saw that element seems to be added by ipyvuetify.VuetifyTemplate.
MaartenBreddels
MaartenBreddels5mo ago
the .element method is added by Reacton, the underlying React implementation in Python that Solara is using. After importing solara (or reacton), the method should be available.