aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cgeo/geocaching/googlemaps/googleMapFactory.java12
-rw-r--r--src/cgeo/geocaching/googlemaps/googleMapView.java42
-rw-r--r--src/cgeo/geocaching/googlemaps/googleOverlay.java23
-rw-r--r--src/cgeo/geocaching/mapcommon/ItemizedOverlayBase.java9
-rw-r--r--src/cgeo/geocaching/mapcommon/cgMapMyOverlay.java12
-rw-r--r--src/cgeo/geocaching/mapcommon/cgMapOverlay.java2
-rw-r--r--src/cgeo/geocaching/mapcommon/cgOverlayScale.java12
-rw-r--r--src/cgeo/geocaching/mapcommon/cgeomap.java22
-rw-r--r--src/cgeo/geocaching/mapinterfaces/ItemizedOverlayImpl.java4
-rw-r--r--src/cgeo/geocaching/mapinterfaces/MapFactory.java2
-rw-r--r--src/cgeo/geocaching/mapinterfaces/MapViewImpl.java13
-rw-r--r--src/cgeo/geocaching/mapinterfaces/OverlayBase.java1
-rw-r--r--src/cgeo/geocaching/mapinterfaces/OverlayImpl.java5
-rw-r--r--src/cgeo/geocaching/mapsforge/mfMapFactory.java12
-rw-r--r--src/cgeo/geocaching/mapsforge/mfMapView.java39
-rw-r--r--src/cgeo/geocaching/mapsforge/mfOverlay.java24
16 files changed, 184 insertions, 50 deletions
diff --git a/src/cgeo/geocaching/googlemaps/googleMapFactory.java b/src/cgeo/geocaching/googlemaps/googleMapFactory.java
index 28bfca5..9f44576 100644
--- a/src/cgeo/geocaching/googlemaps/googleMapFactory.java
+++ b/src/cgeo/geocaching/googlemaps/googleMapFactory.java
@@ -7,8 +7,6 @@ import cgeo.geocaching.cgUser;
import cgeo.geocaching.mapinterfaces.CacheOverlayItemImpl;
import cgeo.geocaching.mapinterfaces.GeoPointImpl;
import cgeo.geocaching.mapinterfaces.MapFactory;
-import cgeo.geocaching.mapinterfaces.OverlayBase;
-import cgeo.geocaching.mapinterfaces.OverlayImpl;
import cgeo.geocaching.mapinterfaces.UserOverlayItemImpl;
import com.google.android.maps.MapActivity;
@@ -35,11 +33,11 @@ public class googleMapFactory implements MapFactory{
return new googleGeoPoint(latE6, lonE6);
}
- @Override
- public OverlayImpl getOverlayBaseWrapper(OverlayBase ovlIn) {
- googleOverlay baseOvl = new googleOverlay(ovlIn);
- return baseOvl;
- }
+// @Override
+// public OverlayImpl getOverlayBaseWrapper(OverlayBase ovlIn) {
+// googleOverlay baseOvl = new googleOverlay(ovlIn);
+// return baseOvl;
+// }
@Override
public CacheOverlayItemImpl getCacheOverlayItem(cgCoord coordinate, String type) {
diff --git a/src/cgeo/geocaching/googlemaps/googleMapView.java b/src/cgeo/geocaching/googlemaps/googleMapView.java
index 737e64e..6fa1eb7 100644
--- a/src/cgeo/geocaching/googlemaps/googleMapView.java
+++ b/src/cgeo/geocaching/googlemaps/googleMapView.java
@@ -1,18 +1,23 @@
package cgeo.geocaching.googlemaps;
+import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import cgeo.geocaching.cgSettings;
+import cgeo.geocaching.mapcommon.cgMapMyOverlay;
import cgeo.geocaching.mapcommon.cgMapOverlay;
+import cgeo.geocaching.mapcommon.cgOverlayScale;
import cgeo.geocaching.mapcommon.cgUsersOverlay;
import cgeo.geocaching.mapinterfaces.GeoPointImpl;
import cgeo.geocaching.mapinterfaces.MapControllerImpl;
import cgeo.geocaching.mapinterfaces.MapProjectionImpl;
import cgeo.geocaching.mapinterfaces.MapViewImpl;
+import cgeo.geocaching.mapinterfaces.OverlayBase;
import cgeo.geocaching.mapinterfaces.OverlayImpl;
+import cgeo.geocaching.mapinterfaces.OverlayImpl.overlayType;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
@@ -97,6 +102,24 @@ public class googleMapView extends MapView implements MapViewImpl{
}
@Override
+ public cgMapMyOverlay createAddPositionOverlay(Activity activity,
+ cgSettings settingsIn) {
+
+ googleOverlay ovl = new googleOverlay(activity, settingsIn, overlayType.PositionOverlay);
+ getOverlays().add(ovl);
+ return (cgMapMyOverlay) ovl.getBase();
+ }
+
+ @Override
+ public cgOverlayScale createAddScaleOverlay(Activity activity,
+ cgSettings settingsIn) {
+
+ googleOverlay ovl = new googleOverlay(activity, settingsIn, overlayType.ScaleOverlay);
+ getOverlays().add(ovl);
+ return (cgOverlayScale) ovl.getBase();
+ }
+
+ @Override
public int getMapZoomLevel() {
return getZoomLevel();
}
@@ -105,14 +128,12 @@ public class googleMapView extends MapView implements MapViewImpl{
public void setMapSource(cgSettings settings) {
switch(settings.mapSource) {
- case googleSat:
- setSatellite(true);
- break;
- default:
- setSatellite(false);
- }
-
-
+ case googleSat:
+ setSatellite(true);
+ break;
+ default:
+ setSatellite(false);
+ }
}
@Override
@@ -124,4 +145,9 @@ public class googleMapView extends MapView implements MapViewImpl{
public void setBuiltinScale(boolean b) {
//Nothing to do for google maps...
}
+
+ @Override
+ public void repaintRequired(OverlayBase overlay) {
+ invalidate();
+ }
}
diff --git a/src/cgeo/geocaching/googlemaps/googleOverlay.java b/src/cgeo/geocaching/googlemaps/googleOverlay.java
index 3847d9f..97909be 100644
--- a/src/cgeo/geocaching/googlemaps/googleOverlay.java
+++ b/src/cgeo/geocaching/googlemaps/googleOverlay.java
@@ -1,6 +1,10 @@
package cgeo.geocaching.googlemaps;
+import android.app.Activity;
import android.graphics.Canvas;
+import cgeo.geocaching.cgSettings;
+import cgeo.geocaching.mapcommon.cgMapMyOverlay;
+import cgeo.geocaching.mapcommon.cgOverlayScale;
import cgeo.geocaching.mapinterfaces.MapViewImpl;
import cgeo.geocaching.mapinterfaces.OverlayBase;
import cgeo.geocaching.mapinterfaces.OverlayImpl;
@@ -10,17 +14,28 @@ import com.google.android.maps.Overlay;
public class googleOverlay extends Overlay implements OverlayImpl {
- private OverlayBase overlayBase;
+ private OverlayBase overlayBase = null;
- public googleOverlay(OverlayBase overlayBaseIn) {
- overlayBase = overlayBaseIn;
+ public googleOverlay(Activity activityIn, cgSettings settingsIn, overlayType ovlType) {
+ switch (ovlType) {
+ case PositionOverlay:
+ overlayBase = new cgMapMyOverlay(settingsIn, activityIn, this);
+ break;
+ case ScaleOverlay:
+ overlayBase = new cgOverlayScale(activityIn, settingsIn, this);
+ }
}
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
super.draw(canvas, mapView, shadow);
- overlayBase.draw(canvas, (MapViewImpl) mapView, shadow);
+ if (overlayBase != null) {
+ overlayBase.draw(canvas, (MapViewImpl) mapView, shadow);
+ }
}
+ public OverlayBase getBase() {
+ return overlayBase;
+ }
}
diff --git a/src/cgeo/geocaching/mapcommon/ItemizedOverlayBase.java b/src/cgeo/geocaching/mapcommon/ItemizedOverlayBase.java
index 41739e2..4e0379c 100644
--- a/src/cgeo/geocaching/mapcommon/ItemizedOverlayBase.java
+++ b/src/cgeo/geocaching/mapcommon/ItemizedOverlayBase.java
@@ -6,6 +6,8 @@ import android.graphics.drawable.Drawable;
import cgeo.geocaching.mapinterfaces.ItemizedOverlayImpl;
import cgeo.geocaching.mapinterfaces.MapProjectionImpl;
import cgeo.geocaching.mapinterfaces.MapViewImpl;
+import cgeo.geocaching.mapinterfaces.OverlayBase;
+import cgeo.geocaching.mapinterfaces.OverlayImpl;
import cgeo.geocaching.mapinterfaces.OverlayItemImpl;
/**
@@ -14,7 +16,7 @@ import cgeo.geocaching.mapinterfaces.OverlayItemImpl;
* @author rsudev
*
*/
-public abstract class ItemizedOverlayBase {
+public abstract class ItemizedOverlayBase implements OverlayBase {
private ItemizedOverlayImpl ovlImpl;
@@ -50,6 +52,11 @@ public abstract class ItemizedOverlayBase {
MapProjectionImpl projection, byte drawZoomLevel) {
ovlImpl.superDrawOverlayBitmap(canvas, drawPosition, projection, drawZoomLevel);
}
+
+ @Override
+ public OverlayImpl getOverlayImpl() {
+ return ovlImpl;
+ }
public abstract OverlayItemImpl createItem(int index);
diff --git a/src/cgeo/geocaching/mapcommon/cgMapMyOverlay.java b/src/cgeo/geocaching/mapcommon/cgMapMyOverlay.java
index cbf065c..caee721 100644
--- a/src/cgeo/geocaching/mapcommon/cgMapMyOverlay.java
+++ b/src/cgeo/geocaching/mapcommon/cgMapMyOverlay.java
@@ -7,9 +7,9 @@ import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
-import android.graphics.Paint.Style;
import android.graphics.PaintFlagsDrawFilter;
import android.graphics.Point;
+import android.graphics.Paint.Style;
import android.location.Location;
import cgeo.geocaching.R;
import cgeo.geocaching.cgBase;
@@ -19,6 +19,7 @@ import cgeo.geocaching.mapinterfaces.MapFactory;
import cgeo.geocaching.mapinterfaces.MapProjectionImpl;
import cgeo.geocaching.mapinterfaces.MapViewImpl;
import cgeo.geocaching.mapinterfaces.OverlayBase;
+import cgeo.geocaching.mapinterfaces.OverlayImpl;
public class cgMapMyOverlay implements OverlayBase {
private cgSettings settings = null;
@@ -41,11 +42,13 @@ public class cgMapMyOverlay implements OverlayBase {
private Point historyPointP = new Point();
private Activity activity;
private MapFactory mapFactory = null;
+ private OverlayImpl ovlImpl = null;
- public cgMapMyOverlay(cgSettings settingsIn, Activity activity) {
+ public cgMapMyOverlay(cgSettings settingsIn, Activity activity, OverlayImpl ovlImpl) {
settings = settingsIn;
this.activity = activity;
this.mapFactory = settings.getMapFactory();
+ this.ovlImpl = ovlImpl;
}
public void setCoordinates(Location coordinatesIn) {
@@ -202,4 +205,9 @@ public class cgMapMyOverlay implements OverlayBase {
//super.draw(canvas, mapView, shadow);
}
+
+ @Override
+ public OverlayImpl getOverlayImpl() {
+ return this.ovlImpl;
+ }
} \ No newline at end of file
diff --git a/src/cgeo/geocaching/mapcommon/cgMapOverlay.java b/src/cgeo/geocaching/mapcommon/cgMapOverlay.java
index 80eba5a..293f0c7 100644
--- a/src/cgeo/geocaching/mapcommon/cgMapOverlay.java
+++ b/src/cgeo/geocaching/mapcommon/cgMapOverlay.java
@@ -10,9 +10,9 @@ import android.content.Intent;
import android.graphics.Canvas;
import android.graphics.DashPathEffect;
import android.graphics.Paint;
-import android.graphics.Paint.Style;
import android.graphics.PaintFlagsDrawFilter;
import android.graphics.Point;
+import android.graphics.Paint.Style;
import android.location.Location;
import android.text.Html;
import android.util.Log;
diff --git a/src/cgeo/geocaching/mapcommon/cgOverlayScale.java b/src/cgeo/geocaching/mapcommon/cgOverlayScale.java
index 4aae3d5..93de894 100644
--- a/src/cgeo/geocaching/mapcommon/cgOverlayScale.java
+++ b/src/cgeo/geocaching/mapcommon/cgOverlayScale.java
@@ -14,6 +14,7 @@ import cgeo.geocaching.mapinterfaces.GeoPointImpl;
import cgeo.geocaching.mapinterfaces.MapProjectionImpl;
import cgeo.geocaching.mapinterfaces.MapViewImpl;
import cgeo.geocaching.mapinterfaces.OverlayBase;
+import cgeo.geocaching.mapinterfaces.OverlayImpl;
public class cgOverlayScale implements OverlayBase {
private cgSettings settings = null;
@@ -26,9 +27,11 @@ public class cgOverlayScale implements OverlayBase {
private double distance = 0d;
private double distanceRound = 0d;
private String units = null;
+ private OverlayImpl ovlImpl=null;
- public cgOverlayScale(Activity activity, cgSettings settingsIn) {
+ public cgOverlayScale(Activity activity, cgSettings settingsIn, OverlayImpl overlayImpl) {
settings = settingsIn;
+ this.ovlImpl = overlayImpl;
DisplayMetrics metrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
@@ -138,4 +141,9 @@ public class cgOverlayScale implements OverlayBase {
canvas.drawLine(10, bottom, (int)(pixels + 10), bottom, scale);
canvas.drawText(String.format("%.0f", distanceRound) + " " + units, (float)(pixels - (10 * pixelDensity)), (bottom - (10 * pixelDensity)), scale);
}
-} \ No newline at end of file
+
+ @Override
+ public OverlayImpl getOverlayImpl() {
+ return getOverlayImpl();
+ }
+}
diff --git a/src/cgeo/geocaching/mapcommon/cgeomap.java b/src/cgeo/geocaching/mapcommon/cgeomap.java
index a6c5066..3ed589e 100644
--- a/src/cgeo/geocaching/mapcommon/cgeomap.java
+++ b/src/cgeo/geocaching/mapcommon/cgeomap.java
@@ -28,13 +28,13 @@ import cgeo.geocaching.cgCoord;
import cgeo.geocaching.cgDirection;
import cgeo.geocaching.cgGeo;
import cgeo.geocaching.cgSettings;
-import cgeo.geocaching.cgSettings.mapSourceEnum;
import cgeo.geocaching.cgUpdateDir;
import cgeo.geocaching.cgUpdateLoc;
import cgeo.geocaching.cgUser;
import cgeo.geocaching.cgWaypoint;
import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.activity.ActivityMixin;
+import cgeo.geocaching.cgSettings.mapSourceEnum;
import cgeo.geocaching.mapinterfaces.ActivityImpl;
import cgeo.geocaching.mapinterfaces.CacheOverlayItemImpl;
import cgeo.geocaching.mapinterfaces.GeoPointImpl;
@@ -270,8 +270,7 @@ public class cgeomap extends MapBase {
mapView.clearOverlays();
if (overlayMyLoc == null) {
- overlayMyLoc = new cgMapMyOverlay(settings, activity);
- mapView.addOverlay(mapFactory.getOverlayBaseWrapper(overlayMyLoc));
+ overlayMyLoc = mapView.createAddPositionOverlay(activity, settings);
}
if (settings.publicLoc > 0 && overlayUsers == null) {
@@ -283,8 +282,7 @@ public class cgeomap extends MapBase {
}
if (overlayScale == null && mapView.needsScaleOverlay()) {
- overlayScale = new cgOverlayScale(activity, settings);
- mapView.addOverlay(mapFactory.getOverlayBaseWrapper(overlayScale));
+ overlayScale = mapView.createAddScaleOverlay(activity, settings);
}
mapView.invalidate();
@@ -748,9 +746,10 @@ public class cgeomap extends MapBase {
}
try {
+ boolean repaintRequired = false;
+
if (overlayMyLoc == null && mapView != null) {
- overlayMyLoc = new cgMapMyOverlay(settings, activity);
- mapView.addOverlay(settings.getMapFactory().getOverlayBaseWrapper(overlayMyLoc));
+ overlayMyLoc = mapView.createAddPositionOverlay(activity, settings);
}
if (overlayMyLoc != null && geo.location != null) {
@@ -761,8 +760,7 @@ public class cgeomap extends MapBase {
if (followMyLocation) {
myLocationInMiddle();
} else {
- // move blue arrow
- mapView.invalidate();
+ repaintRequired = true;
}
}
@@ -772,7 +770,13 @@ public class cgeomap extends MapBase {
} else {
overlayMyLoc.setHeading(Double.valueOf(0));
}
+ repaintRequired = true;
}
+
+ if (repaintRequired) {
+ mapView.repaintRequired(overlayMyLoc);
+ }
+
} catch (Exception e) {
Log.w(cgSettings.tag, "Failed to update location.");
}
diff --git a/src/cgeo/geocaching/mapinterfaces/ItemizedOverlayImpl.java b/src/cgeo/geocaching/mapinterfaces/ItemizedOverlayImpl.java
index 73eed1f..08e28ad 100644
--- a/src/cgeo/geocaching/mapinterfaces/ItemizedOverlayImpl.java
+++ b/src/cgeo/geocaching/mapinterfaces/ItemizedOverlayImpl.java
@@ -1,9 +1,9 @@
package cgeo.geocaching.mapinterfaces;
-import cgeo.geocaching.mapcommon.ItemizedOverlayBase;
import android.graphics.Canvas;
import android.graphics.Point;
import android.graphics.drawable.Drawable;
+import cgeo.geocaching.mapcommon.ItemizedOverlayBase;
/**
* Defines the common functions to access the provider-specific
@@ -11,7 +11,7 @@ import android.graphics.drawable.Drawable;
* @author rsudev
*
*/
-public interface ItemizedOverlayImpl {
+public interface ItemizedOverlayImpl extends OverlayImpl {
ItemizedOverlayBase getBase();
diff --git a/src/cgeo/geocaching/mapinterfaces/MapFactory.java b/src/cgeo/geocaching/mapinterfaces/MapFactory.java
index 620f673..1950e9a 100644
--- a/src/cgeo/geocaching/mapinterfaces/MapFactory.java
+++ b/src/cgeo/geocaching/mapinterfaces/MapFactory.java
@@ -21,7 +21,7 @@ public interface MapFactory {
public GeoPointImpl getGeoPointBase(int latE6, int lonE6);
- public OverlayImpl getOverlayBaseWrapper(OverlayBase ovlIn);
+// public OverlayImpl getOverlayBaseWrapper(OverlayBase ovlIn);
CacheOverlayItemImpl getCacheOverlayItem(cgCoord coordinate, String type);
diff --git a/src/cgeo/geocaching/mapinterfaces/MapViewImpl.java b/src/cgeo/geocaching/mapinterfaces/MapViewImpl.java
index 5c955ed..8e99b3d 100644
--- a/src/cgeo/geocaching/mapinterfaces/MapViewImpl.java
+++ b/src/cgeo/geocaching/mapinterfaces/MapViewImpl.java
@@ -1,10 +1,13 @@
package cgeo.geocaching.mapinterfaces;
+import android.app.Activity;
+import android.content.Context;
+import android.graphics.drawable.Drawable;
import cgeo.geocaching.cgSettings;
+import cgeo.geocaching.mapcommon.cgMapMyOverlay;
import cgeo.geocaching.mapcommon.cgMapOverlay;
+import cgeo.geocaching.mapcommon.cgOverlayScale;
import cgeo.geocaching.mapcommon.cgUsersOverlay;
-import android.content.Context;
-import android.graphics.drawable.Drawable;
/**
* Defines common functions of the provider-specific
@@ -50,6 +53,10 @@ public interface MapViewImpl {
Drawable drawable, boolean fromDetailIntent);
cgUsersOverlay createAddUsersOverlay(Context context, Drawable markerIn);
+
+ cgOverlayScale createAddScaleOverlay(Activity activity, cgSettings settingsIn);
+
+ cgMapMyOverlay createAddPositionOverlay(Activity activity, cgSettings settingsIn);
boolean needsScaleOverlay();
@@ -57,4 +64,6 @@ public interface MapViewImpl {
void setMapSource(cgSettings settings);
+ void repaintRequired(OverlayBase overlay);
+
}
diff --git a/src/cgeo/geocaching/mapinterfaces/OverlayBase.java b/src/cgeo/geocaching/mapinterfaces/OverlayBase.java
index 59afb49..17a4d85 100644
--- a/src/cgeo/geocaching/mapinterfaces/OverlayBase.java
+++ b/src/cgeo/geocaching/mapinterfaces/OverlayBase.java
@@ -16,4 +16,5 @@ public interface OverlayBase {
void drawOverlayBitmap(Canvas canvas, Point drawPosition,
MapProjectionImpl projection, byte drawZoomLevel);
+ OverlayImpl getOverlayImpl();
}
diff --git a/src/cgeo/geocaching/mapinterfaces/OverlayImpl.java b/src/cgeo/geocaching/mapinterfaces/OverlayImpl.java
index 6680b6a..bd5b8ef 100644
--- a/src/cgeo/geocaching/mapinterfaces/OverlayImpl.java
+++ b/src/cgeo/geocaching/mapinterfaces/OverlayImpl.java
@@ -8,4 +8,9 @@ package cgeo.geocaching.mapinterfaces;
*/
public interface OverlayImpl {
+ public enum overlayType {
+ PositionOverlay,
+ ScaleOverlay
+ }
+
}
diff --git a/src/cgeo/geocaching/mapsforge/mfMapFactory.java b/src/cgeo/geocaching/mapsforge/mfMapFactory.java
index fa665ec..f72f12f 100644
--- a/src/cgeo/geocaching/mapsforge/mfMapFactory.java
+++ b/src/cgeo/geocaching/mapsforge/mfMapFactory.java
@@ -8,8 +8,6 @@ import cgeo.geocaching.cgUser;
import cgeo.geocaching.mapinterfaces.CacheOverlayItemImpl;
import cgeo.geocaching.mapinterfaces.GeoPointImpl;
import cgeo.geocaching.mapinterfaces.MapFactory;
-import cgeo.geocaching.mapinterfaces.OverlayBase;
-import cgeo.geocaching.mapinterfaces.OverlayImpl;
import cgeo.geocaching.mapinterfaces.UserOverlayItemImpl;
public class mfMapFactory implements MapFactory{
@@ -34,11 +32,11 @@ public class mfMapFactory implements MapFactory{
return new mfGeoPoint(latE6, lonE6);
}
- @Override
- public OverlayImpl getOverlayBaseWrapper(OverlayBase ovlIn) {
- mfOverlay baseOvl = new mfOverlay(ovlIn);
- return baseOvl;
- }
+// @Override
+// public OverlayImpl getOverlayBaseWrapper(OverlayBase ovlIn) {
+// mfOverlay baseOvl = new mfOverlay(ovlIn);
+// return baseOvl;
+// }
@Override
public CacheOverlayItemImpl getCacheOverlayItem(cgCoord coordinate, String type) {
diff --git a/src/cgeo/geocaching/mapsforge/mfMapView.java b/src/cgeo/geocaching/mapsforge/mfMapView.java
index de4bd1a..43aa954 100644
--- a/src/cgeo/geocaching/mapsforge/mfMapView.java
+++ b/src/cgeo/geocaching/mapsforge/mfMapView.java
@@ -7,19 +7,24 @@ import org.mapsforge.android.maps.MapViewMode;
import org.mapsforge.android.maps.Overlay;
import org.mapsforge.android.maps.Projection;
+import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.util.Log;
import cgeo.geocaching.cgSettings;
+import cgeo.geocaching.mapcommon.cgMapMyOverlay;
import cgeo.geocaching.mapcommon.cgMapOverlay;
+import cgeo.geocaching.mapcommon.cgOverlayScale;
import cgeo.geocaching.mapcommon.cgUsersOverlay;
import cgeo.geocaching.mapinterfaces.GeoPointImpl;
import cgeo.geocaching.mapinterfaces.MapControllerImpl;
import cgeo.geocaching.mapinterfaces.MapProjectionImpl;
import cgeo.geocaching.mapinterfaces.MapViewImpl;
+import cgeo.geocaching.mapinterfaces.OverlayBase;
import cgeo.geocaching.mapinterfaces.OverlayImpl;
+import cgeo.geocaching.mapinterfaces.OverlayImpl.overlayType;
public class mfMapView extends MapView implements MapViewImpl {
@@ -88,6 +93,22 @@ public class mfMapView extends MapView implements MapViewImpl {
}
@Override
+ public cgMapMyOverlay createAddPositionOverlay(Activity activity,
+ cgSettings settingsIn) {
+ mfOverlay ovl = new mfOverlay(activity, settingsIn, overlayType.PositionOverlay);
+ getOverlays().add(ovl);
+ return (cgMapMyOverlay) ovl.getBase();
+ }
+
+ @Override
+ public cgOverlayScale createAddScaleOverlay(Activity activity,
+ cgSettings settingsIn) {
+ mfOverlay ovl = new mfOverlay(activity, settingsIn, overlayType.ScaleOverlay);
+ getOverlays().add(ovl);
+ return (cgOverlayScale) ovl.getBase();
+ }
+
+ @Override
public int getLatitudeSpan() {
int span = 0;
@@ -160,10 +181,28 @@ public class mfMapView extends MapView implements MapViewImpl {
if (MapDatabase.isValidMapFile(settings.getMapFile())) {
setMapViewMode(MapViewMode.CANVAS_RENDERER);
super.setMapFile(settings.getMapFile());
+ } else {
+ setMapViewMode(MapViewMode.MAPNIK_TILE_DOWNLOAD);
}
break;
default:
setMapViewMode(MapViewMode.MAPNIK_TILE_DOWNLOAD);
}
}
+
+ @Override
+ public void repaintRequired(OverlayBase overlay) {
+
+ try {
+ mfOverlay ovl = (mfOverlay) overlay.getOverlayImpl();
+
+ if (ovl != null) {
+ ovl.requestRedraw();
+ }
+
+ } catch (Exception e) {
+ Log.e(cgSettings.tag, "mfMapView.repaintRequired: " + e.toString());
+ }
+ }
+
}
diff --git a/src/cgeo/geocaching/mapsforge/mfOverlay.java b/src/cgeo/geocaching/mapsforge/mfOverlay.java
index e015307..833d382 100644
--- a/src/cgeo/geocaching/mapsforge/mfOverlay.java
+++ b/src/cgeo/geocaching/mapsforge/mfOverlay.java
@@ -3,24 +3,40 @@ package cgeo.geocaching.mapsforge;
import org.mapsforge.android.maps.Overlay;
import org.mapsforge.android.maps.Projection;
+import android.app.Activity;
import android.graphics.Canvas;
import android.graphics.Point;
+import cgeo.geocaching.cgSettings;
+import cgeo.geocaching.mapcommon.cgMapMyOverlay;
+import cgeo.geocaching.mapcommon.cgOverlayScale;
import cgeo.geocaching.mapinterfaces.OverlayBase;
import cgeo.geocaching.mapinterfaces.OverlayImpl;
public class mfOverlay extends Overlay implements OverlayImpl {
- private OverlayBase overlayBase;
+ private OverlayBase overlayBase = null;
- public mfOverlay(OverlayBase overlayBaseIn) {
- overlayBase = overlayBaseIn;
+ public mfOverlay(Activity activityIn, cgSettings settingsIn, OverlayImpl.overlayType ovlType) {
+
+ switch (ovlType) {
+ case PositionOverlay:
+ overlayBase = new cgMapMyOverlay(settingsIn, activityIn, this);
+ break;
+ case ScaleOverlay:
+ overlayBase = new cgOverlayScale(activityIn, settingsIn, this);
+ }
}
@Override
protected void drawOverlayBitmap(Canvas canvas, Point drawPosition,
Projection projection, byte drawZoomLevel) {
- overlayBase.drawOverlayBitmap(canvas, drawPosition, new mfMapProjection(projection), drawZoomLevel);
+ if (overlayBase != null) {
+ overlayBase.drawOverlayBitmap(canvas, drawPosition, new mfMapProjection(projection), drawZoomLevel);
+ }
}
+ public OverlayBase getBase() {
+ return overlayBase;
+ }
}