Subversion Repositories eFlore/Applications.cel

Rev

Rev 2117 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2117 Rev 2256
Line 134... Line 134...
134
	return false;
134
	return false;
135
}
135
}
Line 136... Line 136...
136
 
136
 
137
//+----------------------------------------------------------------------------------------------------------+
137
//+----------------------------------------------------------------------------------------------------------+
138
//GOOGLE MAP => OK
-
 
139
 
138
//GOOGLE MAP => OK
140
var map,
139
var map,
141
	geocoder,	
140
	geocoder,	
142
	markerDeb,
141
	markerDeb,
143
	latLngDeb,
142
	latLngDeb,
Line 243... Line 242...
243
	
242
	
244
	// Lorsque la carte est chargée, on vérifie si on peut précharger des données
243
	// Lorsque la carte est chargée, on vérifie si on peut précharger des données
245
	google.maps.event.addListenerOnce(map, 'idle', function(){
244
	google.maps.event.addListenerOnce(map, 'idle', function(){
246
		// Initialisation du marker de début de rue
245
		// Initialisation du marker de début de rue
-
 
246
		initialiserMarkerDeb();
-
 
247
		if (OBS_ID != '') {
-
 
248
			chargerInfoObs();
247
		initialiserMarkerDeb();
249
		} else {
248
		// Tentative de geocalisation si aucune obs à précharger
250
			// Tentative de geocalisation si aucune obs à précharger
-
 
251
			tenterGeolocalisation();
249
		tenterGeolocalisation();
252
		}
Line 250... Line 253...
250
	});
253
	});
251
	
254
	
252
	// Création du Geocoder
255
	// Création du Geocoder
Line -... Line 256...
-
 
256
	geocoder = new google.maps.Geocoder();
-
 
257
}
-
 
258
 
-
 
259
function chargerInfoObs() {
-
 
260
	var urlObs = SERVICE_OBS_URL + '/' + OBS_ID;
-
 
261
	$.ajax({
-
 
262
		url: urlObs,
-
 
263
		type: 'GET',
-
 
264
		success: function(data, textStatus, jqXHR) {
-
 
265
			if (data != undefined && data != "") {
-
 
266
				prechargerForm(data);
-
 
267
			} 
-
 
268
			// TODO: voir s'il est pertinent d'indiquer quelque chose en cas d'erreur ou d'obs
-
 
269
			// inexistante 
-
 
270
		},
-
 
271
		error: function(jqXHR, textStatus, errorThrown) {
-
 
272
			// TODO: cf TODO ci-dessus
-
 
273
		}
-
 
274
	});
-
 
275
}
-
 
276
 
-
 
277
function prechargerForm(data) {
-
 
278
	
-
 
279
    $('#carte-recherche').val(data.zoneGeo);
-
 
280
    
-
 
281
	$('#commune-nom').text(data.zoneGeo);
-
 
282
	$('#commune-code-insee').text(data.codeZoneGeo.replace('INSEE-C:', ''));
-
 
283
	
-
 
284
    pos = new google.maps.LatLng(data.latitude, data.longitude); 
-
 
285
    
-
 
286
    if(data.hasOwnProperty("extension")) {
-
 
287
    	initialiserMarkerFin();
-
 
288
    	
-
 
289
    	// cas des obs florilèges qui apparaissent aussi comme des obs sauvages
-
 
290
    	// mais qui n'ont pas de coté de rue
-
 
291
    	if(data.extension.hasOwnProperty("coteRue")) {
-
 
292
    		$('#rue_cote option[value='+data.extension.coteRue.valeur+']').attr("selected", "selected");
-
 
293
    	}
-
 
294
	        
-
 
295
	    deb = new google.maps.LatLng(data.extension.latitudeDebutRue.valeur, data.extension.longitudeDebutRue.valeur);
-
 
296
	    fin = new google.maps.LatLng(data.extension.latitudeFinRue.valeur, data.extension.longitudeFinRue.valeur);
-
 
297
	    
-
 
298
	    mettreAJourStationPosition(pos);
-
 
299
	    
-
 
300
	    deplacerMarkerDeb(deb);
-
 
301
	    deplacerMarkerFin(fin);
-
 
302
	    afficherEtapeGeolocalisation(4);
-
 
303
	    
-
 
304
	    var latlngbounds = new google.maps.LatLngBounds();
-
 
305
	    latlngbounds.extend(deb);
-
 
306
	    latlngbounds.extend(fin);
-
 
307
	    map.setCenter(latlngbounds.getCenter());
-
 
308
	    map.fitBounds(latlngbounds); 
-
 
309
    } else if(data.hasOwnProperty("latitude") && data.hasOwnProperty("longitude")) {
-
 
310
    	deplacerMarkerDeb(pos);
253
	geocoder = new google.maps.Geocoder();
311
    }
254
}
312
}
255
 
313
 
256
function initialiserMarkerDeb() {
314
function initialiserMarkerDeb() {
257
	premierDeplacement = true;
315
	premierDeplacement = true;
Line 292... Line 350...
292
		initialiserMarkerDeb();
350
		initialiserMarkerDeb();
293
		premierDeplacement = false;
351
		premierDeplacement = false;
294
	} else {
352
	} else {
295
		var nouvellePositionFin = new google.maps.LatLng(latLngDeb.lat(), latLngDeb.lng() + 0.0010);
353
		var nouvellePositionFin = new google.maps.LatLng(latLngDeb.lat(), latLngDeb.lng() + 0.0010);
296
		initialiserMarkerFin();
354
		initialiserMarkerFin();
297
		deplacerMakerFin(nouvellePositionFin)
355
		deplacerMarkerFin(nouvellePositionFin)
298
		afficherEtapeGeolocalisation(3);
356
		afficherEtapeGeolocalisation(3);
299
	}
357
	}
300
}
358
}
Line 301... Line 359...
301
 
359
 
Line 312... Line 370...
312
	} else {
370
	} else {
313
		markerFin.setMap(null);
371
		markerFin.setMap(null);
314
	}
372
	}
315
}
373
}
Line 316... Line 374...
316
 
374
 
317
function deplacerMakerFin(nouvellePosition) {
375
function deplacerMarkerFin(nouvellePosition) {
318
	latLngFin = nouvellePosition;
376
	latLngFin = nouvellePosition;
319
	markerFin.setMap(map);
377
	markerFin.setMap(map);
320
	markerFin.setPosition(latLngFin);
378
	markerFin.setPosition(latLngFin);
321
	dessinerLigneRue(latLngDeb, latLngFin);
379
	dessinerLigneRue(latLngDeb, latLngFin);