Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 1250 Rev 1256
Line 167... Line 167...
167
//+----------------------------------------------------------------------------------------------------------+
167
//+----------------------------------------------------------------------------------------------------------+
168
// GOOGLE MAP
168
// GOOGLE MAP
169
var geocoder;
169
var geocoder;
170
var map;
170
var map;
171
var marker;
171
var marker;
-
 
172
var markerFin;
172
var latLng;
173
var latLng;
-
 
174
var latLngFin;
-
 
175
var ligneRue;
-
 
176
var premierDeplacement = true;
Line 173... Line 177...
173
 
177
 
174
function initialiserGoogleMap(){
178
function initialiserGoogleMap(){
175
	// Carte
179
	// Carte
176
	var latLng = new google.maps.LatLng(48.8543, 2.3483);// Paris
180
	latLng = new google.maps.LatLng(48.8543, 2.3483);// Paris
177
	if (VILLE == 'Marseille') {
181
	if (VILLE == 'Marseille') {
178
		latLng = new google.maps.LatLng(43.29545, 5.37458);
182
		latLng = new google.maps.LatLng(43.29545, 5.37458);
179
	} else if (VILLE == 'Montpellier') {
183
	} else if (VILLE == 'Montpellier') {
180
		latLng = new google.maps.LatLng(43.61077, 3.87672);
184
		latLng = new google.maps.LatLng(43.61077, 3.87672);
Line 210... Line 214...
210
 
214
 
211
	// Marqueur google draggable
215
	// Marqueur google draggable
212
	marker = new google.maps.Marker({
216
	marker = new google.maps.Marker({
213
		map: map,
217
		map: map,
214
		draggable: true,
218
		draggable: true,
215
		title: 'Ma station',
219
		title: 'Début de la rue',
216
		icon: GOOGLE_MAP_MARQUEUR_URL,
220
		icon: GOOGLE_MAP_MARQUEUR_URL,
217
		position: latLng
221
		position: latLng
Line 218... Line 222...
218
	});
222
	});
Line 260... Line 264...
260
				}
264
				}
261
			});
265
			});
262
		},
266
		},
263
		// Cette partie est executee a la selection d'une adresse
267
		// Cette partie est executee a la selection d'une adresse
264
		select: function(event, ui) {
268
		select: function(event, ui) {
265
			var latLng = new google.maps.LatLng(ui.item.latitude, ui.item.longitude);
269
			latLng = new google.maps.LatLng(ui.item.latitude, ui.item.longitude);
266
			deplacerMarker(latLng);
270
			deplacerMarker(latLng);
267
		}
271
		}
268
	});
272
	});
Line 269... Line 273...
269
	
273
	
Line 275... Line 279...
275
	});
279
	});
Line 276... Line 280...
276
	
280
	
277
	google.maps.event.addListener(marker, 'dragend', function() {
281
	google.maps.event.addListener(marker, 'dragend', function() {
278
		trouverCommune(marker.getPosition());
282
		trouverCommune(marker.getPosition());
-
 
283
		mettreAJourMarkerPosition(marker.getPosition());
279
		mettreAJourMarkerPosition(marker.getPosition());
284
		deplacerMarker(marker.getPosition());
Line 280... Line 285...
280
	});
285
	});
281
	
286
	
