File tree Expand file tree Collapse file tree 1 file changed +7
-13
lines changed Expand file tree Collapse file tree 1 file changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ class GeoMan(JSCSSMixin, MacroElement):
3434 {{ this._parent.get_name() }}
3535 );
3636 {%- endif %}
37+
3738 /* The global variable below is needed to prevent streamlit-folium
3839 from barfing :-(
3940 */
@@ -42,6 +43,7 @@ class GeoMan(JSCSSMixin, MacroElement):
4243 {{this.get_name()}}.addControls(
4344 {{this.options|tojavascript}}
4445 )
46+
4547 drawnItems_{{ this.get_name() }}.eachLayer(function(layer){
4648 L.PM.reInitLayer(layer);
4749 {%- for event, handler in this.on.items() %}
@@ -52,7 +54,7 @@ class GeoMan(JSCSSMixin, MacroElement):
5254 {%- endfor %}
5355 });
5456
55- {{ this._parent. get_name() }}.on("pm:create", function(e) {
57+ var new_element_handler_ {{ this.get_name() }} = function(e) {
5658 var layer = e.layer,
5759 type = e.layerType;
5860
@@ -62,19 +64,11 @@ class GeoMan(JSCSSMixin, MacroElement):
6264 {{handler}}
6365 );
6466 {%- endfor %}
65- });
67+ drawnItems_{{ this.get_name() }}.addLayer(layer);
68+ };
6669
67- {{ this._parent.get_name() }}.on("pm:cut", function(e) {
68- var layer = e.layer,
69- type = e.layerType;
70-
71- {%- for event, handler in this.on.items() %}
72- layer.on(
73- "{{event}}",
74- {{handler}}
75- );
76- {%- endfor %}
77- });
70+ {{ this._parent.get_name() }}.on("pm:create", new_element_handler_{{ this.get_name() }});
71+ {{ this._parent.get_name() }}.on("pm:cut", new_element_handler_{{ this.get_name() }});
7872
7973 {% endmacro %}
8074 """
You can’t perform that action at this time.
0 commit comments