Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 2553 Rev 2558
Line 44... Line 44...
44
	private boolean infoOuverte = false;
44
	private boolean infoOuverte = false;
Line 45... Line 45...
45
 
45
 
46
	String valeurCommune = "Bourges"; // j'aurais préféré Bort-les-Orgues
46
	String valeurCommune = "Bourges"; // j'aurais préféré Bort-les-Orgues
47
	LatLng centreFrance = null;
47
	LatLng centreFrance = null;
48
	LatLng pointCommune = null;
48
	LatLng pointCommune = null;
Line 49... Line 49...
49
	String codeCommune = "";
49
	String codeLoc = "";
Line 50... Line 50...
50
 
50
 
51
	int niveauZoom = 6;
51
	int niveauZoom = 6;
Line 95... Line 95...
95
			}
95
			}
96
		}
96
		}
97
	}
97
	}
Line 98... Line 98...
98
	
98
	
-
 
99
	public void obtenirInfosCommunes(LatLng coord) {
-
 
100
		// Remise à zéro des infos restantes d'une ancienne requete
-
 
101
		valeurCommune = ""; 
-
 
102
		codeLoc = "";
99
	public void obtenirInfosCommunes(LatLng coord) {
103
		
100
		oMediateur.obtenirInformationCoord(this, coord.lat(), coord.lng());
104
		oMediateur.obtenirInformationCoord(this, coord.lat(), coord.lng());
Line 101... Line 105...
101
	}
105
	}
102
 
106
 
103
	public void mettreAJourInfos(final LatLng pointNouvelleCommune, String infosComplementaires, int zoom) {
107
	public void mettreAJourInfos(final LatLng pointNouvelleCommune, int zoom) {
104
		GoogleMap mapNulle = null;
108
		GoogleMap mapNulle = null;
105
		if(nmk != null) {
109
		if(nmk != null) {
106
			nmk.setMap(mapNulle);
110
			nmk.setMap(mapNulle);
107
		}
111
		}
108
		pointCommune = pointNouvelleCommune;
112
		pointCommune = pointNouvelleCommune;
109
		nmk = fabriquerMarqueur(pointCommune, infosComplementaires);
113
		nmk = fabriquerMarqueur(pointCommune);
110
		nmk.setMap(map);
114
		nmk.setMap(map);
111
		afficherInfoMarker(nmk);
115
		afficherInfoMarker(nmk, construireContenuInfoMarker(nmk));
112
		recentrerCarte(nmk.getPosition());
116
		recentrerCarte(nmk.getPosition());
Line 113... Line 117...
113
		map.setZoom(zoom);
117
		map.setZoom(zoom);
Line 169... Line 173...
169
	public void fabriquerMarqueurIndication() {
173
	public void fabriquerMarqueurIndication() {
170
		GoogleMap mapNulle = null;
174
		GoogleMap mapNulle = null;
171
		if(nmk != null) {
175
		if(nmk != null) {
172
			nmk.setMap(mapNulle);
176
			nmk.setMap(mapNulle);
173
		}
177
		}
174
		nmk = fabriquerMarqueur(pointCommune,"");
178
		nmk = fabriquerMarqueur(pointCommune);
175
		nmk.setMap(map);
179
		nmk.setMap(map);
176
		info.setContent("<div id=\"info_contenu\">"+
180
		info.setContent("<div id=\"info_contenu\">"+
177
				"Déplacez ce marqueur pour localiser votre observation (commune et coordonnées)<br />"
181
				"Déplacez ce marqueur pour localiser votre observation (commune et coordonnées)<br />"
178
				+"longitude="
182
				+"longitude="
179
				+ Util.tronquerNombrePourAffichage("" + nmk.getPosition().lng(), 5) + "<br />latitude="
183
				+ Util.tronquerNombrePourAffichage("" + nmk.getPosition().lng(), 5) + "<br />latitude="
Line 181... Line 185...
181
		infoOuverte = true;
185
		infoOuverte = true;
182
		info.open(map,nmk);
186
		info.open(map,nmk);
183
	}
187
	}
Line 184... Line 188...
184
 
188
 
185
	public void AfficherMessageAucuneInfos() {
189
	public void AfficherMessageAucuneInfos() {
186
		mettreAJourInfos(centreFrance,"", niveauZoom);
190
		mettreAJourInfos(centreFrance, niveauZoom);
187
		Window.alert("Aucune information pour le nom donné");
191
		Window.alert("Aucune information pour le nom donné");
Line 188... Line 192...
188
	}
192
	}
189
 
193
 
Line 205... Line 209...
205
			return;
209
			return;
206
		} else {
210
		} else {
207
			bouton.addListener("click", new EventCallback() {
211
			bouton.addListener("click", new EventCallback() {
208
				@Override
212
				@Override
209
				public void execute(EventObject e) {
213
				public void execute(EventObject e) {
210
					EntiteGeographiqueObservation infosCommune = new EntiteGeographiqueObservation(codeCommune,valeurCommune,null,null);
214
					EntiteGeographiqueObservation infosCommune = new EntiteGeographiqueObservation(codeLoc,valeurCommune,null,null);
-
 
215
					// TODO: ajouter pays à tout Ceci
211
					infosCommune.setLat(pointCommune.lat()+"");
216
					infosCommune.setLat(pointCommune.lat()+"");
212
					infosCommune.setLon(pointCommune.lng()+"");
217
					infosCommune.setLon(pointCommune.lng()+"");
213
					oMediateur.rafraichirSaisieCommuneObservation(infosCommune);
218
					oMediateur.rafraichirSaisieCommuneObservation(infosCommune);
214
				}
219
				}
215
			});	
220
			});	
Line 252... Line 257...
252
				niveauZoom = infos.getZoom();
257
				niveauZoom = infos.getZoom();
253
			}
258
			}
Line 254... Line 259...
254
 
259
 
255
			String nouvelleValeurCommune = infos.getZoneGeo();
260
			String nouvelleValeurCommune = infos.getZoneGeo();
-
 
261
			valeurCommune = nouvelleValeurCommune;
256
			valeurCommune = nouvelleValeurCommune;
262
			codeLoc = "";
-
 
263
			if(infos.getIdZoneGeo() != null) {
257
			if (infos.getIdZoneGeo() != null) {
264
				if (infos.getPays().equals("FR")) {
258
				codeCommune = Util.convertirChaineZoneGeoVersDepartement(infos.getIdZoneGeo());
265
					codeLoc = Util.convertirChaineZoneGeoVersDepartement(infos.getIdZoneGeo());
259
			} else {
266
				} else {
-
 
267
					codeLoc = infos.getPays();
260
				codeCommune = "";
268
				}
261
			}
269
			}
Line 262... Line 270...
262
			pointCommune = coord;
270
			pointCommune = coord;
263
			
271
			
Line 264... Line 272...
264
			mettreAJourInfos(coord, "", niveauZoom);
272
			mettreAJourInfos(coord, niveauZoom);
265
		}
273
		}
