9,6 → 9,7 |
import com.google.gwt.maps.client.MapType; |
import com.google.gwt.maps.client.MapWidget; |
import com.google.gwt.maps.client.control.LargeMapControl; |
import com.google.gwt.maps.client.event.InfoWindowRestoreEndHandler; |
import com.google.gwt.maps.client.event.MapZoomEndHandler; |
import com.google.gwt.maps.client.event.MarkerClickHandler; |
import com.google.gwt.maps.client.event.MarkerDragEndHandler; |
18,6 → 19,7 |
import com.google.gwt.maps.client.geom.LatLng; |
import com.google.gwt.maps.client.overlay.Marker; |
import com.google.gwt.maps.client.overlay.MarkerOptions; |
import com.google.gwt.user.client.Timer; |
import com.google.gwt.user.client.Window; |
import com.google.gwt.user.client.ui.HTML; |
import com.gwtext.client.core.EventCallback; |
62,6 → 64,8 |
|
private InfoWindow info; |
|
private boolean listenerInitialise = false; |
|
public CartographieObservationVue(ObservationMediateur om) { |
oMediateur = om; |
|
83,7 → 87,7 |
public void onAfterLayout(Container c) { |
|
if(!carteAjoutee) { |
initialiserCarte(); |
initialiserCarte(false); |
} |
recentrerCarte(); |
} |
115,7 → 119,7 |
public void mettreAJourInfos(final LatLng pointNouvelleCommune, String infosComplementaires, int zoom) { |
|
if (!carteAjoutee) { |
initialiserCarte(); |
initialiserCarte(true); |
} |
|
pointCommune = pointNouvelleCommune; |
126,12 → 130,15 |
recentrerCarte(); |
} |
|
public void initialiserCarte() { |
public void initialiserCarte(boolean commune) { |
|
map = new MapWidget(pointCommune, niveauZoom); |
panneauCarto.add(map); |
panneauCarto.doLayout(); |
info = map.getInfoWindow(); |
if(!commune) { |
fabriquerMarqueurIndication(); |
} |
map.checkResizeAndCenter(); |
map.setUIToDefault(); |
map.addControl(new LargeMapControl()); |
147,6 → 154,17 |
|
}); |
} |
|
public void fabriquerMarqueurIndication() { |
Marker marker = fabriquerMarqueur(pointCommune,""); |
map.addOverlay(marker); |
info.open(marker, new InfoWindowContent("<div id=\"info_contenu\">"+ |
"Déplacez ce marqueur pour localiser votre observation (commune et coordonnées)<br />" |
+"longitude=" |
+ marker.getLatLng().getLongitude() + "<br />latitude=" |
+ marker.getLatLng().getLatitude() + "</div>")); |
map.setZoomLevel(3); |
} |
|
public void AfficherMessageAucuneInfos() { |
mettreAJourInfos(centreFrance,"", niveauZoom); |
157,11 → 175,22 |
return niveauZoom; |
} |
|
private void ajouterListenerBouton(String idBouton) { |
ExtElement bouton = Ext.get(idBouton); |
|
private void ajouterListenerBouton(final String idBouton) { |
|
final ExtElement bouton = Ext.get(idBouton); |
|
if(bouton == null) { |
Timer t = new Timer() { |
public void run() { |
ajouterListenerBouton(idBouton); |
} |
|
}; |
t.schedule(500); |
return; |
} |
|
bouton.addListener("click", new EventCallback() { |
|
public void execute(EventObject e) { |
EntiteGeographiqueObservation infosCommune = new EntiteGeographiqueObservation(codeCommune,valeurCommune,null,null); |
infosCommune.setLat(pointCommune.getLatitude()+""); |
168,8 → 197,9 |
infosCommune.setLon(pointCommune.getLongitude()+""); |
oMediateur.rafraichirSaisieCommuneObservation(infosCommune); |
} |
|
}); |
}); |
|
bouton.focus(); |
} |
|
public void rafraichir(Object nouvelleDonnees, |
181,14 → 211,15 |
} |
} |
|
if (nouvelleDonnees instanceof Object[]) { |
if (nouvelleDonnees instanceof EntiteGeographiqueObservation) { |
|
Object[] infos = (Object[]) nouvelleDonnees; |
LatLng coord = LatLng.newInstance((Double) infos[0], |
(Double) infos[1]); |
EntiteGeographiqueObservation infos = (EntiteGeographiqueObservation) nouvelleDonnees; |
LatLng coord = LatLng.newInstance(Double.parseDouble(infos.getLat()), |
Double.parseDouble(infos.getLon())); |
|
valeurCommune = (String)infos[3]; |
codeCommune = (String)infos[2]; |
valeurCommune = infos.getCommune(); |
codeCommune = infos.getIdLocalite(); |
pointCommune = coord; |
|
mettreAJourInfos(coord, "", niveauZoom); |
} |
230,7 → 261,6 |
} |
|
public void recentrerCarte() { |
//mettreAJourInfos(pointCommune,"", niveauZoom); |
map.setSize((this.getWidth() - 12)+"px" , (this.getHeight() - 24)+"px"); |
panneauCarto.setSize((this.getWidth() - 12)+"px" , (this.getHeight() - 12)+"px"); |
map.setCenter(pointCommune, niveauZoom); |
242,6 → 272,7 |
} |
|
public void afficherInfoMarker(Marker marker) { |
|
final String htmlBoutonOk = "<br /><button id=\"okMap\" class=\"x-btn-text\" type=\"button\">OK</button>"; |
|
info.open(marker, new InfoWindowContent("" |
249,7 → 280,8 |
+"longitude=" |
+ marker.getLatLng().getLongitude() + "<br />latitude=" |
+ marker.getLatLng().getLatitude() + htmlBoutonOk)); |
|
|
recentrerCarte(); |
ajouterListenerBouton("okMap"); |
} |
|