I am trying to capture mouse events in gwt-openlayers. The following handler does receive events, however I am unable to extract mouse position from EventObject object. Anybody can help ?
mapPanel.getMap().getEvents().register("mousemove", mapPanel.getMap(), new EventHandler() {
@Override
public void onHandle(EventObject eventObject) {
// how to obtain mouse position ?
}
});
Also, is there another way to receive mouse move events ? Can I intercept MousePosition Control for this ?
Thanks a lot for any help.
I went through the source code and found an answer myself. I hope it can be useful to somebody else.
mapPanel.getMap().getEvents().register("mousemove", mapPanel.getMap(), new EventHandler() {
@Override
public void onHandle(EventObject eventObject) {
JSObject xy = eventObject.getJSObject().getProperty("xy");
Pixel px = Pixel.narrowToPixel(xy);
LonLat lonlat = mapPanel.getMap().getLonLatFromPixel(px);
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With