Line 266... Line 274...
266
		
274
		
267
		masquerChargement(false);
275
		masquerChargement(false);
268
	}
276
	}
269
	
277
	
270
	public Marker fabriquerMarqueur(LatLng pointMarqueur, final String texte) {
278
	public Marker fabriquerMarqueur(LatLng pointMarqueur) {
271
		// ajout de marqueurs déplacables, qui affichent une bulle d'information
279
		// ajout de marqueurs déplacables, qui affichent une bulle d'information
Line 272... Line 280...
272
		MarkerOptions options = MarkerOptions.create();
280
		MarkerOptions options = MarkerOptions.create();
Line 273... Line 281...
273
		options.setDraggable(true);
281
		options.setDraggable(true);
274
		options.setPosition(pointMarqueur);
282
		options.setPosition(pointMarqueur);
-
 
283
		final Marker marker = Marker.create(options);
275
		final Marker marker = Marker.create(options);
284
		
276
		
285
		marker.addDragEndListener(new Marker.DragEndHandler() {
277
		marker.addDragEndListener(new Marker.DragEndHandler() {
286
			
Line 278... Line 287...
278
			
287
			@Override
Line 296... Line 305...
296
			public void handle(MouseEvent event) {
305
			public void handle(MouseEvent event) {
297
				if(infoOuverte) {
306
				if(infoOuverte) {
298
					info.close();
307
					info.close();
299
					infoOuverte = false;
308
					infoOuverte = false;
300
				} else {
309
				} else {
301
					afficherInfoMarker(marker);
310
					afficherInfoMarker(marker, construireContenuPartielInfoMarker(marker));
302
					infoOuverte = true;
311
					infoOuverte = true;
303
				}
312
				}
304
			}
313
			}
305
		});
314
		});
306
		return marker;
315
		return marker;
Line 326... Line 335...
326
 
335
 
327
	public boolean isCarteAjoutee() {
336
	public boolean isCarteAjoutee() {
328
		return carteAjoutee;
337
		return carteAjoutee;
Line 329... Line 338...
329
	}
338
	}
330
	
339
	
Line 331... Line 340...
331
	public void afficherInfoMarker(Marker marker) {		
340
	public String construireContenuInfoMarker(Marker marker) {
Line 332... Line 341...
332
		final String htmlBoutonOk = "<br /><button id=\"okMap\" class=\"x-btn-text\" type=\"button\">OK</button>";
341
		final String htmlBoutonOk = "<br /><button id=\"okMap\" class=\"x-btn-text\" type=\"button\">OK</button>";
333
 
342
 
334
		String contenuMarker = "";
343
		String contenuMarker = "";
335
		
344
		
336
		if(valeurCommune == null || valeurCommune.trim().equals("")) {
345
		if(valeurCommune == null || valeurCommune.trim().equals("")) {
337
			if(marker.getPosition().lng() == 0 && marker.getPosition().lat() == 0) {
346
			if(marker.getPosition().lng() == 0 && marker.getPosition().lat() == 0) {
-
 
347
				LatLng point = centreFrance;
338
				LatLng point = centreFrance;
348
				marker.setPosition(point);
339
				marker.setPosition(point);
349
				niveauZoom = 6;
340
				niveauZoom = 6;
350
			}
341
			}
-
 
342
			contenuMarker = "<div id=\"info_contenu\">"+
351
			contenuMarker = 
343
			"Aucun nom de lieu trouvé à cet emplacement <br />"
352
			"<div id=\"info_contenu\">"+
-
 
353
				"Aucun nom de lieu trouvé à cet emplacement <br />"
344
			+"Déplacez ce marqueur pour localiser votre observation (nom de lieu et coordonnées)<br />"
354
				+"Déplacez ce marqueur pour localiser votre observation (nom de lieu et coordonnées)<br />"
-
 
355
				+"longitude="+Util.tronquerNombrePourAffichage(""+marker.getPosition().lng(), 5)+"<br />"
345
			+"longitude="
356
				+"latitude="+Util.tronquerNombrePourAffichage(""+marker.getPosition().lat(), 5)+
346
			+ Util.tronquerNombrePourAffichage("" + marker.getPosition().lng(), 5) + "<br />latitude="
357
			"</div>";
347
			+ Util.tronquerNombrePourAffichage("" + marker.getPosition().lat(), 5) + "</div>";
358
		} else {
348
		} else {
359
			String chaineCommune = valeurCommune + ((codeLoc.isEmpty()) ? "" : " ("+codeLoc+")");
349
			contenuMarker = ""
360
			contenuMarker = 
-
 
361
			"<div id=\"info_contenu\">"+
350
			+valeurCommune+" ("+codeCommune+")<br />"
362
					chaineCommune+"<br />"
Line 351... Line 363...
351
			+"longitude="
363
					+"longitude="+Util.tronquerNombrePourAffichage(""+marker.getPosition().lng(), 5)+"<br />"
-
 
364
					+"latitude="+Util.tronquerNombrePourAffichage(""+marker.getPosition().lat(), 5)+
-
 
365
			"</div>";
-
 
366
		}
-
 
367
		
-
 
368
		return contenuMarker+ htmlBoutonOk;
-
 
369
	}
-
 
370
	
-
 
371
	public String construireContenuPartielInfoMarker(Marker marker) {
-
 
372
		final String htmlBoutonOk = "<br /><button id=\"okMap\" class=\"x-btn-text\" type=\"button\">OK</button>";
-
 
373
 
-
 
374
		String contenuMarker = "";
-
 
375
		
-
 
376
		contenuMarker = 
-
 
377
			"<div id=\"info_contenu\">"+
-
 
378
					"<div class=\"recherche_infos_zone_geo\">"+
-
 
379
						"<div class=\"recherche_infos_zone_geo_en_cours\">"+
-
 
380
							"<img src=\"chargement_carte.gif\" />"+
-
 
381
							"<div>"+
-
 
382
								"Recherche du nom de lieu en cours... <br />"+
-
 
383
								"Cela peut prendre un moment"+
-
 
384
							"</div>"+
-
 
385
							"<hr class=\"nettoyage\" />"+
-
 
386
						"</div>"+
-
 
387
						"Si vous ne désirez que les coordonnées, vous pouvez cliquer dès maintenant sur OK"+
-
 
388
					"</div>"+
-
 
389
					"longitude="+Util.tronquerNombrePourAffichage("" + marker.getPosition().lng(), 5)+"<br />"+
-
 
390
					"latitude="+Util.tronquerNombrePourAffichage("" + marker.getPosition().lat(), 5)+
-
 
391
			"</div>";
-
 
392
		
-
 
393
		return contenuMarker+ htmlBoutonOk;
352
			+ Util.tronquerNombrePourAffichage("" + marker.getPosition().lng(), 5) + "<br />latitude="
394
	}
-
 
395
	
-
 
396
	public void afficherInfoMarker(Marker marker, String contenuInfo) {		
Line 353... Line 397...
353
			+ Util.tronquerNombrePourAffichage("" + marker.getPosition().lat(), 5) ;
397
 
354
		}
398
		info.setContent(contenuInfo);
355
		
399
		info.open(map, marker);
356
		info.setContent(contenuMarker+ htmlBoutonOk);
400
		
357
		info.open(map, marker);	
401
		pointCommune = marker.getPosition();
358
		
402
		
Line 359... Line 403...
359
		info.addDomReadyListenerOnce(new InfoWindow.DomReadyHandler() {	
403
		info.addDomReadyListenerOnce(new InfoWindow.DomReadyHandler() {	
360
			@Override
404
			@Override
-
 
405
			public void handle() {
-
 
406
				ajouterListenerBouton("okMap");
-
 
407
			}
-
 
408
		});
-
 
409
		
-
 
410
		recentrerCarte(marker.getPosition());
Line 361... Line 411...
361
			public void handle() {
411
	}
362
				ajouterListenerBouton("okMap");
412
	
363
			}
413
	public void afficherCarteEnAttenteAvecMarker(double lat, double lon) {
364
		});
414
		pointCommune = LatLng.create(lat, lon);