conic
conic
SSolara
Created by conic on 2/19/2024 in #questions-issues
Help: Auth Redirect to a new page
I like this answer as it doesn't require knowledge of vue and is fully python. I'll give it a try. Thanks for your help.
11 replies
SSolara
Created by conic on 2/16/2024 in #questions-issues
Help: Drawing a rectangle on an ipyleaflet map
thank you for your help by the way, I don't think I'd have gotten this far. Now I just need to find an on_delete. but that should be simpler now that I kind of understand how to persist state to a reactive variable.
59 replies
SSolara
Created by conic on 2/16/2024 in #questions-issues
Help: Drawing a rectangle on an ipyleaflet map
yeah that's what I do on the callback essentially
59 replies
SSolara
Created by conic on 2/16/2024 in #questions-issues
Help: Drawing a rectangle on an ipyleaflet map
data_reactive = solara.reactive([])

@solara.component
def Map():
def on_draw_rectangle(*args, **kwargs):
data_reactive.value.append(kwargs["geo_json"]["geometry"])

test = List().tag(sync=True)

for x in data_reactive.value:
print(x)

draw_control = DrawControl(data = data_reactive.value)
draw_control.polyline = {}
draw_control.polygon = {}
draw_control.circle = {}
draw_control.rectangle = {
"shapeOptions": {
"fillColor": "#fca45d",
"color": "#fca45d",
"fillOpacity": 0.4,
}
}
draw_control.on_draw(on_draw_rectangle)


ipyleaflet.Map.element( # type: ignore
zoom=zoom_level.value,
on_zoom=zoom_level.set,
center=center.value,
on_center=center.set,
scroll_wheel_zoom=True,
controls=[draw_control,
ipyleaflet.FullScreenControl(),
ipyleaflet.ZoomControl()],
)

@solara.component
def Page():
Map()
data_reactive = solara.reactive([])

@solara.component
def Map():
def on_draw_rectangle(*args, **kwargs):
data_reactive.value.append(kwargs["geo_json"]["geometry"])

test = List().tag(sync=True)

for x in data_reactive.value:
print(x)

draw_control = DrawControl(data = data_reactive.value)
draw_control.polyline = {}
draw_control.polygon = {}
draw_control.circle = {}
draw_control.rectangle = {
"shapeOptions": {
"fillColor": "#fca45d",
"color": "#fca45d",
"fillOpacity": 0.4,
}
}
draw_control.on_draw(on_draw_rectangle)


ipyleaflet.Map.element( # type: ignore
zoom=zoom_level.value,
on_zoom=zoom_level.set,
center=center.value,
on_center=center.set,
scroll_wheel_zoom=True,
controls=[draw_control,
ipyleaflet.FullScreenControl(),
ipyleaflet.ZoomControl()],
)

