Géolocalisation application web
Bonjour,
j'utilise la géolocalisation afin de récupérer les coordonnées gps de ma position pour les envoyer dans une base de donnée.
Tout fonctionne en local mais ça ne fonctionne pas avec mon iphone ou mon androïd.
Avez-vous une solution à me proposer?
Voici le code:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
| <!DOCTYPE html>
<html lang="fr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8">
<title>modification de données en PHP :: partie2</title>
<meta name="Author" content="NoSmoking">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.css">
<link rel="stylesheet" href="http://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script src="http://cdn.leafletjs.com/leaflet/v0.7.7/leaflet.js"></script>
<Link rel = " stylesheet " href = "leaflet/fullscreen/Control.FullScreen.css" />
<Script src = "leaflet/fullscreen/Control.FullScreen.js" ></script>
<link rel="stylesheet" href="leaflet/dist/leaflet.home.css" />
<script src="leaflet/dist/leaflet.home.js"></script>
<style>
html, body {
margin: 0 0 1em;
padding: 0;
font: 1em/1.5 Verdana,sans-serif;
font-size: 100%;
background-color: #90C3D4;
}
h1, h2, h3 {
margin: 0 0 .5em .25em;
color: #069;
text-align:center;
}
input {
width: 20em;
font: inherit;
}
select {
width : 100% ;
}
button {
/* Cette marge représente approximativement le même espace
que celui entre les étiquettes et les champs textuels */
display: block;
margin : auto;
text-align: center ;
width: 16em;
height: 5em;
}
form
{
width : 100% ;
}
</style>
</head>
<body>
<header>
<h1>Modification du type d'incident</h1>
</header>
<?php
//connection au serveur:
$cnx = mysql_connect( "localhost", "root", "" ) ;
//sélection de la base de données:
$db = mysql_select_db( "VOIRIE" ) ;
//récupération de la variable d'URL,
//qui va nous permettre de savoir quel enregistrement modifier
$id = $_GET["voirie_id"] ;
//requête SQL:
$sql = "SELECT *
FROM incident
WHERE voirie_id = ".$id ;
mysql_query("SET NAMES 'utf8'");
//exécution de la requête:
$requete = mysql_query( $sql, $cnx ) ;
//affichage des données:
if( $result = mysql_fetch_object( $requete ) )
{
?>
<script>
//Récupérer les coordonnées
function maPosition(position) {
document.getElementById('lat').value=position.coords.latitude ;
document.getElementById('lng').value=position.coords.longitude ;
}
if(navigator.geolocation)
navigator.geolocation.getCurrentPosition(maPosition);
</script>
<form name="insertion" action="type3.php" method="POST">
<input type="hidden" name="id" value="<?php echo($id) ;?>">
<table border="0" align="center" cellspacing="2" cellpadding="2" >
<tr align="center">
<td bgcolor="#669999">Voie</td>
<td bgcolor="#669999"><input type="text" name="voie" value="<?php echo($result->voirie_voie) ;?>"></td>
</tr>
<tr align="center">
<td bgcolor="#669999">code</td>
<td bgcolor="#669999"><input type="text" name="code" value="<?php echo($result->voirie_code) ;?>"></td>
</tr>
<tr align="center">
<td bgcolor="#669999">ville</td>
<td bgcolor="#669999"><input type="text" name="ville" value="<?php echo($result->voirie_ville) ;?>"></td>
</tr>
<tr align="center">
<td bgcolor="#669999">Type</td>
<td bgcolor="#669999">
<select name="type">
<option value="autre" selected><?php echo($result->voirie_type) ;?></option>
<option value="nid">nid</option>
<option value="rives">rives</option>
<option value="faussé">fossé</option>
</select></td>
</tr>
<tr align="center">
<td bgcolor="#669999">Enrobé</td>
<td bgcolor="#669999">
<select name="enrobe">
<option value="choix" selected><?php echo($result->voirie_enrobe) ;?></option>
<option value="oui">oui</option>
<option value="non">non</option>
<tr align="center">
<td bgcolor="#669999">latitude</td>
<td bgcolor="#669999"><input type="text" name="lat" id="lat" ></td>
</tr>
<tr align="center">
<td bgcolor="#669999">longitude</td>
<td bgcolor="#669999"><input type="text" name="lng" id="lng" ></td>
</tr>
</select></td>
</tr>
<tr align="center">
<td colspan="2"><input type="submit" value="modifier"></td>
</tr>
</table>
</form>
<?php
}//fin if
?>
</body>
<form method="post" action="type1.php" enctype="multipart/form-data">
<p>
<label></label><button type="submit">Retour</button>
</p>
</form>
</html> |