So far this is what I have and seems to be working good. I'll stick with
this for now I think and change it if something better comes up.
public class MapHandlerRegistration {
/**
* create a handler for eventName
* @param w
* @param eventName
* @param handler
* @return
*/
public static HandlerRegistration addHandler(MapWidget w, String eventName,
MapHandler<?> handler) {
final JavaScriptObject listener = addHandlerImpl(w, eventName, handler);
HandlerRegistration registration = new HandlerRegistration() {
public void removeHandler() {
removeHandlerImpl(listener);
}
};
return registration;
}
/**
* maps v3 event observation
* @param w
* @param eventName
* @param handler
* @return
*/
private static native JavaScriptObject addHandlerImpl(MapWidget w, String
eventName, MapHandler<?> handler) /*-{
var jso =
[email protected]::getJso()();
var callback = function(event) {
@com.gonevertical.apis.googlemaps.client.events.MapHandlerRegistration::onCallback(Lcom/gonevertical/apis/googlemaps/client/events/MapHandler;Lcom/google/gwt/ajaxloader/client/Properties;)(handler,
event);
};
return $wnd.google.maps.event.addListener(jso, eventName, callback)
}-*/;
/**
* HandlerRegistration call when finished
* @param listener
*/
private static native void removeHandlerImpl(JavaScriptObject listener) /*-{
$wnd.google.maps.MapsEventListener.addListener(listener);
}-*/;
/**
* Process event and next step is to format it into an event that extends
format handler
* @param handler
* @param properties
*/
@SuppressWarnings("unused")
protected static void onCallback(final MapHandler<?> handler, final
Properties properties) {
try {
formatEvent(handler, properties);
} catch (Throwable x) {
GWT.getUncaughtExceptionHandler().onUncaughtException(x);
}
}
/**
* format the event and tell the handler so parent can then work with it
* @param handler
* @param properties
*/
private static void formatEvent(MapHandler<?> handler, Properties properties)
{
if (handler instanceof ClickMapHandler) {
System.out.println("tes2");
} else {
System.out.println("test3");
}
}
}
Brandon
http://c.gwt-examples.com
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/DyxMz9E0qioJ.
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.