Hello NG!
I'm stuck on a ajax query.
i use a mapwidget and a marker.
when i click on the marker(i extended marker and call it BioMarker, but
functions of super, are still supported) i open a infowindow.
while opening the window i am querying a php script and load some data.
this data needs to be assigned to the marker and updated into the
infowindow.
how i tried to achieve this
here is the markerClickHandler:
----------------------------------------
marker.addMarkerClickHandler(new MarkerClickHandler() {
public void onClick(MarkerClickEvent event) {
BioMarker marker = (BioMarker)
event.getSender();
// now try to update altitude
Ajax ajax = new Ajax(mapWidget, marker);
// end try
mapWidget.getInfoWindow().open(event.getSender(),
marker.getInfoWindowContent());
}
});
----------------------------------------
further the implementation of Ajax (workaround to be able to pass the
marker)
public class Ajax {
private BioMarker sender;
private MapWidget mapWidget;
public Ajax(MapWidget mapWidget, BioMarker sender) {
this.sender = sender;
this.mapWidget = mapWidget;
this.get();
}
public void notifySender(String altitude) {
this.sender.setAltitude(Integer.parseInt(altitude));
this.mapWidget.getInfoWindow().close();
Window.alert("new altitude set to :"+this.sender.getAltitude());
this.mapWidget.getInfoWindow().open(sender,
sender.getInfoWindowContent());
}
private void get() {
String postData = "longitude=" + this.sender.getLongitude()
+ "&latitude=" + this.sender.getLatitude();
RequestBuilder rb = new RequestBuilder(RequestBuilder.GET,
BioMapModule.ROOT + "topocoding.php?" + postData);
Maps.logWrite("ajaxing on: " + rb.getUrl());
rb.setTimeoutMillis(BioMapModule.TIMEOUT);
try {
Request request = rb.sendRequest(postData, new RequestCallback()
{
public void onError(Request request, Throwable exception) {
Window.alert("ERROR: " + exception.getMessage());
}
public void onResponseReceived(Request request,
Response response) {
// all ok?
if (response.getStatusCode() == 200) {
Window.alert("SUCCESS: " + response.getText());
notifySender(response.getText());
} else {
Window.alert("ERROR: " + response.getStatusCode());
}
Maps.logWrite("Status=" + response.getStatusCode()
+ " | response.value=" + response.getText());
}
});
} catch (RequestException e) {
Window.alert("Failed to send the request: " + e.getMessage());
}
}
}
so when i click the marker on the map, all fine, the ajax retrieves the data
from my php script and
alerts me SUCCESS, BUT the notifysender stuff does not work.
any code below the success does not get executed.
is there a better way to do this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---