Permalink
Browse files

port code to latest osmdroid (SNAPSHOT, as stable 3.0.8 has a bug in …

…resource)

Todo:
 - onTap in WaypointOverlay
  • Loading branch information...
1 parent 23ae998 commit 3578ef1a5088d69ec565b768f90d0d406b9e4490 @dkm committed Feb 16, 2012
View
@@ -5,8 +5,8 @@
<classpathentry kind="src" path="gen"/>
<classpathentry kind="lib" path="libs/FlurryAgent.jar"/>
<classpathentry kind="lib" path="libs/slf4j-android-1.5.8.jar"/>
- <classpathentry kind="lib" path="libs/osmdroid-android-1.08.jar" sourcepath="/osmdroid-android"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
+ <classpathentry kind="lib" path="libs/osmdroid-android-3.0.8-20120208.220818-1.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
View
@@ -8,6 +8,7 @@
android:anyDensity="true" />
<uses-sdk android:minSdkVersion="3" android:targetSdkVersion="8" />
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:description="@string/app_description" android:name="com.geeksville.gaggle.GaggleApplication"
Binary file not shown.
Binary file not shown.
@@ -283,5 +283,7 @@ please email kevinh@geeksville.com.</string>
<string name="advanced">Advanced</string>
<string name="flurry_logging_conf">Flurry report</string>
<string name="enables_reporting_dev_data_to_flurry">Enables reporting to Flurry</string>
+ <string name="mapnik_map">Mapnik</string>
+ <string name="toposm_map">OpenStreetMap Topo</string>
</resources>
@@ -25,8 +25,8 @@
import java.util.Observable;
import java.util.Observer;
-import org.andnav.osm.views.OpenStreetMapViewController;
-import org.andnav.osm.views.overlay.MyLocationOverlay;
+import org.osmdroid.views.MapController;
+import org.osmdroid.views.overlay.MyLocationOverlay;
import android.app.AlertDialog;
import android.content.Context;
@@ -293,7 +293,7 @@ private TracklogOverlay createTracklogOverlay(final LocationList locs) {
@Override
public void run() {
- OpenStreetMapViewController control = mapView.getController();
+ MapController control = mapView.getController();
control.setCenter(locs.getGeoPoint(0));
@@ -339,5 +339,4 @@ public void update(Observable observable, Object data) {
mapView.postInvalidateDelayed(1000);
}
-
}
@@ -5,7 +5,8 @@
import java.io.File;
-import org.andnav.osm.tileprovider.constants.OpenStreetMapTileProviderConstants;
+import org.osmdroid.tileprovider.constants.OpenStreetMapTileProviderConstants;
+
import android.app.TabActivity;
import android.content.Intent;
@@ -20,7 +20,7 @@
******************************************************************************/
package com.geeksville.location;
-import org.andnav.osm.util.GeoPoint;
+import org.osmdroid.util.GeoPoint;
import android.database.Cursor;
import android.graphics.drawable.Drawable;
@@ -20,7 +20,8 @@
******************************************************************************/
package com.geeksville.location;
-import org.andnav.osm.util.GeoPoint;
+import org.osmdroid.util.GeoPoint;
+
public interface ILocationList extends Iterable<GeoPoint> {
@@ -23,7 +23,7 @@
import java.util.Iterator;
import java.util.Observable;
-import org.andnav.osm.util.GeoPoint;
+import org.osmdroid.util.GeoPoint;
import android.os.Bundle;
@@ -26,7 +26,7 @@
import java.util.SortedMap;
import java.util.TreeMap;
-import org.andnav.osm.util.GeoPoint;
+import org.osmdroid.util.GeoPoint;
import android.content.ComponentName;
import android.content.Context;
@@ -20,16 +20,17 @@
******************************************************************************/
package com.geeksville.maps;
-import org.andnav.osm.ResourceProxy;
-import org.andnav.osm.util.GeoPoint;
-import org.andnav.osm.views.OpenStreetMapViewController;
-import org.andnav.osm.views.overlay.MyLocationOverlay;
-import org.andnav.osm.views.util.IOpenStreetMapRendererInfo;
-import org.andnav.osm.views.util.OpenStreetMapRendererFactory;
-import org.andnav.osm.views.util.XYRenderer;
+import org.osmdroid.tileprovider.tilesource.OnlineTileSourceBase;
+import org.osmdroid.tileprovider.tilesource.TileSourceFactory;
+import org.osmdroid.util.GeoPoint;
+import org.osmdroid.views.MapController;
+import org.osmdroid.views.overlay.MyLocationOverlay;
import android.app.Activity;
+import android.content.Context;
+import android.location.LocationManager;
import android.os.Bundle;
+import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.MenuItem.OnMenuItemClickListener;
@@ -58,46 +59,45 @@
private LifeCyclePublisherImpl lifePublish = new LifeCyclePublisherImpl();
// There is also TopOSM features, but we don't bother to show that
- private static final IOpenStreetMapRendererInfo TopOSMRelief =
- new XYRenderer("Topo Relief (USA)", ResourceProxy.string.unknown, 4, 15, 8, ".jpg",
- "http://tile1.toposm.com/us/color-relief/",
- "http://tile2.toposm.com/us/color-relief/",
- "http://tile3.toposm.com/us/color-relief/");
-
- private static final IOpenStreetMapRendererInfo TopOSMContours =
- new XYRenderer("Topo Contours (USA)", ResourceProxy.string.unknown, 12, 15, 8, ".png",
- "http://tile1.toposm.com/us/contours/",
- "http://tile2.toposm.com/us/contours/",
- "http://tile3.toposm.com/us/contours/");
-
- private static final IOpenStreetMapRendererInfo OpenCycleMap =
- new XYRenderer("www.opencyclemap.org", ResourceProxy.string.unknown, 1, 18, 8, ".png",
- "http://a.tile.opencyclemap.org/cycle/",
- "http://b.tile.opencyclemap.org/cycle/",
- "http://c.tile.opencyclemap.org/cycle/"
- );
-
- private static final IOpenStreetMapRendererInfo OpenHikingMap =
- new XYRenderer("maps.refuges.info", ResourceProxy.string.unknown, 1, 18, 8, ".jpeg",
- "http://maps.refuges.info/tiles/renderer.py/hiking/");
+// private static final XYTileSource TopOSMRelief =
+// new XYTileSource("Topo Relief (USA)", ResourceProxy.string.unknown, 4, 15, 8, ".jpg",
+// "http://tile1.toposm.com/us/color-relief/",
+// "http://tile2.toposm.com/us/color-relief/",
+// "http://tile3.toposm.com/us/color-relief/");
+//
+// private static final XYTileSource TopOSMContours =
+// new XYTileSource("Topo Contours (USA)", ResourceProxy.string.unknown, 12, 15, 8, ".png",
+// "http://tile1.toposm.com/us/contours/",
+// "http://tile2.toposm.com/us/contours/",
+// "http://tile3.toposm.com/us/contours/");
+//
+// private static final XYTileSource OpenCycleMap =
+// new XYTileSource("www.opencyclemap.org", ResourceProxy.string.unknown, 1, 18, 8, ".png",
+// "http://a.tile.opencyclemap.org/cycle/",
+// "http://b.tile.opencyclemap.org/cycle/",
+// "http://c.tile.opencyclemap.org/cycle/"
+// );
+// private static final XYTileSource OpenHikingMap =
+// new XYTileSource("maps.refuges.info", ResourceProxy.string.unknown, 1, 18, 8, ".jpeg",
+// "http://maps.refuges.info/tiles/renderer.py/hiking/");
- private static IOpenStreetMapRendererInfo supportedRenderers[] = {
- OpenStreetMapRendererFactory.OSMARENDER,
- OpenCycleMap,
- OpenHikingMap,
- OpenStreetMapRendererFactory.TOPO,
- TopOSMContours,
- TopOSMRelief
+ private static OnlineTileSourceBase supportedRenderers[] = {
+ TileSourceFactory.OSMARENDER,
+ TileSourceFactory.CYCLEMAP,
+ TileSourceFactory.MAPNIK,
+ TileSourceFactory.TOPO,
+// TopOSMContours,
+// TopOSMRelief
};
private String supportedRendererNames[];
public GeeksvilleMapActivity() {
// FIXME - do this someplace better
- OpenStreetMapRendererFactory.addRenderer(TopOSMContours);
- OpenStreetMapRendererFactory.addRenderer(TopOSMRelief);
- OpenStreetMapRendererFactory.addRenderer(OpenCycleMap);
- OpenStreetMapRendererFactory.addRenderer(OpenHikingMap);
+// TileSourceFactory.addTileSource(TopOSMContours);
+// TileSourceFactory.addTileSource(TopOSMRelief);
+// TileSourceFactory.addTileSource(OpenCycleMap);
+// TileSourceFactory.addTileSource(OpenHikingMap);
}
/** Called when the activity is first created. */
@@ -107,10 +107,12 @@ public void onCreate(Bundle savedInstanceState, int layoutId, int mapViewId) {
supportedRendererNames = new String[] {
getString(R.string.street_map),
getString(R.string.opencyclemap),
- getString(R.string.openhikingmap),
- getString(R.string.topo_europe),
- getString(R.string.topo_us_contour),
- getString(R.string.topo_us_relief)
+ getString(R.string.mapnik_map),
+ getString(R.string.toposm_map),
+// getString(R.string.openhikingmap),
+// getString(R.string.topo_europe),
+// getString(R.string.topo_us_contour),
+// getString(R.string.topo_us_relief)
};
// Our license key is different for the emulator, otherwise these files
@@ -121,7 +123,7 @@ public void onCreate(Bundle savedInstanceState, int layoutId, int mapViewId) {
mapView.setBuiltInZoomControls(true);
// Set default map view
- mapView.setRenderer(OpenStreetMapRendererFactory.OSMARENDER);
+ mapView.setTileSource(TileSourceFactory.OSMARENDER);
// Default to sat view
// mapView.setSatellite(true);
@@ -178,19 +180,18 @@ public boolean onCreateOptionsMenu(Menu menu) {
MenuItem toCheck = null;
for (int i = 0; i < supportedRenderers.length; i++) {
- final IOpenStreetMapRendererInfo info = supportedRenderers[i];
+ final OnlineTileSourceBase info = supportedRenderers[i];
String name = supportedRendererNames[i];
MenuItem item = children.add(1, i, Menu.NONE, name);
-
- if (mapView.getRenderer().name().equals(info.name()))
+ if (mapView.getTileProvider().getTileSource().name().equals(info.name()))
toCheck = item;
item.setOnMenuItemClickListener(new OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
- mapView.setRenderer(info);
+ mapView.setTileSource(info);
item.setChecked(true);
return true;
}
@@ -252,7 +253,7 @@ public void run() {
private void zoomToLocation() {
// Center on where the user is
- OpenStreetMapViewController control = mapView.getController();
+ MapController control = mapView.getController();
GeoPoint loc;
if (myLocationOverlay != null && (loc = myLocationOverlay.getMyLocation()) != null)
Oops, something went wrong.

0 comments on commit 3578ef1

Please sign in to comment.