1- from typing import Optional , Union
1+ from typing import Union
22
33from branca .element import MacroElement
44from jinja2 import Template
@@ -27,11 +27,11 @@ class Realtime(JSCSSMixin, MacroElement):
2727 on the map and stopped when layer is removed from the map
2828 interval: int, default 60000
2929 Automatic update interval, in milliseconds
30- get_feature_id: JsCode, optional
30+ get_feature_id: str or JsCode, optional
3131 A JS function with a geojson `feature` as parameter
3232 default returns `feature.properties.id`
3333 Function to get an identifier to uniquely identify a feature over time
34- update_feature: JsCode, optional
34+ update_feature: str or JsCode, optional
3535 A JS function with a geojson `feature` as parameter
3636 Used to update an existing feature's layer;
3737 by default, points (markers) are updated, other layers are discarded
@@ -44,7 +44,8 @@ class Realtime(JSCSSMixin, MacroElement):
4444
4545
4646 Other keyword arguments are passed to the GeoJson layer, so you can pass
47- `style`, `point_to_layer` and/or `on_each_feature`.
47+ `style`, `point_to_layer` and/or `on_each_feature`. Make sure to wrap
48+ Javascript functions in the JsCode class.
4849
4950 Examples
5051 --------
@@ -95,8 +96,8 @@ def __init__(
9596 source : Union [str , dict , JsCode ],
9697 start : bool = True ,
9798 interval : int = 60000 ,
98- get_feature_id : Optional [JsCode ] = None ,
99- update_feature : Optional [JsCode ] = None ,
99+ get_feature_id : Union [JsCode , str , None ] = None ,
100+ update_feature : Union [JsCode , str , None ] = None ,
100101 remove_missing : bool = False ,
101102 ** kwargs
102103 ):
@@ -107,9 +108,9 @@ def __init__(
107108 kwargs ["start" ] = start
108109 kwargs ["interval" ] = interval
109110 if get_feature_id is not None :
110- kwargs ["get_feature_id" ] = get_feature_id
111+ kwargs ["get_feature_id" ] = JsCode ( get_feature_id )
111112 if update_feature is not None :
112- kwargs ["update_feature" ] = update_feature
113+ kwargs ["update_feature" ] = JsCode ( update_feature )
113114 kwargs ["remove_missing" ] = remove_missing
114115
115116 # extract JsCode objects
0 commit comments