282
	google.maps.event.addListener(map, 'click', function(event) {
287
	google.maps.event.addListener(map, 'click', function(event) {
Line 297... Line 302...
297
function deplacerMarker(latLng) {
302
function deplacerMarker(latLng) {
298
	if (marker != undefined) {
303
	if (marker != undefined) {
299
		marker.setPosition(latLng);
304
		marker.setPosition(latLng);
300
		map.setCenter(latLng);
305
		map.setCenter(latLng);
301
		//map.setZoom(18);
306
		//map.setZoom(18);
302
		mettreAJourMarkerPosition(latLng);
-
 
303
		trouverCommune(latLng);
307
		trouverCommune(latLng);
-
 
308
		
-
 
309
		if(!premierDeplacement) {
-
 
310
			if(markerFin != undefined) {
-
 
311
				markerFin.setMap(null);
-
 
312
			}
-
 
313
			
-
 
314
			latLngFin = new google.maps.LatLng(latLng.lat(), latLng.lng() - 0.0002);
-
 
315
			// Marqueur google draggable
-
 
316
			markerFin = new google.maps.Marker({
-
 
317
				map: map,
-
 
318
				draggable: true,
-
 
319
				title: 'Fin de la rue',
-
 
320
				icon: FIN_ICONE_URL,
-
 
321
				position: latLngFin
-
 
322
			});
-
 
323
			
-
 
324
			google.maps.event.addListener(markerFin, 'dragend', function() {
-
 
325
				dessinerLigneRue(marker.getPosition(), markerFin.getPosition());
-
 
326
				latLngFin = markerFin.getPosition();
-
 
327
				latLngCentre = new google.maps.LatLng((latLngFin.lat() + latLng.lat())/2, (latLngFin.lng() + latLng.lng())/2); 
-
 
328
				mettreAJourMarkerPosition(latLngCentre);
-
 
329
			});
-
 
330
			
-
 
331
			dessinerLigneRue(latLng, latLngFin);
-
 
332
			
-
 
333
			latLngCentre = new google.maps.LatLng((latLngFin.lat() + latLng.lat())/2, (latLngFin.lng() + latLng.lng())/2); 
-
 
334
			mettreAJourMarkerPosition(latLng);
-
 
335
		} else {
-
 
336
			mettreAJourMarkerPosition(latLng);
-
 
337
		}
-
 
338
		premierDeplacement = false;
304
	}
339
	}
305
}
340
}
Line -... Line 341...
-
 
341
 
-
 
342
function dessinerLigneRue(pointDebut, pointFin) {
-
 
343
	if(ligneRue != undefined) {
-
 
344
		ligneRue.setMap(null);
-
 
345
	}
-
 
346
	
-
 
347
	ligneRue = new google.maps.Polyline({
-
 
348
	    path: [pointDebut, pointFin],
-
 
349
	    strokeColor: "#FF0000",
-
 
350
	    strokeOpacity: 1.0,
-
 
351
	    strokeWeight: 2
-
 
352
	  });
-
 
353
 
-
 
354
	ligneRue.setMap(map);
-
 
355
}
306
 
356
 
307
function mettreAJourMarkerPosition(latLng) {
357
function mettreAJourMarkerPosition(latLng) {
308
	var lat = latLng.lat().toFixed(5);
358
	var lat = latLng.lat().toFixed(5);
309
	var lng = latLng.lng().toFixed(5); 
359
	var lng = latLng.lng().toFixed(5); 
310
	remplirChampLatitude(lat);
360
	remplirChampLatitude(lat);
Line 400... Line 450...
400
			courriel_confirmation : {
450
			courriel_confirmation : {
401
				required : true,
451
				required : true,
402
				equalTo: "#courriel"
452
				equalTo: "#courriel"
403
			},
453
			},
404
			rue : "required",
454
			rue : "required",
405
			rue_num_debut : {
-
 
406
				required : true,
-
 
407
				digits : true,
-
 
408
				min : 1},
-
 
409
			rue_num_fin : {
-
 
410
				required : true,
-
 
411
				digits : true,
-
 
412
				min : 1},
-
 
413
			rue_cote : "required",
455
			rue_cote : "required",
414
			milieu : "required",
456
			milieu : "required",
415
			latitude : {
457
			latitude : {
416
				required: true,
458
				required: true,
417
				range: [-90, 90]},
459
				range: [-90, 90]},
Line 474... Line 516...
474
				'latitude' : $("#latitude").val(),
516
				'latitude' : $("#latitude").val(),
475
				'longitude' : $("#longitude").val(),
517
				'longitude' : $("#longitude").val(),
476
				'commune_nom' : $("#commune-nom").text(),
518
				'commune_nom' : $("#commune-nom").text(),
477
				'commune_code_insee' : $("#commune-code-insee").text(),
519
				'commune_code_insee' : $("#commune-code-insee").text(),
478
				'lieudit' : $("#rue").val(),
520
				'lieudit' : $("#rue").val(),
479
				'station' : $("#rue_num_debut").val()+'-'+$("#rue_num_fin").val()+'-'+$("#rue_cote").val(),
521
				'station' : latLng.lat().toFixed(5)+','+latLng.lng().toFixed(5)+';'+latLngFin.lat().toFixed(5)+','+latLngFin.lng().toFixed(5)+';'+$("#rue_cote").val(),
480
				'notes' : $("#notes").val(),
522
				'notes' : $("#notes").val(),
481
				//Ajout des champs images
523
				//Ajout des champs images
482
				'image_nom' : $("#miniature-img").attr('alt'),
524
				'image_nom' : $("#miniature-img").attr('alt'),
483
				'image_b64' : getB64ImgOriginal()
525
				'image_b64' : getB64ImgOriginal()
484
			});
526
			});