Mercurial > dive4elements > river
comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/map/GetFeatureInfo.java @ 5794:af2aa716152f
Fix issue1254, make GetFeatureInfo work reliably
This reduced GetFeatureInfo to one request per layer and chooses
the layer based on the selected theme
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Tue, 23 Apr 2013 17:14:07 +0200 |
parents | 46fc11ad697f |
children | e0ab5a566688 |
comparison
equal
deleted
inserted
replaced
5793:4cc59122b682 | 5794:af2aa716152f |
---|---|
4 | 4 |
5 import com.google.gwt.core.client.GWT; | 5 import com.google.gwt.core.client.GWT; |
6 import com.google.gwt.user.client.rpc.AsyncCallback; | 6 import com.google.gwt.user.client.rpc.AsyncCallback; |
7 | 7 |
8 import com.smartgwt.client.util.SC; | 8 import com.smartgwt.client.util.SC; |
9 import com.smartgwt.client.widgets.grid.ListGridRecord; | |
9 | 10 |
10 import org.gwtopenmaps.openlayers.client.Map; | 11 import org.gwtopenmaps.openlayers.client.Map; |
11 import org.gwtopenmaps.openlayers.client.LonLat; | 12 import org.gwtopenmaps.openlayers.client.LonLat; |
12 import org.gwtopenmaps.openlayers.client.Pixel; | 13 import org.gwtopenmaps.openlayers.client.Pixel; |
13 import org.gwtopenmaps.openlayers.client.event.MapClickListener; | 14 import org.gwtopenmaps.openlayers.client.event.MapClickListener; |
15 import de.intevation.flys.client.shared.model.FeatureInfo; | 16 import de.intevation.flys.client.shared.model.FeatureInfo; |
16 | 17 |
17 import de.intevation.flys.client.client.FLYSConstants; | 18 import de.intevation.flys.client.client.FLYSConstants; |
18 import de.intevation.flys.client.client.services.GFIService; | 19 import de.intevation.flys.client.client.services.GFIService; |
19 import de.intevation.flys.client.client.services.GFIServiceAsync; | 20 import de.intevation.flys.client.client.services.GFIServiceAsync; |
21 import de.intevation.flys.client.shared.model.FacetRecord; | |
22 import de.intevation.flys.client.shared.model.Theme; | |
20 import de.intevation.flys.client.client.ui.ThemePanel; | 23 import de.intevation.flys.client.client.ui.ThemePanel; |
21 | 24 |
22 | 25 |
23 public class GetFeatureInfo implements MapClickListener { | 26 public class GetFeatureInfo implements MapClickListener { |
24 | 27 |
69 @Override | 72 @Override |
70 public void onClick(MapClickListener.MapClickEvent e) { | 73 public void onClick(MapClickListener.MapClickEvent e) { |
71 LonLat lonlat = e.getLonLat(); | 74 LonLat lonlat = e.getLonLat(); |
72 Pixel pixel = map.getPixelFromLonLat(lonlat); | 75 Pixel pixel = map.getPixelFromLonLat(lonlat); |
73 | 76 |
74 gfiService.query( | 77 if (themePanel.getSelectedRecords().length == 0) { |
75 themePanel.getThemeList().getActiveThemes(), | 78 SC.say(MSG.requireTheme()); |
76 infoFormat, | 79 } |
77 map.getExtent().toString(), | |
78 map.getProjection(), | |
79 (int) map.getSize().getHeight(), | |
80 (int) map.getSize().getWidth(), | |
81 pixel.x(), pixel.y(), | |
82 new AsyncCallback<List<FeatureInfo>>() { | |
83 public void onFailure(Throwable e) { | |
84 SC.warn(MSG.getString(e.getMessage())); | |
85 } | |
86 | 80 |
87 public void onSuccess(List<FeatureInfo> features) { | 81 for (ListGridRecord rec : themePanel.getSelectedRecords()) { |
88 newGetFeatureInfoWindow(features); | 82 Theme act_theme = ((FacetRecord)rec).getTheme(); |
89 } | 83 gfiService.query( |
90 }); | 84 act_theme, |
85 infoFormat, | |
86 map.getExtent().toString(), | |
87 map.getProjection(), | |
88 (int) map.getSize().getHeight(), | |
89 (int) map.getSize().getWidth(), | |
90 pixel.x(), pixel.y(), | |
91 new AsyncCallback<List<FeatureInfo>>() { | |
92 @Override | |
93 public void onFailure(Throwable e) { | |
94 SC.warn(MSG.getString(e.getMessage())); | |
95 } | |
96 | |
97 @Override | |
98 public void onSuccess(List<FeatureInfo> features) { | |
99 if (features != null && !features.isEmpty()) | |
100 newGetFeatureInfoWindow(features); | |
101 } | |
102 } | |
103 ); | |
104 break; // More intelligent handling when more then one is selected | |
105 } | |
91 } | 106 } |
92 } | 107 } |