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 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305
| <html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<meta name="msapplication-tap-highlight" content="no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<title>AÏGO</title>
<!--<link href="C:/APPLICATION/www/img" /> -->
<link rel="stylesheet" type="text/html" href="www/index.html" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<link rel="stylesheet" href="css/leaflet.css" />
<script src="js/leaflet.js"></script>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/capture.js"></script>
<link rel="stylesheet" href="jquery/jquery.mobile-1.4.5.min.css">
<script src="jquery/jquery-1.11.3.min.js"></script>
<script src="jquery/jquery.mobile-1.4.5.min.js"></script>
<script type="text/javascript" src="js/date_heure.js"></script>
</head>
<body>
<div data-role="page" id="carte">
<div data-role="content">
<div id="map" ></div>
<button onclick='centrageauto();'>Ma position</button>
<a href="#infopoint" class="ui-btn" onclick='Picture();'>Photo</a>
</div>
</div>
<!-- Début de la seconde page -->
<div data-role="page" id="infopoint">
<div data-role="content">
<center>
<br>
<!--<form name="formulaire" action="page.php" method="post" target="_blank">-->
<label>Date et heure : </label>
<span id="date_heure"></span>
<script id="date_heure" type="text/javascript">window.onload = date_heure('date_heure');</script>
<br/>
<br/>
<label>ASA : </label>
<select id="asa">
<option>ASA 1</option>
<option>ASA 2</option>
<option>ASA 3</option>
<option>ASA 4</option>
</select>
<br/>
<br/>
<label>Nom : </label>
<input type="text" id="nom"/>
<br/>
<br/>
<label>Prénom : </label><input type="text" id="prenom"/>
<br/>
<br/>
<label>Intérêt : </label>
<select id="interet">
<option>Fuite</option>
<option>Bouché</option>
<option>Végétation</option>
</select>
<br/>
<br/>
<label>Latitude : </label>
<input type="text" id="coor_x"/>
<br/>
<br/>
<label>Longitude : </label>
<input type="text" id="coor_y"/>
<br/>
<br/>
<label>Commentaire : </label>
<textarea rows="4" cols="25" id="commentaire">Commentaire ici </textarea>
<br/>
<br/>
<a href="#carte" class="ui-btn" <!--onclick='onDeviceReadytb();'-->Valider</a>
<!--</form>-->
</center>
</div><!-- /content -->
</div><!-- /page -->
<script>
/*------------------------------Initialisation de la carte------------------------------*/
$('#map').load('pagecreate',function() {
//création de la variable carte : 'map'
map = L.map('map').setView([10, 4.6495853], 18);
//création de la couche de fond Open Street Map (OSM) avec options d'affichage à l'ouverture
L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png', {
maxZoom: 18,
minZoom: 2,
attribution: 'Map data © ; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>' +
'<a href="http://creativecommons.org/licenses/by-sa/2.0/"></a>',
id: 'examples.map-i875mjb7'
}).addTo(map);
setTimeout(function(){
map.invalidateSize();
}, 1);
//niveau de zoom à l'ouverture
//map.locate({setView: true, maxZoom: 18});
//lancement de la fonction 'centrageauto' quand le mobile est prêt
//document.addEventListener("deviceready", centrageauto, false);
/*------------------------------exécution du GPS du mobile------------------------------*/
//la variable 'centrageautoactive' a pour valeure 'true'
centrageautoactive = true;
//activation du GPS
navigator.geolocation.watchPosition(onSuccess,error,{ maximumAge: 0, timeout: 10000, enableHighAccuracy: true });
//pour 'centrageautoactive' égale 'true' la fonction détermine les coordonnées x et y et exécute centrageauto
function onSuccess(position) {
x = position.coords.latitude;
y = position.coords.longitude;
if (centrageautoactive==true){
centrageauto();
}
document.getElementById("coor_x").value = x;
document.getElementById("coor_y").value = y;
}
//applique la valeure 'false' à la variable 'centrageautoactive' au déplacement de la map
map.on('dragstart', function() {
centrageautoactive = false;
});
//réapplique la valeure 'true' à la variable 'centrageautoactive' et réexécute la fonction 'centrageauto'
function reactivecentrageauto () {
centrageautoactive = true;
centrageauto();
}
//lancement d'une alerte en cas d'erreur
function error(erreur) {
var info = "Erreur lors de la géolocalisation : ";
switch (erreur.code) {
case error.PERMISSION_DENIED:
alert ('Vous navez pas donné la permission');
break;
case erreur.TIMEOUT :
alert ('Délais de recherche dépassé, vérifier si le GPS fonctionne');
break;
case error.POSITION_UNAVAILABLE:
alert ('La position na pu être déterminée');
break;
case error.UNKNOW_ERROR:
alert ('Erreur inconnue');
break;
}
}
/*function clearWatch() {
if (watchID != null) {navigator.geolocation.clearWatch(watchID); watchID = null;}
}*/
/*------------------------------gestion de l'icone et 'centrageauto' permet de centrer la carte sur la position------------------------------*/
//mise en forme du marker
var monIcone = L.icon({iconUrl: 'img/monIcone.png'});
marker = L.marker([0 , 0], {icon : monIcone}).addTo(map);
});
function centrageauto() {
map.setView([x,y], 18);
//map.setZoom(18,{animate:true});
marker.setLatLng([x,y]);
}
</script>
<script>
/*------------------------------utilisation de l'appareil photo du mobile------------------------------*/
//quand le mobile est prêt lancement de la fonction 'camera'
function ready () {
document.addEventListener("deviceready", camera, false);
}
//permet l'utilisation de l'appareil photo du mobile
function camera() {
console.log(navigator.camera);
}
//lancement de l'appareil photo avec options et succès ou non
function Picture (){
navigator.camera.getPicture(onSuccess, onFail, {quality: 70, destinationType: Camera.DestinationType.FILE_URI, targetWidth: 200, targetHeight: 200, mediaType: Camera.MediaType.ALLMEDIA});
}
//succès de la prise de photo
function onSuccess(imageURI) {
var image = document.getElementById('image')
image.src = imageURI;
image.style.display = 'block';
}
//erreur en cas de non prise de photo
function onFail(message) {
alert('Echec: ' + message);
}
</script>
<script>
/*------------------------------enregistrement du point et de ses données sur la base de données mobile sqlite------------------------------*/
//PLUGIN SQLITE : CREATION BASE DE DONNEES
testvariable = 'variable';
//ouverture de base de données sqlite
//document.addEventListener("deviceready", onDeviceReadytb, false);
function onDeviceReadytb() {
var db = window.sqlitePlugin.openDatabase({name: "my.db"});
db.transaction(function(tx) {
tx.executeSql("DROP TABLE IF EXISTS table_photo");
tx.executeSql('CREATE TABLE IF NOT EXISTS table_photo (id INTEGER PRIMARY KEY AUTOINCREMENT, dateheure TEXT, asa TEXT, prenom TEXT, nom TEXT, interet TEXT, latitude REAL, longitude REAL, commentaire TEXT) CHARACTER SET utf8'); //créer la table table_photo avec les champs et leur type
});
db.transaction(function(tx) {
tx.executeSql("DELETE FROM table_photo"); //effacer les entitées de la table table_photo déjà existantes
//tx.executeSql("DROP TABLE IF EXISTS table_photo"); //supprimer la table table_photo si elle existe déjà
//tx.executeSql("INSERT INTO table_photo(id) VALUES ('"autoincrement"')");
tx.executeSql("INSERT INTO table_photo(dateheure, asa, prenom, nom, interet, latitude, longitude, commentaire) VALUES ('"+$('#date_heure').val()+,+$('#asa').val()+,+$('#prenom').val()+,+$('#nom').val()+,+$('#interet').val()+,+$('#coor_x').val()+,+$('#coor_y').val()+,+$('#commentaire').val()+,"')");
//tx.executeSql("INSERT INTO table_photo(asa) VALUES ('"+$('#asa').val()+"')");
//tx.executeSql("INSERT INTO table_photo(prenom) VALUES ('"+$('#prenom').val()+"')");
//tx.executeSql("INSERT INTO table_photo(COMMUNE) VALUES ('"commune"')");
//tx.executeSql("INSERT INTO table_photo(nom) VALUES ('"+$('#nom').val()+"')");
//tx.executeSql("INSERT INTO table_photo(interet) VALUES ('"+$('#interet').val()+"')");
//tx.executeSql("INSERT INTO table_photo(latitude) VALUES ('"+$('#coor_x').val()+"')");
//tx.executeSql("INSERT INTO table_photo(longitude) VALUES ('"+$('#coor_y').val()+"')");
//tx.executeSql("INSERT INTO table_photo(commentaire) VALUES ('"+$('#commentaire').val()+"')");
alert('Enregistrement du point');
});
db.transaction(function(tx) {
tx.executeSql("SELECT * FROM table_photo", [], function(tx, res) {
alert("Nombre d'enregistrements : " + res.rows.length);
var i = 0;
while (i < res.rows.length){
//alert(i);
alert(res.rows.item(i).id);
//alert(res.rows.item(i).datetime());
//alert(res.rows.item(i).asa);
//alert(res.rows.item(i).prenom);
alert(res.rows.item(i).nom);
//alert(res.rows.item(i).interet);
//alert(res.rows.item(i).coor_x);
//alert(res.rows.item(i).coor_y);
//alert(res.rows.item(i).commentaire);
i++;
}
});
});
}
</script>
</body>
</html> |
Partager