Subversion Repositories eFlore/Applications.cel

Rev

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

Rev 264 Rev 268
Line 7... Line 7...
7
import com.google.gwt.maps.client.InfoWindow;
7
import com.google.gwt.maps.client.InfoWindow;
8
import com.google.gwt.maps.client.InfoWindowContent;
8
import com.google.gwt.maps.client.InfoWindowContent;
9
import com.google.gwt.maps.client.MapType;
9
import com.google.gwt.maps.client.MapType;
10
import com.google.gwt.maps.client.MapWidget;
10
import com.google.gwt.maps.client.MapWidget;
11
import com.google.gwt.maps.client.control.LargeMapControl;
11
import com.google.gwt.maps.client.control.LargeMapControl;
-
 
12
import com.google.gwt.maps.client.event.InfoWindowRestoreEndHandler;
12
import com.google.gwt.maps.client.event.MapZoomEndHandler;
13
import com.google.gwt.maps.client.event.MapZoomEndHandler;
13
import com.google.gwt.maps.client.event.MarkerClickHandler;
14
import com.google.gwt.maps.client.event.MarkerClickHandler;
14
import com.google.gwt.maps.client.event.MarkerDragEndHandler;
15
import com.google.gwt.maps.client.event.MarkerDragEndHandler;
15
import com.google.gwt.maps.client.event.MarkerDragStartHandler;
16
import com.google.gwt.maps.client.event.MarkerDragStartHandler;
16
import com.google.gwt.maps.client.event.MarkerDragEndHandler.MarkerDragEndEvent;
17
import com.google.gwt.maps.client.event.MarkerDragEndHandler.MarkerDragEndEvent;
17
import com.google.gwt.maps.client.event.MarkerDragStartHandler.MarkerDragStartEvent;
18
import com.google.gwt.maps.client.event.MarkerDragStartHandler.MarkerDragStartEvent;
18
import com.google.gwt.maps.client.geom.LatLng;
19
import com.google.gwt.maps.client.geom.LatLng;
19
import com.google.gwt.maps.client.overlay.Marker;
20
import com.google.gwt.maps.client.overlay.Marker;
20
import com.google.gwt.maps.client.overlay.MarkerOptions;
21
import com.google.gwt.maps.client.overlay.MarkerOptions;
-
 
22
import com.google.gwt.user.client.Timer;
21
import com.google.gwt.user.client.Window;
23
import com.google.gwt.user.client.Window;
22
import com.google.gwt.user.client.ui.HTML;
24
import com.google.gwt.user.client.ui.HTML;
23
import com.gwtext.client.core.EventCallback;
25
import com.gwtext.client.core.EventCallback;
24
import com.gwtext.client.core.EventObject;
26
import com.gwtext.client.core.EventObject;
25
import com.gwtext.client.core.Ext;
27
import com.gwtext.client.core.Ext;
Line 60... Line 62...
60
	Label panneauExplication = new Label(
62
	Label panneauExplication = new Label(
61
			"Précisez le lieu de votre observation et cliquez sur OK. Les coordonnées sont données en degrés décimaux, comptés positivement vers le Nord pour la latitude, et vers l'Est pour la longitude");
63
			"Précisez le lieu de votre observation et cliquez sur OK. Les coordonnées sont données en degrés décimaux, comptés positivement vers le Nord pour la latitude, et vers l'Est pour la longitude");
Line 62... Line 64...
62
 
64
 
Line -... Line 65...
-
 
65
	private InfoWindow info;
-
 
66
 
63
	private InfoWindow info;
67
	private boolean listenerInitialise = false;
64
 
68
 
