Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
1385:31e69ee9dd36 | 1386:9aa1a453eed5 |
---|---|
8 | 8 |
9 import org.gwtopenmaps.openlayers.client.LonLat; | 9 import org.gwtopenmaps.openlayers.client.LonLat; |
10 import org.gwtopenmaps.openlayers.client.Map; | 10 import org.gwtopenmaps.openlayers.client.Map; |
11 import org.gwtopenmaps.openlayers.client.MapWidget; | 11 import org.gwtopenmaps.openlayers.client.MapWidget; |
12 import org.gwtopenmaps.openlayers.client.Pixel; | 12 import org.gwtopenmaps.openlayers.client.Pixel; |
13 | 13 import org.gwtopenmaps.openlayers.client.event.EventHandler; |
14 import org.gwtopenmaps.openlayers.client.event.EventObject; | |
15 import org.gwtopenmaps.openlayers.client.util.JSObject; | |
14 | 16 |
15 /** | 17 /** |
16 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> | 18 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> |
17 */ | 19 */ |
18 public class MapPositionPanel extends HLayout { | 20 public class MapPositionPanel extends HLayout { |
19 | 21 |
20 protected MapWidget mapWidget; | 22 protected MapWidget mapWidget; |
21 protected Map map; | 23 protected final Map map; |
22 | 24 |
23 protected Label x; | 25 protected Label x; |
24 protected Label y; | 26 protected Label y; |
25 | 27 |
26 | 28 |
27 public MapPositionPanel(MapWidget mapWidget, final Canvas c) { | 29 public MapPositionPanel(MapWidget mapWidget) { |
28 this.mapWidget = mapWidget; | 30 this.mapWidget = mapWidget; |
29 this.map = mapWidget.getMap(); | 31 this.map = mapWidget.getMap(); |
30 | 32 |
31 this.x = new Label(); | 33 this.x = new Label(); |
32 this.y = new Label(); | 34 this.y = new Label(); |
41 | 43 |
42 addMember(x); | 44 addMember(x); |
43 addMember(d); | 45 addMember(d); |
44 addMember(y); | 46 addMember(y); |
45 | 47 |
46 // TODO We should use the MousePosition control provided by | 48 // TODO This is not an optimal way to get the mouse position but makes |
47 // GwtOpenLayers here instead of calculating the mouse pos manually. | 49 // the wrapper canvas superfluous. |
48 c.addMouseMoveHandler(new MouseMoveHandler() { | 50 this.map.getEvents().register("mousemove", map, new EventHandler() { |
49 public void onMouseMove(MouseMoveEvent e) { | |
50 int x = e.getX() - c.getPageLeft(); | |
51 int y = e.getY() - c.getPageTop(); | |
52 | 51 |
53 LonLat point = map.getLonLatFromPixel(new Pixel(x, y)); | 52 @Override |
54 setX(point.lon()); | 53 public void onHandle(EventObject eventObject) { |
55 setY(point.lat()); | 54 JSObject xy = eventObject.getJSObject().getProperty("xy"); |
55 Pixel px = Pixel.narrowToPixel(xy); | |
56 LonLat lonlat = map.getLonLatFromPixel(px); | |
57 | |
58 setX(lonlat.lon()); | |
59 setY(lonlat.lat()); | |
56 } | 60 } |
57 }); | 61 }); |
58 } | 62 } |
59 | 63 |
60 | 64 |