Mercurial > dive4elements > river
diff flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPositionPanel.java @ 1386:9aa1a453eed5
Issue 294.
Redesigned UESK tab layout, removed superfluous map wrapper canvas.
flys-client/trunk@3185 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Raimund Renkert <raimund.renkert@intevation.de> |
---|---|
date | Tue, 08 Nov 2011 13:07:56 +0000 |
parents | 95cc560ce7c4 |
children | f3410c96f51a |
line wrap: on
line diff
--- a/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPositionPanel.java Fri Nov 04 11:53:13 2011 +0000 +++ b/flys-client/src/main/java/de/intevation/flys/client/client/ui/map/MapPositionPanel.java Tue Nov 08 13:07:56 2011 +0000 @@ -10,7 +10,9 @@ import org.gwtopenmaps.openlayers.client.Map; import org.gwtopenmaps.openlayers.client.MapWidget; import org.gwtopenmaps.openlayers.client.Pixel; - +import org.gwtopenmaps.openlayers.client.event.EventHandler; +import org.gwtopenmaps.openlayers.client.event.EventObject; +import org.gwtopenmaps.openlayers.client.util.JSObject; /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> @@ -18,13 +20,13 @@ public class MapPositionPanel extends HLayout { protected MapWidget mapWidget; - protected Map map; + protected final Map map; protected Label x; protected Label y; - public MapPositionPanel(MapWidget mapWidget, final Canvas c) { + public MapPositionPanel(MapWidget mapWidget) { this.mapWidget = mapWidget; this.map = mapWidget.getMap(); @@ -43,16 +45,18 @@ addMember(d); addMember(y); - // TODO We should use the MousePosition control provided by - // GwtOpenLayers here instead of calculating the mouse pos manually. - c.addMouseMoveHandler(new MouseMoveHandler() { - public void onMouseMove(MouseMoveEvent e) { - int x = e.getX() - c.getPageLeft(); - int y = e.getY() - c.getPageTop(); + // TODO This is not an optimal way to get the mouse position but makes + // the wrapper canvas superfluous. + this.map.getEvents().register("mousemove", map, new EventHandler() { - LonLat point = map.getLonLatFromPixel(new Pixel(x, y)); - setX(point.lon()); - setY(point.lat()); + @Override + public void onHandle(EventObject eventObject) { + JSObject xy = eventObject.getJSObject().getProperty("xy"); + Pixel px = Pixel.narrowToPixel(xy); + LonLat lonlat = map.getLonLatFromPixel(px); + + setX(lonlat.lon()); + setY(lonlat.lat()); } }); }