Openlayers Map in Android

Put your problem here if it does not fit any of the other categories.

Openlayers Map in Android

Postby sandesh » Sat Mar 08, 2008 7:09 am

JOSM client on Android

hello everyone i m trying to develop a application JOSM client on android , i tried the code in link below to run on android
http://docs.codehaus.org/display/GEOSDO ... olkit+(GWT),+OpenLayers+and+GeoServer
tried only java code its without errors... but i dont know where to put other files in android from link given above.
the purpose is to open a openlayers map in android and then other editing will be done.i also added external libraries which are needed.which are gwt-user.jar and openlayers_gwt-0.2.jar
here is the only code i runned without errors

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. package org.android.openlayer;
  2.  
  3.  
  4.  
  5.  
  6.  
  7. import com.eg.gwt.openLayers.client.Bounds;
  8.  
  9. import com.eg.gwt.openLayers.client.Icon;
  10.  
  11. import com.eg.gwt.openLayers.client.JObjectArray;
  12.  
  13. import com.eg.gwt.openLayers.client.JSObject;
  14.  
  15. import com.eg.gwt.openLayers.client.LonLat;
  16.  
  17. import com.eg.gwt.openLayers.client.Map;
  18.  
  19. import com.eg.gwt.openLayers.client.MapOptions;
  20.  
  21. import com.eg.gwt.openLayers.client.MapWidget;
  22.  
  23. import com.eg.gwt.openLayers.client.Marker;
  24.  
  25. import com.eg.gwt.openLayers.client.Pixel;
  26.  
  27. import com.eg.gwt.openLayers.client.Size;
  28.  
  29. import com.eg.gwt.openLayers.client.control.LayerSwitcher;
  30.  
  31. import com.eg.gwt.openLayers.client.control.MousePosition;
  32.  
  33. import com.eg.gwt.openLayers.client.control.MouseToolbar;
  34.  
  35. import com.eg.gwt.openLayers.client.control.PanZoomBar;
  36.  
  37. import com.eg.gwt.openLayers.client.control.Scale;
  38.  
  39. import com.eg.gwt.openLayers.client.event.EventHandler;
  40.  
  41. import com.eg.gwt.openLayers.client.layer.Layer;
  42.  
  43. import com.eg.gwt.openLayers.client.layer.Markers;
  44.  
  45. import com.eg.gwt.openLayers.client.layer.WMS;
  46.  
  47. import com.eg.gwt.openLayers.client.layer.WMSParams;
  48.  
  49. import com.eg.gwt.openLayers.client.popup.AnchoredBubble;
  50.  
  51. import com.eg.gwt.openLayers.client.popup.Popup;
  52.  
  53. import com.google.gwt.core.client.EntryPoint;
  54.  
  55. import com.google.gwt.user.client.ui.DockPanel;
  56.  
  57. import com.google.gwt.user.client.ui.RootPanel;
  58.  
  59.  
  60.  
  61. public class hello implements EntryPoint {
  62.  
  63.  
  64.  
  65. private MapWidget mapWidget;
  66.  
  67. private Map map;
  68.  
  69. private WMS wmsLayer;
  70.  
  71. private Markers markers;
  72.  
  73. private Popup popup;
  74.  
  75. public void onModuleLoad() {
  76.  
  77. // let's create map options
  78.  
  79. MapOptions mapOptions = new MapOptions();
  80.  
  81. mapOptions.setControls(new JObjectArray(new JSObject[] {}));
  82.  
  83. mapOptions.setNumZoomLevels(16);
  84.  
  85. mapOptions.setProjection("EPSG:4326");
  86.  
  87.  
  88.  
  89. // let's create map widget and map objects
  90.  
  91. mapWidget = new MapWidget("350px", "350px", mapOptions);
  92.  
  93. map = mapWidget.getMap();
  94.  
  95. markers = new Markers("marker layer");
  96.  
  97. // let's create WMS map layer
  98.  
  99. WMSParams wmsParams = new WMSParams();
  100.  
  101. wmsParams.setFormat("image/png");
  102.  
  103. wmsParams.setLayers("tiger-ny");
  104.  
  105. wmsParams.setStyles("");
  106.  
  107. wmsParams.setMaxExtent(new Bounds(-74.047185, 40.679648, -73.907005, 40.882078));
  108.  
  109.  
  110.  
  111. wmsLayer = new WMS("WMS Layer", "http://openlayers.org", wmsParams);
  112.  
  113.  
  114.  
  115. // let's add layers and controls to map
  116.  
  117. map.addLayers(new Layer[] {wmsLayer, markers});
  118.  
  119.  
  120.  
  121. map.addControl(new PanZoomBar(RootPanel.get("nav").getElement()));
  122.  
  123. map.addControl(new MousePosition(RootPanel.get("position").getElement()));
  124.  
  125. map.addControl(new Scale(RootPanel.get("scale").getElement()));
  126.  
  127. map.addControl(new MouseToolbar());
  128.  
  129. map.addControl(new LayerSwitcher());
  130.  
  131. // let's center the map to somewhere and set zoom level to 13
  132.  
  133. LonLat center = new LonLat(-73.99, 40.73);
  134.  
  135. map.setCenter(center, 13);
  136.  
  137.  
  138.  
  139. // add marker
  140.  
  141. Size size = new Size(10,17);
  142.  
  143. Pixel offset = new Pixel(-5, -17);
  144.  
  145. Icon icon = new Icon("img/marker.png", size, offset);
  146.  
  147. Marker marker = new Marker(center, icon);
  148.  
  149. markers.addMarker(marker);
  150.  
  151. // register mouse over event
  152.  
  153. marker.getEvents().register("mouseover", marker, new EventHandler() {
  154.  
  155. public void onHandle(JSObject source, JSObject[] param) {
  156.  
  157. Marker marker = Marker.narrowToMarker(source);
  158.  
  159. if (popup != null) {
  160.  
  161. map.removePopup(popup);
  162.  
  163. }
  164.  
  165.  
  166.  
  167. popup = new AnchoredBubble("marker-info",
  168.  
  169. marker.getLonLat(),
  170.  
  171. new Size(120,80),
  172.  
  173. "<p>You moved near " + marker.getLonLat().lon() + " : " + marker.getLonLat().lat() + "</p>" ,
  174.  
  175. new Icon("", new Size(0,0), new Pixel(0,0)),
  176.  
  177. true);
  178.  
  179. map.addPopup(popup);
  180.  
  181.  
  182.  
  183. }
  184.  
  185. });
  186.  
  187.  
  188.  
  189. // register mouse out event
  190.  
  191. marker.getEvents().register("mouseout", marker, new EventHandler() {
  192.  
  193. public void onHandle(JSObject source, JSObject[] param) {
  194.  
  195. // Marker marker = Marker.narrowToMarker(source);
  196.  
  197. if (popup != null) {
  198.  
  199. map.removePopup(popup);
  200.  
  201. }
  202.  
  203. }
  204.  
  205. });
  206.  
  207. // eventually add the map widget to div:map
  208.  
  209. DockPanel dockPanel = new DockPanel();
  210.  
  211. dockPanel.add(mapWidget, DockPanel.CENTER);
  212.  
  213. dockPanel.setBorderWidth(1);
  214.  
  215. RootPanel.get("map").add(dockPanel);
  216.  
  217. }
  218.  
  219. }
Parsed in 0.048 seconds, using GeSHi 1.0.8.4





Thanks in andvance..
sandesh
Freshman
Freshman
 
Posts: 6
Joined: Fri Mar 07, 2008 11:12 am

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 26 guests