Line 65... Line 69...
65
	public CartographieObservationVue(ObservationMediateur om) {
69
	public CartographieObservationVue(ObservationMediateur om) {
66
		oMediateur = om;
70
		oMediateur = om;
Line 81... Line 85...
81
		
85
		
82
		addListener(new ContainerListenerAdapter() {
86
		addListener(new ContainerListenerAdapter() {
Line 83... Line 87...
83
			public void onAfterLayout(Container c) {
87
			public void onAfterLayout(Container c) {
84
				
88
				
85
				if(!carteAjoutee) {
89
				if(!carteAjoutee) {
86
					initialiserCarte();
90
					initialiserCarte(false);
87
				}
91
				}
88
				recentrerCarte();
92
				recentrerCarte();
Line 113... Line 117...
113
	}
117
	}
Line 114... Line 118...
114
 
118
 
Line 115... Line 119...
115
	public void mettreAJourInfos(final LatLng pointNouvelleCommune, String infosComplementaires, int zoom) {
119
	public void mettreAJourInfos(final LatLng pointNouvelleCommune, String infosComplementaires, int zoom) {
116
 
120
 
117
		if (!carteAjoutee) {
121
		if (!carteAjoutee) {
Line 118... Line 122...
118
			initialiserCarte();
122
			initialiserCarte(true);
119
		}
123
		}
120
 
124
 
121
		pointCommune = pointNouvelleCommune;
125
		pointCommune = pointNouvelleCommune;
122
		map.clearOverlays();
126
		map.clearOverlays();
123
		Marker nmk = fabriquerMarqueur(pointCommune, infosComplementaires);
127
		Marker nmk = fabriquerMarqueur(pointCommune, infosComplementaires);
124
		map.addOverlay(nmk);
128
		map.addOverlay(nmk);
Line 125... Line 129...
125
		afficherInfoMarker(nmk);
129
		afficherInfoMarker(nmk);
Line 126... Line 130...
126
		recentrerCarte();
130
		recentrerCarte();
127
	}
131
	}
128
 
132
 
129
	public void initialiserCarte() {
133
	public void initialiserCarte(boolean commune) {
-
 
134
 
-
 
135
		map = new MapWidget(pointCommune, niveauZoom);
-
 
136
		panneauCarto.add(map);
130
 
137
		panneauCarto.doLayout();
131
		map = new MapWidget(pointCommune, niveauZoom);
138
		info = map.getInfoWindow();
132
		panneauCarto.add(map);
139
		if(!commune) {
133
		panneauCarto.doLayout();
140
			fabriquerMarqueurIndication();
134
		info = map.getInfoWindow();
141
		}
Line 145... Line 152...
145
				niveauZoom = event.getNewZoomLevel();
152
				niveauZoom = event.getNewZoomLevel();
146
			}
153
			}
Line 147... Line 154...
147
			
154
			
148
		});
155
		});
-
 
156
	}
-
 
157
	
-
 
158
	public void fabriquerMarqueurIndication() {
-
 
159
		Marker marker = fabriquerMarqueur(pointCommune,"");
-
 
160
		map.addOverlay(marker);		
-
 
161
		info.open(marker, new InfoWindowContent("<div id=\"info_contenu\">"+
-
 
162
				"Déplacez ce marqueur pour localiser votre observation (commune et coordonnées)<br />"
-
 
163
				+"longitude="
-
 
164
				+ marker.getLatLng().getLongitude() + "<br />latitude="
-
 
165
				+ marker.getLatLng().getLatitude() + "</div>"));
-
 
166
		map.setZoomLevel(3);
Line 149... Line 167...
149
	}
167
	}
150
 
168
 
151
	public void AfficherMessageAucuneInfos() {
169
	public void AfficherMessageAucuneInfos() {
152
		mettreAJourInfos(centreFrance,"", niveauZoom);
170
		mettreAJourInfos(centreFrance,"", niveauZoom);
Line 153... Line 171...
153
		Window.alert("Aucune information pour le nom donné");
171
		Window.alert("Aucune information pour le nom donné");
154
	}
172
	}
155
 
173
 
Line 156... Line 174...
156
	public int getNiveauZoom() {
174
	public int getNiveauZoom() {
-
 
175
		return niveauZoom;
157
		return niveauZoom;
176
	}
-
 
177
	
-
 
178
	private void ajouterListenerBouton(final String idBouton) {
-
 
179
		
-
 
180
		final ExtElement bouton = Ext.get(idBouton);
-
 
181
		
-
 
182
		if(bouton == null) {
-
 
183
			Timer t = new Timer() {
-
 
184
				public void run() {
-
 
185
					ajouterListenerBouton(idBouton);
-
 
186
				}
-
 
187
				
158
	}
188
			};
159
	
189
			t.schedule(500);
160
	private void ajouterListenerBouton(String idBouton) {
-
 
161
		ExtElement bouton = Ext.get(idBouton);
190
			return;
162
 
191
		}
163
		bouton.addListener("click", new EventCallback() {
192
		
164
 
193
		bouton.addListener("click", new EventCallback() {
165
			public void execute(EventObject e) {
194
			public void execute(EventObject e) {
166
				EntiteGeographiqueObservation infosCommune = new EntiteGeographiqueObservation(codeCommune,valeurCommune,null,null);
195
				EntiteGeographiqueObservation infosCommune = new EntiteGeographiqueObservation(codeCommune,valeurCommune,null,null);
-
 
196
				infosCommune.setLat(pointCommune.getLatitude()+"");
167
				infosCommune.setLat(pointCommune.getLatitude()+"");
197
				infosCommune.setLon(pointCommune.getLongitude()+"");
168
				infosCommune.setLon(pointCommune.getLongitude()+"");
198
				oMediateur.rafraichirSaisieCommuneObservation(infosCommune);
169
				oMediateur.rafraichirSaisieCommuneObservation(infosCommune);
199
			}
Line 170... Line 200...
170
			}
200
		});	
171
 
201
		
172
		});
202
		bouton.focus();
Line 179... Line 209...
179
			if(isVisible()) {
209
			if(isVisible()) {
180
				Window.alert((String)nouvelleDonnees);
210
				Window.alert((String)nouvelleDonnees);
181
			}
211
			}
182
		}
212
		}
