From 9da871e3d6146b063f43fa309c622ad1a279d7a6 Mon Sep 17 00:00:00 2001 From: Tangui Morlier Date: Thu, 25 May 2023 18:16:52 +0200 Subject: [PATCH] =?UTF-8?q?Permet=20de=20s=C3=A9lectionner=20des=20parcell?= =?UTF-8?q?es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- carte.html | 67 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 46 insertions(+), 21 deletions(-) diff --git a/carte.html b/carte.html index bdcc4dfd91..1e7ad6ffa7 100644 --- a/carte.html +++ b/carte.html @@ -28,9 +28,16 @@

La carte

-

Les parcelles

-
@@ -138,27 +145,22 @@

Téléchargement

features.sort(function (feature1, feature2) { return feature1.feature.properties['id'] > feature2.feature.properties['id'] }).forEach(function(feature) { properties = feature.feature.properties; parcelle_id = properties["id"]; - parcelle_title = ''; - if (properties['prefixe'] != '000') { - parcelle_title = properties['prefixe']+' '; - } - parcelle_title += properties['section']+' '+properties['numero'] - content = '

'+parcelle_title+'

'; + content = '

'+properties2title(properties)+'

'; content += ''; feature.bindPopup(content); my_features[parcelle_id] = feature; - $('#list_parcelles').append('
  • '+parcelle_title+' : '+contenance+'
  • ') + $('#list_les_parcelles').append(properties2li(properties)); map.addLayer( new L.Marker( feature.getBounds().getCenter(), @@ -167,7 +169,7 @@

    Téléchargement

    icon: L.divIcon( iconOptions = { iconSize : [15, 15], className : 'parcellelabel', - html: '' + parcelle_title + '' + html: '' + properties2title(properties) + '' }) } ) @@ -178,7 +180,8 @@

    Téléchargement

    console.log(window.location.hash); if (window.location.hash) { - openParcelle(window.location.hash.substring(1)); + parcelles = window.location.hash.substring(1).split(',').filter((item, i, ar) => ar.indexOf(item) === i);; + selectParcelles(parcelles); } map.on('zoomend', function() { if (map.getZoom() > 16){ @@ -189,20 +192,42 @@

    Téléchargement

    }); } })(); -var current_parcelle = null; +var current_parcelles = []; +function selectParcelles(uid_parcelles) { + current_parcelles.forEach(function(cuid) { + if (my_features[cuid]) { + my_features[cuid].setStyle({'color': 'black', 'weight': '1'});//, 'stroke-opacity': '0.75', 'stroke-width': '1'}); + } + }); + current_parcelles = parcelles; + current_parcelles.forEach(function(cuid) { + if (my_features[cuid]) { + my_features[cuid].setStyle({'color': 'red', 'fillColor': 'black', 'weight': '2'});//, 'stroke-opacity': '1', 'stroke-width': '2'}); + $('#list_vos_parcelles').append(properties2li(my_features[cuid].feature.properties)); + } + }); + $('#vos_parcelles').show(); +} function openParcelle(uid) { if (!uid || !my_features[uid]) { return; } map.fitBounds(my_features[uid].getBounds()); - if (current_parcelle) { - current_parcelle.setStyle({'color': 'black', 'weight': '1'});//, 'stroke-opacity': '0.75', 'stroke-width': '1'}); - } - current_parcelle = my_features[uid]; - current_parcelle.setStyle({'color': 'red', 'fillColor': 'black', 'weight': '2'});//, 'stroke-opacity': '1', 'stroke-width': '2'}); my_features[uid].openPopup(); return false; } +function properties2title(properties) { + var parcelle_title = ''; + if (properties['prefixe'] != '000') { + parcelle_title = properties['prefixe']+' '; + } + parcelle_title += properties['section']+' '+properties['numero']; + return parcelle_title; + +} +function properties2li(properties) { + return '
  • '+properties2title(properties)+' : '+properties['contenance']+'
  • '; +}