Advertisement
Guest User

Untitled

a guest
Aug 24th, 2016
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.19 KB | None | 0 0
  1. <html>
  2. <head>
  3.  
  4. <meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1.0">
  5.  
  6. <title>Smiddest</title>
  7.  
  8. <link type="text/css" rel="stylesheet" href="css/jquery-ui.css">
  9.  
  10. <link rel="stylesheet" href="http://openlayers.org/en/v3.17.1/css/ol.css" type="text/css">
  11. <link rel="stylesheet" href="css/ol3-layerswitcher.css">
  12. <link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
  13. <link type="text/css" rel="stylesheet" href="css/materialize.css" media="screen,projection">
  14. <link type="text/css" rel="stylesheet" href="css/main.css">
  15.  
  16.  
  17.  
  18. </head>
  19. <body>
  20. <?php
  21. if(isset($_SESSION['mem_id']) AND $userinfo['mem_id'] == $_SESSION['mem_id']) {
  22. ?>
  23.  
  24. <header>
  25. <?php include 'header.php' ?>
  26. </header>
  27.  
  28. <main>
  29. <div class="row">
  30. <div class="col s8 m8 l8">
  31. <div id="map" class="map"></div>
  32. </div>
  33.  
  34.  
  35. <div class="col s4 m4 4">
  36. <div class="col s6 m6 l6"></div>
  37. <div class="col s6 m6 l6">
  38. <?php
  39. $date = date("d/m/Y");
  40. Print('<div class="heure">' . "$date" . '</div>');
  41. ?>
  42. </div>
  43. </div>
  44. </div>
  45. </main>
  46.  
  47.  
  48. <!-- Fin du isset -->
  49. <?php
  50. }
  51. ?>
  52.  
  53. <script src="js/ol.js" type="text/javascript"></script>
  54. <script src="js/ol3-layerswitcher.js" type="text/javascript"></script>
  55.  
  56. <script type="text/javascript" src="js/jquery-3.1.0.js"></script>
  57. <script type="text/javascript" src="js/jquery-ui.js"></script>
  58.  
  59.  
  60.  
  61. <script src="js/materialize.js"></script>
  62. <script src="js/app.js"></script>
  63.  
  64. </body>
  65. </html>
  66.  
  67. $(".button-collapse").sideNav();
  68.  
  69.  
  70. var map = new ol.Map({
  71. target: 'map',
  72. layers: [
  73. new ol.layer.Group({
  74. 'title': 'Fond de cartes',
  75. layers: [
  76.  
  77. new ol.layer.Vector({
  78. title: 'Chemins',
  79. source: new ol.source.Vector({
  80. url: 'getData.php',
  81. format: new ol.format.GeoJSON()
  82. }),
  83. }),
  84.  
  85. new ol.layer.Tile({
  86. title: 'MapBox Street',
  87. type: 'base',
  88. visible: true,
  89. source: new ol.source.XYZ({
  90. url: 'https://api.mapbox.com/styles/v1/mapbox/streets-v9/tiles/256/{z}/{x}/{y}?access_token=pk.eyJ1IjoiamF1ZnJ5IiwiYSI6ImNpcmVsbjg1YjAwMGhpY200b2xudmQ3bmUifQ.vSOJfU9DMMEa7JDss5TDQA'
  91. })
  92. }),
  93.  
  94. new ol.layer.Tile({
  95. title: 'Fond OSM',
  96. type: 'base',
  97. visible: true,
  98. source: new ol.source.OSM()
  99. }),
  100. ]
  101. }),
  102.  
  103. ],
  104. view: new ol.View({
  105. center: ol.proj.fromLonLat([-0.57, 45.22]),
  106. zoom: 10
  107. })
  108. });
  109.  
  110. var layerSwitcher = new ol.control.LayerSwitcher({
  111. tipLabel: 'Légende'
  112. });
  113. map.addControl(layerSwitcher);
  114.  
  115. <?php
  116. try{
  117. $bdd = new PDO ("pgsql:host=localhost;port=8356;dbname=BDD_SMIDDEST;user=postgres") or die(print_r($bdd->errorInfo()));
  118. $bdd->exec("SET NAMES utf8");
  119. $bdd->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
  120. }
  121.  
  122. catch(Exeption $e){
  123. die("Erreur!".$e->getMessage());
  124. }
  125.  
  126.  
  127. $qry = $bdd->prepare("SELECT dgs_id, ST_ASGeoJSON(geom) AS geojson FROM departements_geofla_sage");
  128. $qry->execute();
  129. $Resultats = array("type"=> "FeatureCollection", "features" => array());
  130. $compteur = 0;
  131.  
  132. while($row = $qry->fetch()) {
  133. //Je rajoute un feature avec geométrie et propriétés nulles pour l'instant
  134. $Resultats["features"][$compteur] = array("type" => "Feature", "id"=> $row["dgs_id"], "coordinates" => Null, "properties" => Null);
  135.  
  136. //Je rajoute les propriétés
  137. $Resultats["features"][$compteur]["properties"]["dgs_id"] = array ($row["dgs_id"]);
  138.  
  139.  
  140.  
  141. //Je rajoute la géométrie
  142. $Resultats["features"][$compteur]["coordinates"] = array ($row["geojson"]);
  143.  
  144. $compteur ++; //Incrémentation du compteur
  145. }
  146. $bdd = null;
  147. echo json_encode($Resultats);
  148. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement