{"id":442,"date":"2022-06-21T12:03:25","date_gmt":"2022-06-21T10:03:25","guid":{"rendered":"https:\/\/www.eldin.net\/wordpress\/?page_id=442"},"modified":"2023-04-03T08:48:15","modified_gmt":"2023-04-03T06:48:15","slug":"expoactes-pour-utiliser-openstreetmap-pour-la-carte-principal","status":"publish","type":"page","link":"https:\/\/www.eldin.net\/wordpress\/index.php\/expoactes-pour-utiliser-openstreetmap-pour-la-carte-principal\/","title":{"rendered":"ExpoActes : pour utiliser OpenStreetMap pour la carte principal"},"content":{"rendered":"\n<pre class=\"wp-block-code\"><code>Fichier actes\/index.php\n\n\n[......]\n\n\nif($userlevel > 2) {\n\nif (GEO_MODE_PUBLIC==5 or $vue==\"C\")  \/\/ si pas localit\u00e9 isol\u00e9e et avec carte\n        {\n         if (GEO_CENTRE_CARTE &lt;> \"\"){\n                 $georeq = \"select LON,LAT from \".EA_DB.\"_geoloc where COMMUNE = '\".sql_quote(GEO_CENTRE_CARTE).\"' and STATUT in ('A','M')\";\n                 $geores =  EA_sql_query($georeq);\n                 if ($geo = EA_sql_fetch_array($geores)){\n                         $lat=$geo['LAT'];\n                         $lon=$geo['LON'];\n                 }else{\n                        $lat=0;\n                         $lon=0;\n                 }\n\n          }\n\n\n        if (GEO_ZOOM_INITIAL==\"\") $geo_zoom=0; \n                else $geo_zoom=GEO_ZOOM_INITIAL;\n\n       echo '&lt;link rel=\"stylesheet\" href=\"\/leaflet\/leaflet.css\" \/>';\n        echo '&lt;script src=\"\/leaflet\/leaflet.js\" >&lt;\/script>';\n echo '&lt;link rel=\"stylesheet\" href=\"\/leaflet\/leaflet.fullscreen.css\" \/>';\n echo '&lt;script src=\"\/leaflet\/Leaflet.fullscreen.min.js\">&lt;\/script>';\n\n        echo '&lt;script type=\"text\/javascript\">';\n        echo '  var lat = '.$lat.';';\n        echo '  var lon = '.$lon.';';\n        echo '  var macarte = null;';\n        echo '  function initMap() {';\n        echo '          var iconBase = \"\/actes\/img\/pin_eye.png\";';\n        echo \"          macarte = L.map('map').setView([lat, lon], \".$geo_zoom.\");\";\n        echo '          L.tileLayer(\"https:\/\/{s}.tile.openstreetmap.fr\/osmfr\/{z}\/{x}\/{y}.png\", {';\n        echo '                  attribution: \\'donn\u00e9es \u00a9 &lt;a href=\"\/\/osm.org\/copyright\">OpenStreetMap&lt;\/a>\/ODbL - rendu &lt;a href=\"\/\/openstreetmap.fr\">OSM France&lt;\/a>\\',';\n        echo '                  minZoom: 1,';\n        echo '                  maxZoom: 20';\n        echo '          }).addTo(macarte);';\n        echo '          var myIcon = L.icon({';\n        echo '                  iconUrl: iconBase ,';\n        echo '                  iconSize: [21, 34],';\n        echo '                  iconAnchor: [21, 34],';\n        echo '                  popupAnchor: [-25, -80],';\n        echo '          });';\n        $georeq = \"select LON,LAT,commune,depart from \".EA_DB.\"_geoloc where STATUT in ('A','M')\";\n        $geores =  EA_sql_query($georeq);\n         while ($geo = EA_sql_fetch_array($geores)){\n                $texte_html=\"&lt;b>\".$geo['commune'].\" [\".$geo['depart'].\"]&lt;\/b>&lt;br \/>\u00a0&lt;br \/>\";\n                $lstreq = \"select LIBELLE,sum(NB_TOT) as nbtot,TYPACT from \".EA_DB.\"_sums  where commune='\".$geo['commune'].\"' and depart='\".$geo['depart'].\"'\";\n                $lstres=EA_sql_query($lstreq);\n                while ($lst=EA_sql_fetch_array($lstres)){\n                        $linkdiv = \"\";\n                        switch ($lst['TYPACT']){\n                                case \"N\":\n                                $typel = \"Naissances\/Bapt\u00eames\";\n                                $prog = \"tab_naiss.php\";\n                                $sigle = \"\u00b0\";\n                                break;\n                         case \"M\":\n                                $typel = \"Mariages\";\n                                $prog = \"tab_mari.php\";\n                                $sigle = \"x\";\n                                break;\n                         case \"D\":\n                                $typel = \"D\u00e9c\u00e8s\/S\u00e9pultures\";\n                                $prog = \"tab_deces.php\";\n                                $sigle = \"+\";\n                                break;\n                         case \"V\":\n                                if ($lst['LIBELLE']==\"\")\n                                        $typel = \"Divers\";\n                                 else{\n                                        $typel = $lst['LIBELLE'];\n                                        $linkdiv = ';'.$lst['LIBELLE'];\n                                 }\n                                $prog = \"tab_bans.php\";\n                                $sigle = \"#\";\n                                break;\n                         }\n\n                        $href = '&lt;a href='.mkurl($root.$chemin.$prog,$geo['commune'].' ['.$geo['depart'].']'.$linkdiv).'>';\n                        $texte_html.=$href.$lst['nbtot'].\" \".$lst['LIBELLE'].\"&lt;\/a>&lt;br \/>\";\n                }\n                echo 'var marker = L.marker(['.$geo['LAT'].','.$geo['LON'].'],{ icon: myIcon }).addTo(macarte).bindPopup(\"'.$texte_html.'\");';\n\n        }\n\n    \/\/ pour le passage en plein \u00e9cran\n        echo '          macarte.addControl(new L.Control.Fullscreen({';\n        echo '               title: {';\n        echo \"             'false': 'Passer en plein \u00e9cran',\";\n        echo \"             'true': 'Sortir du plein \u00e9cran'\";\n        echo '                      }';\n        echo '                  }));';\n        echo '  }';\n        \/\/ on charge la carte\n\n        echo 'window.onload = function(){';\n        echo '          initMap(); ';\n        echo '};';\n        echo '&lt;\/script>';\n        echo '&lt;style type=\"text\/css\">';\n        echo '  #map{ ';\n        echo '          height:400px;';\n        echo '  }';\n        echo '&lt;\/style>';\n} else\n        $JSheader = \"\";\n}\n[....]\n\n\n\necho '&lt;h2>Communes et paroisses';\nif (GEO_MODE_PUBLIC>=3 and GEO_MODE_PUBLIC&lt;5)\n        {\n        echo \" : \";\n        if ($xtyp==\"\")\n                $argtyp = \"\";\n                else\n                $argtyp = \"&amp;xtyp=\".$xtyp;\n        $href = '&lt;a href=\"'.$root.$chemin.'index.php';\n        if ($vue==\"C\")\n                echo \"Carte\";\n                else\n                echo '&lt;a href=\"'.$root.$chemin.'index.php?vue=C'.$argtyp.'\">Carte&lt;\/a>';\n        echo \" | \";\n        if ($vue==\"T\")\n                echo \"Tableau\";\n                else\n                echo '&lt;a href=\"'.$root.$chemin.'index.php?vue=T'.$argtyp.'\">Tableau&lt;\/a>';\n        }\necho '&lt;\/h2>';\n\nif (GEO_MODE_PUBLIC==5 or $vue==\"C\")  \/\/ si pas localit\u00e9 isol\u00e9e et avec carte\n        {\n        echo '&lt;p>&lt;b>'.$menu_actes.'&lt;\/b>&lt;\/p>';\n        \/\/--- affiche la Carte\n        echo '&lt;div id=\"map\">&lt;\/div>';\n        echo '&lt;style type=\"text\/css\">';\n        echo '  #map{ ';\n        echo '          height:600px;';\n        echo '  }';\n        echo '&lt;\/style>';\n        }\n\n[........]<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-442","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/www.eldin.net\/wordpress\/index.php\/wp-json\/wp\/v2\/pages\/442"}],"collection":[{"href":"https:\/\/www.eldin.net\/wordpress\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.eldin.net\/wordpress\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.eldin.net\/wordpress\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.eldin.net\/wordpress\/index.php\/wp-json\/wp\/v2\/comments?post=442"}],"version-history":[{"count":9,"href":"https:\/\/www.eldin.net\/wordpress\/index.php\/wp-json\/wp\/v2\/pages\/442\/revisions"}],"predecessor-version":[{"id":543,"href":"https:\/\/www.eldin.net\/wordpress\/index.php\/wp-json\/wp\/v2\/pages\/442\/revisions\/543"}],"wp:attachment":[{"href":"https:\/\/www.eldin.net\/wordpress\/index.php\/wp-json\/wp\/v2\/media?parent=442"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}