mousemove events in gwt-openlayers
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 mo开发者_运维问答ve 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);
}
});
精彩评论