Closed yishaiSilver closed 5 months ago
@yishaiSilver Can you have a look at the update_feature
parameter? This accepts a javascript (JsCode) function that can be used to update existing layers. Have a look at the function prototype for inspiration here: https://github.com/perliedman/leaflet-realtime/blob/master/src/L.Realtime.js.
You can define something like this:
update_feature = JsCode("""
function (feature, oldLayer) {
var layer = L.Realtime.prototype.options.updateFeature(feature, oldLayer);
var type = feature.geometry && feature.geometry.type
if(type === "Point") {
layer.setRadius(feature.properties.radius);
}
return layer;
}
""")
Yes, that looks like what I was looking for. Thank you so much.
Describe the bug When using Circle in the context of a realtime map, the radius never changes. If using differing IDs, the radius of each additional circle will, in fact, change. But, prior circles will still be on the map (you can see this if you change
'properties': { 'id': 0, })
to'properties': { 'id': id, })
. The position of the circle, however, will be updated without issue.To Reproduce
FastAPI API:
Folium code:
Expected behavior In the same way that the lat and long values cause the circle to change, I expect that the radius also changes.
Environment (please complete the following information):
Possible solutions A rather dirty fix would be to add a new circle each time the map is updated and send the prior circle(s) to the some irrelevant part of the globe (off-camera). I have tested this and it works, but I suspect that this would incur serious performance issues if used for an extended period of time.