Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 move events ? Can I intercept MousePosition Control for this ?

Thanks a lot for any help.

like image 807
t.aldo Avatar asked Jan 19 '23 17:01

t.aldo


1 Answers

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);
            }
        });
like image 183
t.aldo Avatar answered Jan 28 '23 00:01

t.aldo