Skip to content

Instantly share code, notes, and snippets.

@hansthen
Created January 15, 2025 06:30
Show Gist options
  • Save hansthen/52b6375ebc803b1922af932aa5ef9acc to your computer and use it in GitHub Desktop.
Save hansthen/52b6375ebc803b1922af932aa5ef9acc to your computer and use it in GitHub Desktop.
realtime + fitbounds
realtime = Realtime(source, on_each_feature=on_each_feature, interval=10000).add_to(m)
realtime.on(
update=folium.JsCode(
"""
(e) => {
console.log('update ', e.target._map);
var map = e.target._map;
var realtime = e.target;
map.fitBounds(realtime.getBounds(), {maxZoom: 3});
}
"""
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment