public class EventHandlers extends Object
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
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:
google.maps.event.addListener(map, 'event_type', function(event) { document.jsHandlers.handleUIEvent('key', event.latLng); });
google.maps.event.addListener(map, 'event_type', function() { document.jsHandlers.handleStateEvent('key'); });
Constructor and Description |
---|
EventHandlers() |
Modifier and Type | Method and Description |
---|---|
void |
handleStateEvent(String callbackKey)
This method is called from Javascript, passing in the previously
created callback key.
|
void |
handleUIEvent(String callbackKey,
netscape.javascript.JSObject result)
This method is called from Javascript, passing in the previously
created callback key, and the event object.
|
String |
registerHandler(GFXEventHandler handler)
Registers a handler and returns the callback key to be passed to
Javascript.
|
public String registerHandler(GFXEventHandler handler)
handler
- Handler to be registered.public void handleUIEvent(String callbackKey, netscape.javascript.JSObject result)
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?
callbackKey
- Key generated by the call to registerHandler.result
- Currently the LatLng object from the Google Maps event.public void handleStateEvent(String callbackKey)
callbackKey
- Key generated by the call to registerHandler.Copyright © 2016. All Rights Reserved.