Vertdure commited on
Commit
8777235
verified
1 Parent(s): 12b9c09

Update pages/HelvetiMap.py

Browse files
Files changed (1) hide show
  1. pages/HelvetiMap.py +35 -1
pages/HelvetiMap.py CHANGED
@@ -76,7 +76,7 @@ class PrintFormatControl(MacroElement):
76
  color: "#ff7800",
77
  weight: 1,
78
  draggable: true
79
- }).addTo({{ this._parent.get_name() }});
80
 
81
  // Attacher un 茅v茅nement de clic pour afficher le GeoJSON
82
  window.rectangleLayer.on('click', function(e) {
@@ -121,6 +121,40 @@ def main():
121
  drawn_items = folium.FeatureGroup(name="Dessins")
122
  m.add_child(drawn_items)
123
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
124
  # Activer le plein 茅cran et les contr么les sur la carte
125
  Fullscreen().add_to(m)
126
  folium.LayerControl().add_to(m)
 
76
  color: "#ff7800",
77
  weight: 1,
78
  draggable: true
79
+ }).addTo(window.drawnItems);
80
 
81
  // Attacher un 茅v茅nement de clic pour afficher le GeoJSON
82
  window.rectangleLayer.on('click', function(e) {
 
121
  drawn_items = folium.FeatureGroup(name="Dessins")
122
  m.add_child(drawn_items)
123
 
124
+ # Ajouter les outils de dessin Leaflet
125
+ draw_control = Draw(
126
+ draw_options={
127
+ "rectangle": True,
128
+ "polygon": True,
129
+ "polyline": True,
130
+ "circle": True,
131
+ "marker": True
132
+ },
133
+ edit_options={"edit": True, "remove": True},
134
+ )
135
+ m.add_child(draw_control)
136
+
137
+ # Ajouter un bouton d'export GeoJSON
138
+ export_button = """
139
+ <button id="export" class="btn btn-primary" style="position:absolute; top:10px; right:10px; z-index:9999;">Export GeoJSON</button>
140
+ <script>
141
+ document.getElementById("export").onclick = function() {
142
+ var data = window.drawnItems.toGeoJSON();
143
+ var convertedData = 'text/json;charset=utf-8,' + encodeURIComponent(JSON.stringify(data));
144
+ var a = document.createElement('a');
145
+ a.href = 'data:' + convertedData;
146
+ a.download = 'data.geojson';
147
+ a.innerHTML = 'Download GeoJSON';
148
+
149
+ var container = document.getElementById('export');
150
+ container.appendChild(a);
151
+ a.click();
152
+ container.removeChild(a);
153
+ }
154
+ </script>
155
+ """
156
+ m.get_root().html.add_child(folium.Element(export_button))
157
+
158
  # Activer le plein 茅cran et les contr么les sur la carte
159
  Fullscreen().add_to(m)
160
  folium.LayerControl().add_to(m)