Mercurial > dive4elements > river
annotate flys-client/src/main/java/de/intevation/flys/client/client/ui/map/FloodMap.java @ 880:22dc88b17253
Added tooltips for the maptoolbar.
flys-client/trunk@2709 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Tue, 13 Sep 2011 04:49:10 +0000 |
parents | dcecdd9693a8 |
children | 4af1ee86b0b1 |
rev | line source |
---|---|
797
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
1 package de.intevation.flys.client.client.ui.map; |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
2 |
823
407de0f4b66a
Set the map projection and its max extent dynamically - information extracted from facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
806
diff
changeset
|
3 import org.gwtopenmaps.openlayers.client.Bounds; |
797
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
4 import org.gwtopenmaps.openlayers.client.Map; |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
5 import org.gwtopenmaps.openlayers.client.MapOptions; |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
6 import org.gwtopenmaps.openlayers.client.MapWidget; |
833
dcecdd9693a8
Added a UIProvider that displays a combobox on the left and a map widget in the helper container.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
7 import org.gwtopenmaps.openlayers.client.feature.VectorFeature; |
dcecdd9693a8
Added a UIProvider that displays a combobox on the left and a map widget in the helper container.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
8 import org.gwtopenmaps.openlayers.client.format.GeoJSON; |
800
95cc560ce7c4
Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
799
diff
changeset
|
9 import org.gwtopenmaps.openlayers.client.layer.Vector; |
823
407de0f4b66a
Set the map projection and its max extent dynamically - information extracted from facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
806
diff
changeset
|
10 import org.gwtopenmaps.openlayers.client.layer.VectorOptions; |
797
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
11 import org.gwtopenmaps.openlayers.client.util.JObjectArray; |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
12 import org.gwtopenmaps.openlayers.client.util.JSObject; |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
13 |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
14 |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
15 public class FloodMap { |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
16 |
800
95cc560ce7c4
Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
799
diff
changeset
|
17 public static final String LAYER_BARRIERS = "vector_layer_barriers"; |
95cc560ce7c4
Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
799
diff
changeset
|
18 |
797
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
19 protected MapWidget mapWidget; |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
20 protected Map map; |
800
95cc560ce7c4
Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
799
diff
changeset
|
21 protected Vector barrierLayer; |
823
407de0f4b66a
Set the map projection and its max extent dynamically - information extracted from facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
806
diff
changeset
|
22 protected String srid; |
407de0f4b66a
Set the map projection and its max extent dynamically - information extracted from facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
806
diff
changeset
|
23 protected Bounds maxExtent; |
797
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
24 |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
25 |
823
407de0f4b66a
Set the map projection and its max extent dynamically - information extracted from facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
806
diff
changeset
|
26 public FloodMap(String srid, Bounds maxExtent) { |
407de0f4b66a
Set the map projection and its max extent dynamically - information extracted from facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
806
diff
changeset
|
27 this.srid = srid; |
407de0f4b66a
Set the map projection and its max extent dynamically - information extracted from facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
806
diff
changeset
|
28 this.maxExtent = maxExtent; |
407de0f4b66a
Set the map projection and its max extent dynamically - information extracted from facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
806
diff
changeset
|
29 |
797
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
30 MapOptions opts = new MapOptions(); |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
31 opts.setControls(new JObjectArray(new JSObject[] {})); |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
32 opts.setNumZoomLevels(16); |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
33 opts.setProjection(getRiverProjection()); |
823
407de0f4b66a
Set the map projection and its max extent dynamically - information extracted from facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
806
diff
changeset
|
34 opts.setMaxExtent(maxExtent); |
407de0f4b66a
Set the map projection and its max extent dynamically - information extracted from facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
806
diff
changeset
|
35 opts.setMaxResolution(500); // TODO DO THIS ON THE FLY |
797
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
36 |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
37 mapWidget = new MapWidget("510px", "635px", opts); |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
38 map = mapWidget.getMap(); |
806
e50da1f74e58
The layers created in the floodmap reflect to the facets this output mode has.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
800
diff
changeset
|
39 |
e50da1f74e58
The layers created in the floodmap reflect to the facets this output mode has.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
800
diff
changeset
|
40 getBarrierLayer(); |
797
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
41 } |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
42 |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
43 |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
44 public MapWidget getMapWidget() { |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
45 return mapWidget; |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
46 } |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
47 |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
48 |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
49 public Map getMap() { |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
50 return map; |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
51 } |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
52 |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
53 |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
54 public String getRiverProjection() { |
823
407de0f4b66a
Set the map projection and its max extent dynamically - information extracted from facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
806
diff
changeset
|
55 return "EPSG:" + srid; |
797
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
56 } |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
57 |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
58 |
800
95cc560ce7c4
Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
799
diff
changeset
|
59 public Vector getBarrierLayer() { |
95cc560ce7c4
Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
799
diff
changeset
|
60 if (barrierLayer == null) { |
823
407de0f4b66a
Set the map projection and its max extent dynamically - information extracted from facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
806
diff
changeset
|
61 VectorOptions opts = new VectorOptions(); |
407de0f4b66a
Set the map projection and its max extent dynamically - information extracted from facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
806
diff
changeset
|
62 opts.setProjection(getRiverProjection()); |
407de0f4b66a
Set the map projection and its max extent dynamically - information extracted from facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
806
diff
changeset
|
63 opts.setMaxExtent(maxExtent); |
407de0f4b66a
Set the map projection and its max extent dynamically - information extracted from facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
806
diff
changeset
|
64 |
407de0f4b66a
Set the map projection and its max extent dynamically - information extracted from facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
806
diff
changeset
|
65 barrierLayer = new Vector(LAYER_BARRIERS, opts); |
806
e50da1f74e58
The layers created in the floodmap reflect to the facets this output mode has.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
800
diff
changeset
|
66 barrierLayer.setIsBaseLayer(true); |
823
407de0f4b66a
Set the map projection and its max extent dynamically - information extracted from facets.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
806
diff
changeset
|
67 |
800
95cc560ce7c4
Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
799
diff
changeset
|
68 map.addLayer(barrierLayer); |
95cc560ce7c4
Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
799
diff
changeset
|
69 } |
95cc560ce7c4
Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
799
diff
changeset
|
70 |
95cc560ce7c4
Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
799
diff
changeset
|
71 return barrierLayer; |
95cc560ce7c4
Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
799
diff
changeset
|
72 } |
95cc560ce7c4
Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
799
diff
changeset
|
73 |
95cc560ce7c4
Added map controls for digitizing and removing barriers.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
799
diff
changeset
|
74 |
833
dcecdd9693a8
Added a UIProvider that displays a combobox on the left and a map widget in the helper container.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
75 public String getFeaturesAsGeoJSON() { |
dcecdd9693a8
Added a UIProvider that displays a combobox on the left and a map widget in the helper container.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
76 VectorFeature[] features = barrierLayer.getFeatures(); |
dcecdd9693a8
Added a UIProvider that displays a combobox on the left and a map widget in the helper container.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
77 |
dcecdd9693a8
Added a UIProvider that displays a combobox on the left and a map widget in the helper container.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
78 if (features == null || features.length == 0) { |
dcecdd9693a8
Added a UIProvider that displays a combobox on the left and a map widget in the helper container.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
79 return null; |
dcecdd9693a8
Added a UIProvider that displays a combobox on the left and a map widget in the helper container.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
80 } |
dcecdd9693a8
Added a UIProvider that displays a combobox on the left and a map widget in the helper container.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
81 |
dcecdd9693a8
Added a UIProvider that displays a combobox on the left and a map widget in the helper container.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
82 return new GeoJSON().write(features); |
dcecdd9693a8
Added a UIProvider that displays a combobox on the left and a map widget in the helper container.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
83 } |
dcecdd9693a8
Added a UIProvider that displays a combobox on the left and a map widget in the helper container.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
84 |
dcecdd9693a8
Added a UIProvider that displays a combobox on the left and a map widget in the helper container.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
823
diff
changeset
|
85 |
797
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
86 public void setSize(String width, String height) { |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
87 mapWidget.setWidth(width); |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
88 mapWidget.setHeight(height); |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
89 } |
cc3f481e9484
Introduced GwtOpenLayers to bring up maps.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
diff
changeset
|
90 } |
799
f4299b90c996
Added controls to navigate in the map.
Ingo Weinzierl <ingo.weinzierl@intevation.de>
parents:
797
diff
changeset
|
91 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |