Vertdure commited on
Commit
f780d89
·
verified ·
1 Parent(s): 8777235

Update pages/HelvetiMap.py

Browse files
Files changed (1) hide show
  1. pages/HelvetiMap.py +22 -54
pages/HelvetiMap.py CHANGED
@@ -25,19 +25,18 @@ class PrintFormatControl(MacroElement):
25
  var printFormatControl = L.control({position: 'topright'});
26
  printFormatControl.onAdd = function (map) {
27
  var div = L.DomUtil.create('div', 'print-format-control');
28
- div.innerHTML = `
29
- <label for="format-select">Format:</label>
30
- <select id="paper-format" name="format-select">
31
- <option value="A4">A4</option>
32
- <option value="A3">A3</option>
33
- <option value="A2">A2</option>
34
- <option value="A1">A1</option>
35
- <option value="A0">A0</option>
36
- </select>
37
- <label for="scale-input">Échelle:</label>
38
- <input id="scale-input" type="number" value="1000" min="1" step="100">
39
- <button id="apply-format">Appliquer</button>
40
- `;
41
  L.DomEvent.disableClickPropagation(div);
42
  return div;
43
  };
@@ -76,7 +75,7 @@ class PrintFormatControl(MacroElement):
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) {
@@ -100,7 +99,7 @@ def main():
100
  st.title("SwissScape - Générateur de fonds de plans pour Paysagistes")
101
 
102
  st.markdown("""
103
- Utilisez la carte interactive pour définir votre zone d'intérêt, choisissez votre format papier et votre échelle,
104
  puis exportez facilement votre fond de plan.
105
  """)
106
 
@@ -117,50 +116,19 @@ def main():
117
  # Ajouter les contrôles de format et d'échelle
118
  m.add_child(PrintFormatControl())
119
 
 
 
 
 
 
 
 
120
  # Créer un groupe pour les objets dessinés
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)
161
-
162
  # Afficher la carte
163
  folium_static(m, width=800, height=600)
164
 
165
  if __name__ == "__main__":
166
- main()
 
25
  var printFormatControl = L.control({position: 'topright'});
26
  printFormatControl.onAdd = function (map) {
27
  var div = L.DomUtil.create('div', 'print-format-control');
28
+ div.innerHTML =
29
+ '<label for="format-select">Format:</label>' +
30
+ '<select id="paper-format" name="format-select">' +
31
+ '<option value="A4">A4</option>' +
32
+ '<option value="A3">A3</option>' +
33
+ '<option value="A2">A2</option>' +
34
+ '<option value="A1">A1</option>' +
35
+ '<option value="A0">A0</option>' +
36
+ '</select>' +
37
+ '<label for="scale-input">Échelle:</label>' +
38
+ '<input id="scale-input" type="number" value="1000" min="1" step="100">' +
39
+ '<button id="apply-format">Appliquer</button>';
 
40
  L.DomEvent.disableClickPropagation(div);
41
  return div;
42
  };
 
75
  color: "#ff7800",
76
  weight: 1,
77
  draggable: true
78
+ }).addTo({{ this._parent.get_name() }});
79
 
80
  // Attacher un événement de clic pour afficher le GeoJSON
81
  window.rectangleLayer.on('click', function(e) {
 
99
  st.title("SwissScape - Générateur de fonds de plans pour Paysagistes")
100
 
101
  st.markdown("""
102
+ Utilisez la carte interactive pour définir votre zone d'intérêt, choisissez votre format papier et votre échelle,
103
  puis exportez facilement votre fond de plan.
104
  """)
105
 
 
116
  # Ajouter les contrôles de format et d'échelle
117
  m.add_child(PrintFormatControl())
118
 
119
+ # Activer le plein écran et les contrôles sur la carte
120
+ Fullscreen().add_to(m)
121
+
122
+ # Ajouter le plugin Draw pour dessiner des formes sur la carte
123
+ draw = Draw(export=True)
124
+ draw.add_to(m)
125
+
126
  # Créer un groupe pour les objets dessinés
127
  drawn_items = folium.FeatureGroup(name="Dessins")
128
  m.add_child(drawn_items)
129
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  # Afficher la carte
131
  folium_static(m, width=800, height=600)
132
 
133
  if __name__ == "__main__":
134
+ main()