Top Description Fields Constructors Methods
com.dlsc.gmapsfx.javascript.event

public Class EventHandlers

extends Object
Class Inheritance
Imports
com.dlsc.gmapsfx.javascript.object.LatLong, java.util.HashMap, .Map, .UUID, netscape.javascript.JSObject

This object forms the bridge between Javascript events and the Java events.

An instance of this class is assigned to the document model so that Javascript can access it to make callbacks when events occur.

An application calls on one of the two addXXEventHandler methods in the com.dlsc.gmapsfx.javascript.object.GoogleMap class to register an instance of the GFXEventHandler interface against a certain event type in the Google Maps event model. See addUIEventHandler and addStateEventHandler.

This class uses a key based on a UUID to map the Javascript event handlers registered against the Google Maps model back to our Java event handlers stored here. The addXXEventHandler methods in GoogleMap create functions that call back into this class using the supplied key.

Currently an instance of this class is registered as: document.jsHandlers

The event listeners are established using the following Javascript calls:

com.dlsc.gmapsfx.javascript.object.GoogleMap#addUIEventHandler


google.maps.event.addListener(map, 'event_type', function(event) {
     document.jsHandlers.handleUIEvent('key', event.latLng);
});

com.dlsc.gmapsfx.javascript.object.GoogleMap#addStateEventHandler


 google.maps.event.addListener(map, 'event_type', function() {
     document.jsHandlers.handleStateEvent('key');
 });
Author
Geoff Capper

Field Summary

Modifier and TypeField and Description
private final Map<String, GFXEventHandler>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected GMapMouseEvent
buildMouseEvent(JSObject jsObject)
References Deprecated JSObject is deprecated or references (maybe indirectly) at least one deprecated element.

public void
handleStateEvent(String
Key generated by the call to registerHandler.
callbackKey
)

This method is called from Javascript, passing in the previously created callback key.

public void
handleUIEvent(String
Key generated by the call to registerHandler.
callbackKey
,
JSObject
Currently the event object from the Google Maps event.
result
)
References Deprecated JSObject is deprecated or references (maybe indirectly) at least one deprecated element.

This method is called from Javascript, passing in the previously created callback key, and the event object.

public String

Returns:

A String random UUID that can be used as the callback key.
registerHandler
(GFXEventHandler
Handler to be registered.
handler
)

Registers a handler and returns the callback key to be passed to Javascript.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

handlersback to summary
private final Map<String, GFXEventHandler> handlers

Constructor Detail

EventHandlersback to summary
public EventHandlers()

Method Detail

buildMouseEventback to summary
protected GMapMouseEvent buildMouseEvent(JSObject jsObject)

References Deprecated

JSObject is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

handleStateEventback to summary
public void handleStateEvent(String callbackKey)

This method is called from Javascript, passing in the previously created callback key. It uses that to find the correct handler and then passes on the call. State events in the Google Maps API don't pass any parameters.

Parameters
callbackKey:String

Key generated by the call to registerHandler.

handleUIEventback to summary
public void handleUIEvent(String callbackKey, JSObject result)

References Deprecated

JSObject is deprecated or references (maybe indirectly) at least one deprecated element.

See corresponding docs for further information.

This method is called from Javascript, passing in the previously created callback key, and the event object. The current implementation is receiving the LatLng object that the Javascript MouseEvent contains.

It may be more useful to return the MouseEvent and let clients go from there, but there is only the stop() method on the MouseEvent?

Parameters
callbackKey:String

Key generated by the call to registerHandler.

result:JSObject

Currently the event object from the Google Maps event.

registerHandlerback to summary
public String registerHandler(GFXEventHandler handler)

Registers a handler and returns the callback key to be passed to Javascript.

Parameters
handler:GFXEventHandler

Handler to be registered.

Returns:String

A String random UUID that can be used as the callback key.