Line 183... Line 213...
183
 
213
 
Line 184... Line 214...
184
		if (nouvelleDonnees instanceof Object[]) {
214
		if (nouvelleDonnees instanceof EntiteGeographiqueObservation) {
185
			
215
			
186
			Object[] infos = (Object[]) nouvelleDonnees;
216
			EntiteGeographiqueObservation infos = (EntiteGeographiqueObservation) nouvelleDonnees;
Line 187... Line 217...
187
			LatLng coord = LatLng.newInstance((Double) infos[0],
217
			LatLng coord = LatLng.newInstance(Double.parseDouble(infos.getLat()),
188
					(Double) infos[1]);
218
					Double.parseDouble(infos.getLon()));
-
 
219
			
Line 189... Line 220...
189
			
220
			valeurCommune = infos.getCommune();
190
			valeurCommune = (String)infos[3];
221
			codeCommune = infos.getIdLocalite();
Line 191... Line 222...
191
			codeCommune = (String)infos[2];
222
			pointCommune = coord;
Line 228... Line 259...
228
		
259
		
229
		return marker;
260
		return marker;
Line 230... Line 261...
230
	}
261
	}
231
 
-
 
232
	public void recentrerCarte() {
262
 
233
		//mettreAJourInfos(pointCommune,"", niveauZoom);
263
	public void recentrerCarte() {
234
		map.setSize((this.getWidth() - 12)+"px" , (this.getHeight() - 24)+"px");
264
		map.setSize((this.getWidth() - 12)+"px" , (this.getHeight() - 24)+"px");
235
		panneauCarto.setSize((this.getWidth() - 12)+"px" , (this.getHeight() - 12)+"px");
265
		panneauCarto.setSize((this.getWidth() - 12)+"px" , (this.getHeight() - 12)+"px");
236
		map.setCenter(pointCommune, niveauZoom);
266
		map.setCenter(pointCommune, niveauZoom);
Line 240... Line 270...
240
	public boolean isCarteAjoutee() {
270
	public boolean isCarteAjoutee() {
241
		return carteAjoutee;
271
		return carteAjoutee;
242
	}
272
	}
Line 243... Line 273...
243
	
273
	
-
 
274
	public void afficherInfoMarker(Marker marker) {
244
	public void afficherInfoMarker(Marker marker) {
275
		
Line 245... Line 276...
245
		final String htmlBoutonOk = "<br /><button id=\"okMap\" class=\"x-btn-text\" type=\"button\">OK</button>";
276
		final String htmlBoutonOk = "<br /><button id=\"okMap\" class=\"x-btn-text\" type=\"button\">OK</button>";
246
 
277
 
247
		info.open(marker, new InfoWindowContent(""
278
		info.open(marker, new InfoWindowContent(""
248
				+valeurCommune+" ("+codeCommune+")<br />"
279
				+valeurCommune+" ("+codeCommune+")<br />"
249
				+"longitude="
280
				+"longitude="
250
				+ marker.getLatLng().getLongitude() + "<br />latitude="
281
				+ marker.getLatLng().getLongitude() + "<br />latitude="
-
 
282
				+ marker.getLatLng().getLatitude() + htmlBoutonOk));
251
				+ marker.getLatLng().getLatitude() + htmlBoutonOk));
283
		
252
 
284
		recentrerCarte();
Line 253... Line 285...
253
		ajouterListenerBouton("okMap");
285
		ajouterListenerBouton("okMap");