开发者

mousemove events in gwt-openlayers

开发者 https://www.devze.com 2023-03-06 07:10 出处:网络
I am trying to capture mouse events in gwt-openlayers. The following handler does receive events, however I am

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);
            }
        });
0

精彩评论

暂无评论...
验证码 换一张
取 消