aletrn commited on
Commit
11a84fd
·
1 Parent(s): 6abf74d

[feat] add support for hiding old polygons from ML inferences

Browse files
static/src/components/PagePredictionMap.vue CHANGED
@@ -105,7 +105,8 @@ import {
105
  Map as LMap,
106
  map as LeafletMap,
107
  tileLayer,
108
- TileLayer as LTileLayer
 
109
  } from 'leaflet'
110
  import 'leaflet-providers'
111
  import '@geoman-io/leaflet-geoman-free'
@@ -160,6 +161,7 @@ const currentZoomRef = ref()
160
  const promptsArrayRef: Ref<Array<IPointPrompt | IRectanglePrompt>> = ref([])
161
  const mapNavigationLocked = ref(false)
162
  const mapOptionsDefaultRef = ref()
 
163
  let map: LMap
164
  type ServiceTiles = {
165
  [key: SourceTileType]: LTileLayer;
@@ -186,7 +188,9 @@ const getPopupContentPoint = (leafletEvent: LEvented, label: number): HTMLDivEle
186
  return popupDiv
187
  }
188
 
189
- const sendMLRequest = async (leafletMap: LMap, promptRequest: Array<IPointPrompt | IRectanglePrompt>, sourceType: SourceTileType = OpenStreetMap) => {
 
 
190
  if (map.pm.globalDragModeEnabled()) {
191
  map.pm.disableGlobalDragMode()
192
  }
@@ -203,6 +207,10 @@ const sendMLRequest = async (leafletMap: LMap, promptRequest: Array<IPointPrompt
203
  try {
204
  const geojsonOutputOnMounted = await getGeoJSONRequest(bodyRequest, '/infer_samgis')
205
  const featureNew = LeafletGeoJSON(geojsonOutputOnMounted)
 
 
 
 
206
  leafletMap.addLayer(featureNew)
207
  } catch (errGeojsonOutputOnMounted) {
208
  console.error('sendMLRequest:: sourceType: ', sourceType)
@@ -253,8 +261,7 @@ onMounted(async () => {
253
  map.fitBounds(props.mapBounds)
254
  map.attributionControl.setPrefix(prefix)
255
  LeafletControl.scale({ position: 'bottomleft', imperial: false, metric: true }).addTo(map)
256
-
257
- LeafletControl.layers(baseMaps).addTo(map)
258
  setGeomanControls(map)
259
  updateZoomBboxMap(map)
260
  mapOptionsDefaultRef.value = {...map.options}
 
105
  Map as LMap,
106
  map as LeafletMap,
107
  tileLayer,
108
+ TileLayer as LTileLayer,
109
+ FeatureGroup
110
  } from 'leaflet'
111
  import 'leaflet-providers'
112
  import '@geoman-io/leaflet-geoman-free'
 
161
  const promptsArrayRef: Ref<Array<IPointPrompt | IRectanglePrompt>> = ref([])
162
  const mapNavigationLocked = ref(false)
163
  const mapOptionsDefaultRef = ref()
164
+ const layerControlGroupLayersRef = ref(LeafletControl.layers());
165
  let map: LMap
166
  type ServiceTiles = {
167
  [key: SourceTileType]: LTileLayer;
 
188
  return popupDiv
189
  }
190
 
191
+ const sendMLRequest = async (
192
+ leafletMap: LMap, promptRequest: Array<IPointPrompt | IRectanglePrompt>, sourceType: SourceTileType = OpenStreetMap
193
+ ) => {
194
  if (map.pm.globalDragModeEnabled()) {
195
  map.pm.disableGlobalDragMode()
196
  }
 
207
  try {
208
  const geojsonOutputOnMounted = await getGeoJSONRequest(bodyRequest, '/infer_samgis')
209
  const featureNew = LeafletGeoJSON(geojsonOutputOnMounted)
210
+ let now = new Date(Date.now())
211
+ let nowString = now.toLocaleString('it-it', )
212
+ let overlayMaps = new FeatureGroup([featureNew])
213
+ layerControlGroupLayersRef.value.addOverlay(overlayMaps, nowString)
214
  leafletMap.addLayer(featureNew)
215
  } catch (errGeojsonOutputOnMounted) {
216
  console.error('sendMLRequest:: sourceType: ', sourceType)
 
261
  map.fitBounds(props.mapBounds)
262
  map.attributionControl.setPrefix(prefix)
263
  LeafletControl.scale({ position: 'bottomleft', imperial: false, metric: true }).addTo(map)
264
+ layerControlGroupLayersRef.value = LeafletControl.layers(baseMaps).addTo(map)
 
265
  setGeomanControls(map)
266
  updateZoomBboxMap(map)
267
  mapOptionsDefaultRef.value = {...map.options}