@solara.component
def Page():
Map()
59 replies
SSolara
Created by conic on 2/16/2024 in #questions-issues
Help: Drawing a rectangle on an ipyleaflet map
there is a drawControl buffer (objects that were drawn), those are always wiped when you update the map. as long as you update the reactive element with your new drawing using on_draw , what you've drawn will be erased.
59 replies
SSolara
Created by conic on 2/16/2024 in #questions-issues
Help: Drawing a rectangle on an ipyleaflet map
here are the caveats
59 replies
SSolara
Created by conic on 2/16/2024 in #questions-issues
Help: Drawing a rectangle on an ipyleaflet map
@Iisakki Rotko that works!
59 replies
SSolara
Created by conic on 2/16/2024 in #questions-issues
Help: Drawing a rectangle on an ipyleaflet map
Giving this a try
59 replies
SSolara
Created by conic on 2/16/2024 in #questions-issues
Help: Drawing a rectangle on an ipyleaflet map
I see, so .value is a mutable reference that the reactive element would still track?
59 replies
SSolara
Created by conic on 2/16/2024 in #questions-issues
Help: Drawing a rectangle on an ipyleaflet map
The error
traitlets.traitlets.TraitError: The 'data' trait of a DrawControl instance expected a list, not the Reactive <Reactive value=[{'type': 'Polygon', 'coordinates': [[[-126.914063, 17.644022], [-126.914063, 65.219894], [-8.085938, 65.219894], [-8.085938, 17.644022], [-126.914063, 17.644022]]]}, {'type': 'Polygon', 'coordinates': [[[-126.210938, -7.710992], [-126.210938, 57.891497], [49.570313, 57.891497], [49.570313, -7.710992], [-126.210938, -7.710992]]]}, {'type': 'Polygon', 'coordinates': [[[-138.164063, 8.407168], [-138.164063, 57.136239], [-56.601563, 57.136239], [-56.601563, 8.407168], [-138.164063, 8.407168]]]}, {'type': 'Polygon', 'coordinates': [[[70.664063, 38.822591], [70.664063, 59.175928], [109.335938, 59.175928], [109.335938, 38.822591], [70.664063, 38.822591]]]}, {'type': 'Polygon', 'coordinates': [[[-112.851563, 15.284185], [-112.851563, 63.391522], [2.8125, 63.391522], [2.8125, 15.284185], [-112.851563, 15.284185]]]}, {'type': 'Polygon', 'coordinates': [[[-134.296875, -4.565474], [-134.296875, 60.239811], [-11.601563, 60.239811], [-11.601563, -4.565474], [-134.296875, -4.565474]]]}] id=0x13c1174d0>.
traitlets.traitlets.TraitError: The 'data' trait of a DrawControl instance expected a list, not the Reactive <Reactive value=[{'type': 'Polygon', 'coordinates': [[[-126.914063, 17.644022], [-126.914063, 65.219894], [-8.085938, 65.219894], [-8.085938, 17.644022], [-126.914063, 17.644022]]]}, {'type': 'Polygon', 'coordinates': [[[-126.210938, -7.710992], [-126.210938, 57.891497], [49.570313, 57.891497], [49.570313, -7.710992], [-126.210938, -7.710992]]]}, {'type': 'Polygon', 'coordinates': [[[-138.164063, 8.407168], [-138.164063, 57.136239], [-56.601563, 57.136239], [-56.601563, 8.407168], [-138.164063, 8.407168]]]}, {'type': 'Polygon', 'coordinates': [[[70.664063, 38.822591], [70.664063, 59.175928], [109.335938, 59.175928], [109.335938, 38.822591], [70.664063, 38.822591]]]}, {'type': 'Polygon', 'coordinates': [[[-112.851563, 15.284185], [-112.851563, 63.391522], [2.8125, 63.391522], [2.8125, 15.284185], [-112.851563, 15.284185]]]}, {'type': 'Polygon', 'coordinates': [[[-134.296875, -4.565474], [-134.296875, 60.239811], [-11.601563, 60.239811], [-11.601563, -4.565474], [-134.296875, -4.565474]]]}] id=0x13c1174d0>.
59 replies
SSolara
Created by conic on 2/16/2024 in #questions-issues
Help: Drawing a rectangle on an ipyleaflet map
I've tried this but it throws errors. I know that data IS a field, but Im not sure how to instantiate the solara reactive for it.
What I've tried:
data_reactive = solara.reactive([])
data_reactive = solara.reactive([])
data_reactive = solara.reactive({})
data_reactive = solara.reactive({})
59 replies
SSolara
Created by conic on 2/16/2024 in #questions-issues
Help: Drawing a rectangle on an ipyleaflet map
I tried binding it, it did not work. I need to look more into what the binding would look liked (expressed in code). The solara documentation is pretty sparse which makes me believe that there's another library or paradigm at play that's obvious to seasoned users, but hidden from me.
59 replies
SSolara
Created by conic on 2/16/2024 in #questions-issues
Help: Drawing a rectangle on an ipyleaflet map
perhaps it rerenders the map each time or resets the data attribute you mentioned. binding a reactive variable to the data attribute might solve both of these, giving it a try
59 replies
SSolara
Created by conic on 2/16/2024 in #questions-issues
Help: Drawing a rectangle on an ipyleaflet map
I'll give this a try, thanks
59 replies
SSolara
Created by conic on 2/19/2024 in #questions-issues
Help: Auth Redirect to a new page
if I specify a window redirect in a vue component, would it only do it for the component? Or can it redirect the page for the entire application?
11 replies
SSolara
Created by conic on 2/19/2024 in #questions-issues
Help: Auth Redirect to a new page
taking a look
11 replies
SSolara
Created by conic on 2/19/2024 in #questions-issues
Help: Auth Redirect to a new page
Thank you for this. Im uncertain what a component vue is just yet. What would that look like? Would I render a component that runs
window.location.href = 'https://solara.dev';
window.location.href = 'https://solara.dev';
?
11 replies
SSolara
Created by conic on 2/16/2024 in #questions-issues
Help: Drawing a rectangle on an ipyleaflet map
59 replies
SSolara
Created by conic on 2/16/2024 in #questions-issues
Help: Drawing a rectangle on an ipyleaflet map
2) The polygons drawn on the map disappear when I pan or zoom
59 replies