comparison flys-client/src/main/java/de/intevation/flys/client/client/ui/map/GetFeatureInfo.java @ 1400:96708d81eaf6

Added an initial GetFeatureInfo tool to get information about points in the map. flys-client/trunk@3285 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 17 Nov 2011 16:20:55 +0000
parents
children 15ef3d3081b7
comparison
equal deleted inserted replaced
1399:748e7c828d03 1400:96708d81eaf6
1 package de.intevation.flys.client.client.ui.map;
2
3 import java.util.List;
4
5 import com.google.gwt.core.client.GWT;
6 import com.google.gwt.user.client.rpc.AsyncCallback;
7
8 import com.smartgwt.client.util.SC;
9
10 import org.gwtopenmaps.openlayers.client.Map;
11 import org.gwtopenmaps.openlayers.client.LonLat;
12 import org.gwtopenmaps.openlayers.client.Pixel;
13 import org.gwtopenmaps.openlayers.client.event.MapClickListener;
14
15 import de.intevation.flys.client.shared.model.Theme;
16
17 import de.intevation.flys.client.client.FLYSConstants;
18 import de.intevation.flys.client.client.services.GFIService;
19 import de.intevation.flys.client.client.services.GFIServiceAsync;
20
21
22 public class GetFeatureInfo implements MapClickListener {
23
24 protected GFIServiceAsync gfiService = GWT.create(GFIService.class);
25
26 protected FLYSConstants MSG = GWT.create(FLYSConstants.class);
27
28 protected Map map;
29 protected List<Theme> themes;
30 protected String infoFormat;
31
32
33 /**
34 * @param map
35 * @param themes
36 * @param url
37 * @param infoFormat
38 */
39 public GetFeatureInfo(Map map, List<Theme> themes, String infoFormat) {
40 this.map = map;
41 this.themes = themes;
42 this.infoFormat = infoFormat;
43 }
44
45
46 public void activate(boolean activate) {
47 if (activate) {
48 map.addMapClickListener(this);
49 }
50 else {
51 map.removeListener(this);
52 }
53 }
54
55
56 @Override
57 public void onClick(MapClickListener.MapClickEvent e) {
58 LonLat lonlat = e.getLonLat();
59 Pixel pixel = map.getPixelFromLonLat(lonlat);
60
61 gfiService.query(
62 themes,
63 infoFormat,
64 map.getExtent().toString(),
65 map.getProjection(),
66 (int) map.getSize().getHeight(),
67 (int) map.getSize().getWidth(),
68 pixel.x(), pixel.y(),
69 new AsyncCallback<String>() {
70 public void onFailure(Throwable e) {
71 SC.warn(MSG.getString(e.getMessage()));
72 }
73
74 public void onSuccess(String response) {
75 new GetFeatureInfoWindow(response).show();
76 }
77 });
78 }
79 }

http://dive4elements.wald.intevation.org