// Init vars var selectedFeature = null; var ignApiKey = "eal2fmz13p39xdne827396vr"; var mapId = "map"; var selectedLayer = L.layerGroup(); // BASE LAYERS var OpenStreetMap = new L.TileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {alias : 'OpenStreetMap', maxZoom: 20, attribution: 'Map data © OpenStreetMap contributors' }) ; var osm_gray = new L.TileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {alias : 'osm_gray', className: 'sysma-leaflet-tile-greyscale', maxZoom: 20, attribution: 'Map data © OpenStreetMap contributors' }) ; var esri_topo = new L.tileLayer.wms("https://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer/tile/{z}/{y}/{x}", {alias : 'esri_topo', attribution: '© ESRI' }) ; var plan_ign_j1 = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=GEOGRAPHICALGRIDSYSTEMS.MAPS.BDUNI.J1&format=image/png&style=normal", {alias : 'plan_ign_j1', maxNativeZoom: 19, maxZoom: 22, attribution: '© IGN' }) ; var scna_25 = new L.TileLayer("https://data.geopf.fr/private/wmts?SERVICE=WMTS&apikey=ign_scan_ws&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=GEOGRAPHICALGRIDSYSTEMS.MAPS.SCAN25TOUR&format=image/jpeg&style=normal", {alias : 'scna_25', maxZoom: 23, attribution: '© IGN' }) ; var oaci = new L.TileLayer("https://data.geopf.fr/private/wmts?SERVICE=WMTS&apikey=ign_scan_ws&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=GEOGRAPHICALGRIDSYSTEMS.MAPS.SCAN-OACI&format=image/jpeg&style=normal", {alias : 'oaci', maxZoom: 23, attribution: '© IGN' }) ; var ortho_pcrs = new L.tileLayer.wms("https://pcrs-proxy.ign.fr/wms?service=WMS&request=GetMap&version=1.3.0&layers=pcrs_wms", {alias : 'ortho_pcrs', format: 'image/png', transparent: true, version: '1.3.0', crs: L.CRS.EPSG4326, attribution: '© IGN - PCRS',maxZoom: 22,maxZoomNative: 22 }) ; var orthophotos_hr = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=HR.ORTHOIMAGERY.ORTHOPHOTOS&format=image/jpeg&style=normal", {alias : 'orthophotos_hr', maxNativeZoom: 19, maxZoom: 22, attribution: '© IGN' }) ; var ortho_express23 = new L.TileLayer("https://data.geopf.fr/wmts?SERVICE=WMTS&VERSION=1.0.0&REQUEST=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=ORTHOIMAGERY.ORTHOPHOTOS.ORTHO-EXPRESS.2023&format=image/jpeg&style=normal", {alias : 'ortho_express23', maxNativeZoom: 19, maxZoom: 22, attribution: '© IGN' }) ; var orthophotos2011_2015 = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=ORTHOIMAGERY.ORTHOPHOTOS2011-2015&format=image/jpeg&style=normal", {alias : 'orthophotos2011_2015', maxNativeZoom: 19, maxZoom: 22, attribution: '© IGN' }) ; var orthophotos2006_2010 = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=ORTHOIMAGERY.ORTHOPHOTOS2006-2010&format=image/jpeg&style=normal", {alias : 'orthophotos2006_2010', maxNativeZoom: 19, maxZoom: 22, attribution: '© IGN' }) ; var orthophotos2000_2005 = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=ORTHOIMAGERY.ORTHOPHOTOS2000-2005&format=image/jpeg&style=normal", {alias : 'orthophotos2000_2005', maxNativeZoom: 19, maxZoom: 22, attribution: '© IGN' }) ; var orthophotos1980_1995 = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=ORTHOIMAGERY.ORTHOPHOTOS.1980-1995&format=image/png&style=BDORTHOHISTORIQUE", {alias : 'orthophotos1980_1995', maxNativeZoom: 19, maxZoom: 22, attribution: '© IGN' }) ; var orthophotos1950_1965 = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=ORTHOIMAGERY.ORTHOPHOTOS.1950-1965&format=image/png&style=normal", {alias : 'orthophotos1950_1965', maxNativeZoom: 17, maxZoom: 22, attribution: '© IGN' }) ; var orthophotosirc = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=ORTHOIMAGERY.ORTHOPHOTOS.IRC&format=image/jpeg&style=normal", {alias : 'orthophotosirc', attribution: '© IGN' }) ; var scan_50_annees_50 = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=GEOGRAPHICALGRIDSYSTEMS.MAPS.SCAN50.1950&format=image/jpeg&style=normal", {alias : 'scan_50_annees_50', maxZoom: 23, attribution: '© IGN' }) ; var carte_etat_major = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=GEOGRAPHICALGRIDSYSTEMS.ETATMAJOR40&format=image/jpeg&style=normal", {alias : 'carte_etat_major', maxZoom: 22, attribution: '© IGN' }) ; var carte_cassini = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=BNF-IGNF_GEOGRAPHICALGRIDSYSTEMS.CASSINI&format=image/png&style=normal", {alias : 'carte_cassini', maxZoom: 22, attribution: '© IGN' }) ; var google_sat = new L.TileLayer("https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}", {alias : 'google_sat', attribution: '© Google' }) ; var noBaseLayer = new L.TileLayer("", {alias : 'noBaseLayer', attribution: '' }) ; // OTHER BASE LAYERS var ortho_transparence = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=ORTHOIMAGERY.ORTHOPHOTOS&format=image/jpeg&style=normal", {alias : 'ortho_transparence', opacity: 0.5, maxNativeZoom: 19, maxZoom: 22, attribution: '© IGN' }) ; var ombrage = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=ELEVATION.ELEVATIONGRIDCOVERAGE.SHADOW&format=image/png&style=estompage_grayscale&transparent=true", {alias : 'ombrage', maxZoom: 23, transparent:true, attribution: '© IGN' }) ; var contour_line = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=ELEVATION.CONTOUR.LINE&format=image/png&style=normal&transparent=true", {alias : 'contour_line', maxNativeZoom: 19, maxZoom: 22, transparent:true, attribution: '© IGN' }) ; var limites_admin = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=LIMITES_ADMINISTRATIVES_EXPRESS.LATEST&format=image/png&style=normal", {alias : 'limites_admin', attribution: '© IGN' }) ; var cadastre = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=CADASTRALPARCELS.PARCELS&format=image/png&STYLE=bdparcellaire", {alias : 'cadastre', maxZoom: 21, attribution: '© IGN' }) ; var decalage_cadastre = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=CADASTRALPARCELS.HEATMAP&format=image/png&STYLE=DECALAGE%20DE%20LA%20REPRESENTATION%20CADASTRALE", {alias : 'decalage_cadastre', maxZoom: 21, attribution: '© IGN' }) ; var brgm_geol = new L.tileLayer.wms("http://geoservices.brgm.fr/geologie?LAYERS=GEOLOGIE&SFORMAT=image/png&CRS=EPSG:4326", {alias : 'brgm_geol', opacity: 0.5, maxNativeZoom: 19, maxZoom: 22, attribution: '© BRGM' }) ; var lidar_hd_mnt = new L.TileLayer("https://data.geopf.fr/wmts?layer=IGNF_LIDAR-HD_MNT_ELEVATION.ELEVATIONGRIDCOVERAGE.SHADOW&style=normal&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png", {alias : 'lidar_hd_mnt', opacity:0.8, maxNativeZoom: 18, maxZoom: 22, attribution: '© IGN' }) ; var lidar_hd_mns = new L.TileLayer("https://data.geopf.fr/wmts?layer=IGNF_LIDAR-HD_MNS_ELEVATION.ELEVATIONGRIDCOVERAGE.SHADOW&style=normal&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png", {alias : 'lidar_hd_mns', opacity:0.8, maxNativeZoom: 18, maxZoom: 22, attribution: '© IGN' }) ; var lidar_hd_mnh = new L.TileLayer("https://data.geopf.fr/wmts?layer=IGNF_LIDAR-HD_MNH_ELEVATION.ELEVATIONGRIDCOVERAGE.SHADOW&style=normal&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&Service=WMTS&Request=GetTile&Version=1.0.0&Format=image/png", {alias : 'lidar_hd_mnh', opacity:0.8, maxNativeZoom: 18, maxZoom: 22, attribution: '© IGN' }) ; var cours_deau_bcae = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=HYDROGRAPHY.BCAE.LATEST&format=image/png&style=normal", {alias : 'cours_deau_bcae', maxNativeZoom: 17, maxZoom: 22, attribution: '© IGN' }) ; var carto_ce_22 = new L.tileLayer.wms("https://ogc.geo-ide.developpement-durable.gouv.fr/wxs?map=/opt/data/carto/geoide-catalogue/1.4/org_37982/4a62f30d-f39e-4137-9330-7a17c73d8f5e.internet.map&crs=EPSG:2154&dpiMode=7&format=image/png&layers=l_inventaire_cours_eau_l_022&styles&tilePixelRatio=0&url=https://ogc.geo-ide.developpement-durable.gouv.fr/wxs?map%3D/opt/data/carto/geoide-catalogue/1.4/org_37982/4a62f30d-f39e-4137-9330-7a17c73d8f5e.internet.map", {alias : 'carto_ce_22', maxNativeZoom: 18, maxZoom: 22, layers:'l_inventaire_cours_eau_l_022', transparent:true, format:'image/png',attribution: 'DDTM22' }) ; var carto_ce_35 = new L.tileLayer.wms("https://ogc.geo-ide.developpement-durable.gouv.fr/wxs?map=/opt/data/carto/geoide-catalogue/1.4/org_38012/cf053ffb-6260-410c-b3a3-fc39a789c225.internet.map&crs=EPSG:2154&dpiMode=7&format=image/png&layers=L_CARTO_COURS_EAU_L_35&styles&tilePixelRatio=0&url=https://ogc.geo-ide.developpement-durable.gouv.fr/wxs?map%3D/opt/data/carto/geoide-catalogue/1.4/org_38012/cf053ffb-6260-410c-b3a3-fc39a789c225.internet.map", {alias : 'carto_ce_35', maxNativeZoom: 18, maxZoom: 22, layers:'L_CARTO_COURS_EAU_L_35', transparent:true, format:'image/png',attribution: 'DDTM35' }) ; var carto_ce_44 = new L.tileLayer.wms("https://ogc.geo-ide.developpement-durable.gouv.fr/wxs?map=/opt/data/carto/geoide-catalogue/1.4/org_38030/088da091-e1c2-4368-886b-d407f9eef695.internet.map&crs=CRS:84&dpiMode=7&format=image/png&styles&url=https://ogc.geo-ide.developpement-durable.gouv.fr/wxs?map%3D/opt/data/carto/geoide-catalogue/1.4/org_38030/088da091-e1c2-4368-886b-d407f9eef695.internet.map", {alias : 'carto_ce_44', maxNativeZoom: 18, maxZoom: 22, layers:'N_COURS_EAU_LOIEAU_L_044', transparent:true, format:'image/png',attribution: 'DDTM44' }) ; var carto_ce_49 = new L.tileLayer.wms("https://carto2.geo-ide.din.developpement-durable.gouv.fr/rest-api/ows/c9ebc9c1-a890-4603-b478-964c3f5433be/L_COURDO_REF_2021_L_049", {alias : 'carto_ce_49', maxNativeZoom: 18, maxZoom: 22, layers:'L_COURDO_REF_2021_L_049', transparent:true, format:'image/png',attribution: 'DDTM49' }) ; var carto_ce_53 = new L.tileLayer.wms("https://ogc.geo-ide.developpement-durable.gouv.fr/wxs?map=/opt/data/stack/mapfiles/1.4/org_38048/03a8d46b-e378-438e-8d6a-4dfa56e7f27e.internet.map&SERVICE=WMS&REQUEST=GetCapabilities", {alias : 'carto_ce_53', maxNativeZoom: 18, maxZoom: 22, layers:'l_cours_eau_police_ddt53', transparent:true, format:'image/png',attribution: 'DDTM53' }) ; var carto_ce_56 = new L.tileLayer.wms("https://ogc.geo-ide.developpement-durable.gouv.fr/wxs?map=/opt/data/carto/geoide-catalogue/1.4/org_38054/146c85e6-6d3f-4929-b3a7-6f8f03fd350e.internet.map&crs=EPSG:2154&dpiMode=7&format=image/png&layers=CARTO_CE_COMPLETE_2023&styles&tilePixelRatio=0&url=https://ogc.geo-ide.developpement-durable.gouv.fr/wxs?map%3D/opt/data/carto/geoide-catalogue/1.4/org_38054/146c85e6-6d3f-4929-b3a7-6f8f03fd350e.internet.map", {alias : 'carto_ce_56', maxNativeZoom: 18, maxZoom: 22, layers:'CARTO_CE_COMPLETE_2023', transparent:true, format:'image/png',attribution: 'DDTM56' }) ; var inventaire_natrional_plan_deau = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=INPE&format=image/png&style=INPE", {alias : 'inventaire_natrional_plan_deau', }) ; var prob_zh_metrop_vf = new L.tileLayer.wms("http://wms.reseau-zones-humides.org/cgi-bin/wmsfma?service=WMS&request=GetMap&version=1.3.0", {alias : 'prob_zh_metrop_vf', layers:'Prob_ZH_metrop_vf', format:'image/png', attribution: '© PatriNat' }) ; var bcae_9 = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=PRAIRIES.SENSIBLES.BCAE&format=image/png&style=nolegend", {alias : 'bcae_9', maxZoom: 23, attribution: '© IGN' }) ; var seuils_pente_bcae = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=ELEVATION.ELEVATIONGRIDCOVERAGE.THRESHOLD&format=image/png&style=ELEVATION.ELEVATIONGRIDCOVERAGE.THRESHOLD", {alias : 'seuils_pente_bcae', maxZoom: 23, attribution: '© IGN' }) ; var carte_forestiere_v2 = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=LANDCOVER.FORESTINVENTORY.V2&format=image/png&style=normal", {alias : 'carte_forestiere_v2', attribution: '© IGN' }) ; var forets_publiques = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=FORETS.PUBLIQUES&format=image/png&style=FORETS PUBLIQUES ONF", {alias : 'forets_publiques', attribution: '© IGN' }) ; var restriction_drone = new L.TileLayer("https://data.geopf.fr/wmts?SERVICE=WMTS&request=GetTile&version=1.0.0&tileMatrixSet=PM_3_15&tilematrix={z}&tilecol={x}&tilerow={y}&&layer=TRANSPORTS.DRONES.RESTRICTIONS&format=image/png&style=normal", {alias : 'restriction_drone', maxZoom: 23, attribution: '© IGN' }) ; var lignes_aeriennes_basses_tensions = new L.tileLayer.wms("https://geobretagne.fr/geoserver/enedis/wms", {alias : 'lignes_aeriennes_basses_tensions', layers:'reseau_bt', transparent:true, format:'image/png', attribution: '@ ENEDIS via Geobretagne' }) ; var lignes_aeriennes_moyennes_tensions = new L.tileLayer.wms("https://geobretagne.fr/geoserver/enedis/wms", {alias : 'lignes_aeriennes_moyennes_tensions', layers:'reseau_hta', transparent:true, format:'image/png', attribution: 'ENEDIS via Geobretagne' }) ; var lignes_aeriennes_hautes_tensions = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=UTILITYANDGOVERNMENTALSERVICES.ALL&format=image/png&style=normal", {alias : 'lignes_aeriennes_hautes_tensions', transparent:true, attribution: '© IGN' }) ; var lignes_souterraines_basses_tensions = new L.tileLayer.wms("https://geobretagne.fr/geoserver/enedis/wms", {alias : 'lignes_souterraines_basses_tensions', layers:'reseau_souterrain_bt', transparent:true, format:'image/png', attribution: 'ENEDIS via Geobretagne' }) ; var lignes_souterraines_moyennes_tensions = new L.tileLayer.wms("https://geobretagne.fr/geoserver/enedis/wms", {alias : 'lignes_souterraines_moyennes_tensions', layers:'reseau_souterrain_hta', transparent:true, format:'image/png', attribution: 'ENEDIS via Geobretagne' }) ; var res_transport_gaz = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=GAZ.RESEAU.TRANSPORT&format=image/png&style=GAZ.RESEAU.TRANSPORT", {alias : 'res_transport_gaz', transparent:true, attribution: '© IGN' }) ; var res_distrib_gaz = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=GAZ.RESEAU.DISTRIBUTION&format=image/png&style=GAZ.RESEAU.DISTRIBUTION", {alias : 'res_distrib_gaz', transparent:true, attribution: '© IGN' }) ; var localisation_installations_methanisation = new L.TileLayer("https://data.geopf.fr/wmts?service=WMTS&request=GetTile&version=1.0.0&tilematrixset=PM&tilematrix={z}&tilecol={x}&tilerow={y}&layer=SITE.PRODUCTION.CHALEUR.METHANISATON&format=image/png&style=SITE.PRODUCTION.CHALEUR.METHANISATON", {alias : 'localisation_installations_methanisation', }) ; var etat_riviere = new L.TileLayer("https://eaurmc.lizmap.com/map/index.php/lizmap/service?repository=eaurmc&project=appli_qualite_riviere&LAYERS=masse_eau_appli_qualite&STYLES=défaut&VERSION=1.0.0&EXCEPTIONS=application/vnd.ogc.se_inimage&FORMAT=image/png&DPI=96&SERVICE=WMTS&REQUEST=GetTile&LAYER=masse_eau_appli_qualite&STYLE=default&TILEMATRIXSET=EPSG:3857&tilematrix={z}&tilecol={x}&tilerow={y}", {alias : 'etat_riviere', maxZoom: 23, transparent:true, attribution: '© AELB-RMC' }) ; var drawnItems = new L.FeatureGroup(); // LEAFLET MAP INIT var map = L.map(mapId, { center: new L.LatLng(47.8883,-1.92), zoom:9, zoomDelta: 0.25, zoomSnap: 0.25, maxZoom: 22, editable:true, editOptions:{ featuresLayer: drawnItems }, layers: [OpenStreetMap, ] }); var baseLayers = { "Open\u0020Street\u0020Map":OpenStreetMap, "Open\u0020Street\u0020Map\u0020NB":osm_gray, "ESRI\u0020Topo\u0020Map":esri_topo, "Plan\u0020IGN\u0020J\u002B1":plan_ign_j1, "SCAN\u002025":scna_25, "Carte\u0020OACI\u002DVFR\u00202024":oaci, "Ortho\u0020PCRS":ortho_pcrs, "OrthoPhotos\u0020HR\u0020\u002820cm\u0029":orthophotos_hr, "Ortho\u002DExpress\u00202023":ortho_express23, "OrthoPhotos\u0020\u00282011\u002D2015\u0029":orthophotos2011_2015, "OrthoPhotos\u0020\u00282006\u002D2010\u0029":orthophotos2006_2010, "OrthoPhotos\u0020\u00282000\u002D2005\u0029":orthophotos2000_2005, "OrthoPhotos\u0020\u00281980\u002D1995\u0029":orthophotos1980_1995, "OrthoPhotos\u0020\u00281950\u002D1965\u0029":orthophotos1950_1965, "OrthoPhotos\u0020Infrarouge":orthophotosirc, "SCAN\u002050\u0020Historique\u0020\u00281950\u0029":scan_50_annees_50, "Carte\u0020de\u0020l\u0027etat\u002Dmajor\u0020\u00281820\u002D1866\u0029":carte_etat_major, "Carte\u0020de\u0020Cassini":carte_cassini, "Google\u0020Sat":google_sat, "Pas\u0020de\u0020fond":noBaseLayer, } ; var otherBaseLayers = { "OrthoPhotos\u0020\u0028Transparence\u0029":ortho_transparence, "Ombrage":ombrage, "Courbes\u0020de\u0020niveau":contour_line, "Limites\u0020administratives":limites_admin, "Cadastre":cadastre, "D\u00E9calage\u0020cadastrale":decalage_cadastre, "Cartes\u0020g\u00E9ologiques\u0020\u0028BRGM\u0029":brgm_geol, "Lidar\u0020HD\u0020MNT\u0020Terrain\u0020\u0028IGN\u0029":lidar_hd_mnt, "Lidar\u0020HD\u0020MNS\u0020Terrain\u0020\u0028IGN\u0029":lidar_hd_mns, "Lidar\u0020HD\u0020MNH\u0020Terrain\u0020\u0028IGN\u0029":lidar_hd_mnh, "Cours\u0020d\u0027eau\u0020\u002D\u0020BCAE\u00204":cours_deau_bcae, "Cartographie\u0020des\u0020cours\u0020d\u0027eau\u0020des\u0020C\u00F4tes\u0020d\u0027Armor":carto_ce_22, "Cartographie\u0020des\u0020cours\u0020d\u0027eau\u0020d\u0027Ille\u002Det\u002DVilaine":carto_ce_35, "Cartographie\u0020des\u0020cours\u0020d\u0027eau\u0020de\u0020Loire\u0020Atlantique":carto_ce_44, "Cartographie\u0020des\u0020cours\u0020d\u0027eau\u0020du\u0020Maine\u0020et\u0020Loire":carto_ce_49, "Cartographie\u0020des\u0020cours\u0020d\u0027eau\u0020de\u0020Mayenne":carto_ce_53, "Cartographie\u0020des\u0020cours\u0020d\u0027eau\u0020du\u0020Morbihan":carto_ce_56, "Inventaire\u0020national\u0020des\u0020plans\u0020d\u0027eau":inventaire_natrional_plan_deau, "Cartographie\u0020nationale\u0020des\u0020milieux\u0020humides":prob_zh_metrop_vf, "Prairies\u0020sensibles\u0020\u002D\u0020BCAE\u00209":bcae_9, "Seuils\u0020de\u0020pente\u0020pour\u0020l\u0027agriculture\u0020\u002D\u0020BCAE\u00205":seuils_pente_bcae, "Carte\u0020foresti\u00E8re":carte_forestiere_v2, "For\u00EAts\u0020publiques":forets_publiques, "Restrictions\u0020UAS\u0020cat\u00E9gorie\u0020Ouverte\u0020et\u0020A\u00E9romod\u00E9lisme":restriction_drone, "Lignes\u0020a\u00E9riennes\u0020basses\u0020tensions":lignes_aeriennes_basses_tensions, "Lignes\u0020a\u00E9riennes\u0020moyennes\u0020tensions":lignes_aeriennes_moyennes_tensions, "Lignes\u0020a\u00E9riennes\u0020hautes\u0020tensions":lignes_aeriennes_hautes_tensions, "Lignes\u0020souterraines\u0020basses\u0020tensions":lignes_souterraines_basses_tensions, "Lignes\u0020souterraines\u0020moyennes\u0020tensions":lignes_souterraines_moyennes_tensions, "R\u00E9seaux\u0020de\u0020transport\u0020de\u0020gaz":res_transport_gaz, "R\u00E9seaux\u0020de\u0020distribution\u0020de\u0020gaz":res_distrib_gaz, "Localisation\u0020des\u0020installations\u0020de\u0020production\u0020de\u0020chaleur\u0020par\u0020m\u00E9thanisation":localisation_installations_methanisation, "Etat\u0020des\u0020rivi\u00E8res\u0020\u0028DCE\u0029":etat_riviere, } ; // Layer control L.control.layers(baseLayers, otherBaseLayers, {position: 'topleft'}).addTo(map); // Scalbar L.control.scale({'imperial':false, 'metric':true, 'position':'bottomright'}).addTo(map); // Locate control L.control.locate().addTo(map); // DRAW var sysmaGroup = new L.FeatureGroup(); map.addLayer(sysmaGroup); map.addLayer(drawnItems); drawnItems.bringToFront(); // other tools // SYSMA TOOL BOX ///////////////////////////////////////////////////////////////////// var sysmaToolBoxIsOpened = false ; var selectionMode = false ; L.Control.sysmaToolsButton = L.Control.extend({ options: { position: 'topleft' }, onAdd: function (map) { var container = L.DomUtil.create('div', 'leaflet-bar leaflet-control leaflet-sysma-toolbox-control'); container.id = 'sysmaToolBox' ; var button = L.DomUtil.create('a', 'leaflet-control-button leaflet-sysma-toolbox-button', container); L.DomEvent.disableClickPropagation(button); L.DomEvent.on(container, 'click', function(){ openCloseSysmaToolbox(); }); container.title = "Sysma ToolBox"; return container; }, onRemove: function(map) {}, }); L.control.sysmaTools = function(opts) { return new L.Control.sysmaToolsButton(opts); } L.control.sysmaTools({ position: 'topleft' }).addTo(map); function toggleSelectionMode() { setSelectionMode(!selectionMode) } function setSelectionMode(onOff) { if (onOff) { selectionMode = true ; drawnItems.clearLayers(); console.log('Selection mode On') ; enableDraw('ST_Polygon',null) $('.leaflet-selection-button').attr('style', 'background-color : #000 !important') ; } else { selectionMode = false ; map.editTools.stopDrawing() ; console.log('Selection mode Off') ; $('.leaflet-selection-button').attr('style', 'background-color : #ccc !important') ; } } function openCloseSysmaToolbox() { // MEASURE CONTROL if (sysmaToolBoxIsOpened == false) { map.measureControl = new L.Control.Measure({ position:'topleft', primaryLengthUnit: 'meters', secondaryLengthUnit: undefined, primaryAreaUnit: 'hectares', secondaryAreaUnit : 'sqmeters', activeColor: '#ff0000', completedColor: '#FF3333', localization: 'fr' }) ; map.addControl(map.measureControl) } else { map.measureControl.remove() ; } // SEARCH Tool if (sysmaToolBoxIsOpened == false) { map.searchBtn = new L.Control.Search({ url: 'https://nominatim.openstreetmap.org/search?format=json&q={s}', jsonpParam: 'json_callback', propertyName: 'display_name', propertyLoc: ['lat', 'lon'], markerLocation: true, autoCollapse: true, autoType: false, minLength: 2 }) ; map.addControl(map.searchBtn); } else { map.searchBtn.remove() ; } // COORDS TOOL if (sysmaToolBoxIsOpened == false) { coordBtnConstructor = L.Control.extend({ options: { position: 'topleft' }, onAdd: function (map) { map.coordBtn = this; var container = L.DomUtil.create('div', 'leaflet-bar leaflet-control leaflet-coord-control'); var button = L.DomUtil.create('a', 'leaflet-control-button leaflet-coord-button text-inactive', container); button.id = 'iconCoord' ; L.DomEvent.disableClickPropagation(container); L.DomEvent.on(container, 'click', function(){ $('#iconCoord').toggleClass('text-inactive'); groupCoord.clearLayers(); if (!$('#iconRpg').hasClass('text-inactive')) { $('#iconRpg').toggleClass('text-inactive'); } if (!$('#iconCad').hasClass('text-inactive')) { $('#iconCad').toggleClass('text-inactive'); } setSelectionMode(false) }); container.title = "Afficher les coordonnées de la carte"; return container; }, onRemove: function(map) { groupCoord.clearLayers(); }, }); var coordBtn = new coordBtnConstructor() ; coordBtn.addTo(map); } else { if (map.coordBtn) { console.log('Close Coord Tool') ; map.coordBtn.remove() ; } } // SELECTION TOOL if (sysmaToolBoxIsOpened == false) { selectionBtnConstructor = L.Control.extend({ options: { position: 'topleft' }, onAdd: function (map) { map.selectBtn = this; var container = L.DomUtil.create('div', 'leaflet-bar leaflet-control leaflet-selection-control'); var button = L.DomUtil.create('a', 'leaflet-control-button leaflet-selection-button', container); L.DomEvent.disableClickPropagation(button); L.DomEvent.on(container, 'click', function(){ toggleSelectionMode(); if (!$('#iconCad').hasClass('text-inactive')) { $('#iconCad').toggleClass('text-inactive'); } if (!$('#iconRpg').hasClass('text-inactive')) { $('#iconRpg').toggleClass('text-inactive'); } if (!$('#iconCoord').hasClass('text-inactive')) { $('#iconCoord').toggleClass('text-inactive'); } }); container.title = "Zone de sélection"; return container; }, onRemove: function(map) {}, }); var selectBtn = new selectionBtnConstructor() ; selectBtn.addTo(map); } else { if (map.selectBtn) { console.log('Close Selection Tool') ; map.selectBtn.remove() ; } } // RPG TOOL if (sysmaToolBoxIsOpened == false) { console.log('Open Sysma Tool Box') ; sysmaToolBoxIsOpened = true ; } else { console.log('Close Sysma Tool Box') ; sysmaToolBoxIsOpened = false ; } } // Editable Events function enableDraw(type,snapLayer,mode = 'classic') { selectedLayer.remove() ; selectedLayer.clearLayers() ; //console.log(snapLayer); if (snapLayer !== null) { var snap = new L.Handler.MarkerSnap(map, null, { snapDistance : 15 }); //console.log('snapping is on') ; //console.log(map._layers[snapLayer]) ; snap.addGuideLayer(map._layers[snapLayer]); var snapMarker = L.marker(map.getCenter(), { icon: map.editTools.createVertexIcon({className: 'leaflet-div-icon leaflet-drawing-icon'}), opacity: 1, zIndexOffset: 1000 }); snap.watchMarker(snapMarker); map.on('editable:vertex:dragstart', function (e) { snap.watchMarker(e.vertex); }); map.on('editable:vertex:dragend', function (e) { snap.unwatchMarker(e.vertex); }); map.on('editable:drawing:start', function () { this.on('mousemove', followMouse); }); map.on('editable:drawing:end', function () { this.off('mousemove', followMouse); snapMarker.remove(); }); map.on('editable:drawing:cancel', function () { snap.disable() ; this.off('mousemove', followMouse); snapMarker.remove(); }); map.on('editable:drawing:click', function (e) { // Leaflet copy event data to another object when firing, // so the event object we have here is not the one fired by // Leaflet.Editable; it's not a deep copy though, so we can change // the other objects that have a reference here. var latlng = snapMarker.getLatLng(); e.latlng.lat = latlng.lat; e.latlng.lng = latlng.lng; }); snapMarker.on('snap', function (e) { snapMarker.addTo(map); }); snapMarker.on('unsnap', function (e) { snapMarker.remove(); }); var followMouse = function (e) { snapMarker.setLatLng(e.latlng); } } createMode = mode ; console.log('createMode'+createMode) ; if (type === 'ST_Point') { map.editTools.startMarker(); } else if (type === 'ST_Linestring') { map.editTools.startPolyline(); } else if (type === 'ST_Polygon') { map.editTools.startPolygon(); } } // tracking continue mode var cont = 0 ; map.on('editable:drawing:commit', function (e) { map.editTools.stopDrawing() ; if (cont === 0) { //console.log(e) ; e.layer.editor.disable() ; layer = e.layer; var shape = layer.toGeoJSON(); var shape_for_db = JSON.stringify(shape); var data = JSON.parse(shape_for_db); openClose('rightColumn', '60%', 'map', '100%'); $('#infos').hide(150); $('#objet').show(150); if (selectionMode) { sendData('geom=' + data.geometry.coordinates + '&selectionMode='+selectionMode, 'https\u003A\/\/eptb\u002Dvilaine.sysma.io\/selection\u002Dgeo', 'objet', null); setSelectionMode(false) ; } else { if (createMode !== undefined && createMode==='complete') { sendData('geom=' + data.geometry.coordinates, 'https\u003A\/\/eptb\u002Dvilaine.sysma.io\/objet\/create\u002Dcomplete', 'objet', null); } else { sendData('geom=' + data.geometry.coordinates, 'https\u003A\/\/eptb\u002Dvilaine.sysma.io\/objet\/create', 'objet', null); } } //sendData(null, "https\u003A\/\/eptb\u002Dvilaine.sysma.io\/layermanager", "infos", event); } else { //console.log('commit with continue = true') ; cont = 0 ; } }); // continue mode, Ctrl + click map.on('editable:vertex:ctrlclick editable:vertex:metakeyclick', function (e) { cont = 1 ; e.vertex.continue(); }); // editable Ctrl Z var Z = 90, latlng, redoBuffer = [], onKeyDown = function (e) { if (e.keyCode == Z) { if (!this.editTools._drawingEditor) return; if (e.shiftKey) { if (redoBuffer.length) this.editTools._drawingEditor.push(redoBuffer.pop()); } else { latlng = this.editTools._drawingEditor.pop(); if (latlng) redoBuffer.push(latlng); } } }; L.DomEvent.addListener(document, 'keydown', onKeyDown, map); map.on('editable:drawing:end', function () { redoBuffer = []; }); // Update user's center and zoom value on each pan and zoom map.on('moveend', function (e) { //console.log('moveend') ; $('#center').val(map.getCenter()) ; $('#zoom').val(map.getZoom()) ; console.log(e); sendData('centre=' + String(map.getCenter()).replace(" ","") + '&zoom=' + map.getZoom(), 'https\u003A\/\/eptb\u002Dvilaine.sysma.io\/update\u002Dmap\u002Dsettings', 'layerstate', null, false); }); map.on('baselayerchange', function (e) { //console.log('baselayerchange') ; //console.log(e) ; //if (e.sourceTarget._popup === null) { sendData2('baselayer=' + e.layer.options.alias, 'https\u003A\/\/eptb\u002Dvilaine.sysma.io\/update\u002Dbaselayer', 'layerstate', null); //} }); map.on('overlayremove', function (e) { //console.log('overlayremove') ; sendData2('action=remove&otherbaselayer=' + e.layer.options.alias, 'https\u003A\/\/eptb\u002Dvilaine.sysma.io\/update\u002Dother\u002Dbaselayer', 'layerstate', null); }); map.on('overlayadd', function (e) { //console.log('overlayadd') ; sendData2('action=add&otherbaselayer=' + e.layer.options.alias, 'https\u003A\/\/eptb\u002Dvilaine.sysma.io\/update\u002Dother\u002Dbaselayer', 'layerstate', null); }); // OnClick map events var groupCad = L.layerGroup(); groupCad.addTo(map); var groupRpg = L.layerGroup(); groupRpg.addTo(map); var groupCoord = L.layerGroup(); groupCoord.addTo(map); var selectedLayer = L.layerGroup(); selectedLayer.addTo(map); var selectedItems = [] ; map.on('dblclick', function (e) { }) ; map.on('click', function (e) { //console.log('click') ; // selected feature style reset selectedLayer.remove() ; selectedLayer.clearLayers() ; selectedItems = [] ; groupCad.clearLayers(); // // map click coordinates infos if (!$('#iconCoord').hasClass('text-inactive') && $('#iconCoord').length>0) { groupCoord.clearLayers(); var markerCoord = L.marker(e.latlng); groupCoord.addLayer(markerCoord); sendData('mouse=' + e.latlng, 'https\u003A\/\/eptb\u002Dvilaine.sysma.io\/coords', 'objet', event, true); $('#infos').hide(150); $('#objet').show(150); } // // map click cadastre infos if (!$('#iconCad').hasClass('text-inactive') && $('#iconCad').length>0) { $('#infos').hide(150); $('#objet').show(150); openClose('rightColumn', '60%', 'map', '40%'); sendData('mouse=' + e.latlng, 'https\u003A\/\/eptb\u002Dvilaine.sysma.io\/infos\u002Dcadastre', 'objet', null); } // map click RPG infos if (!$('#iconRpg').hasClass('text-inactive') && $('#iconRpg').length>0) { $('#infos').hide(150); $('#objet').show(150); openClose('rightColumn', '60%', 'map', '40%'); sendData('mouse=' + e.latlng, 'https\u003A\/\/eptb\u002Dvilaine.sysma.io\/infos\u002Drpg', 'objet', null); } }); sendData(null, 'https\u003A\/\/eptb\u002Dvilaine.sysma.io\/layermanager', 'infos', null);