diff options
| -rw-r--r-- | res/values/strings.xml | 4 | ||||
| -rw-r--r-- | src/cgeo/geocaching/cgSettings.java | 54 | ||||
| -rw-r--r-- | src/cgeo/geocaching/cgeoinit.java | 17 | ||||
| -rw-r--r-- | src/cgeo/geocaching/googlemaps/googleMapView.java | 14 | ||||
| -rw-r--r-- | src/cgeo/geocaching/mapcommon/cgOverlayScale.java | 3 | ||||
| -rw-r--r-- | src/cgeo/geocaching/mapcommon/cgeomap.java | 193 | ||||
| -rw-r--r-- | src/cgeo/geocaching/mapinterfaces/MapViewImpl.java | 4 | ||||
| -rw-r--r-- | src/cgeo/geocaching/mapsforge/mfMapController.java | 4 | ||||
| -rw-r--r-- | src/cgeo/geocaching/mapsforge/mfMapView.java | 25 |
9 files changed, 203 insertions, 115 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml index b2b7f08..2715581 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -416,7 +416,8 @@ <!-- map sources --> <string-array name="map_sources"> - <item>Google Maps</item> + <item>Google: Map</item> + <item>Google: Satellite</item> <item>OSM: Mapnik</item> <item>OSM: Osmarender</item> <item>OSM: Cyclemap</item> @@ -595,7 +596,6 @@ <!-- map --> <string name="map_map">Map</string> <string name="map_live">Live map</string> - <string name="map_view_satellite">Satellite view</string> <string name="map_view_map">Map view</string> <string name="map_trail_show">Show trail</string> <string name="map_trail_hide">Hide trail</string> diff --git a/src/cgeo/geocaching/cgSettings.java b/src/cgeo/geocaching/cgSettings.java index 5c99108..97e8c5c 100644 --- a/src/cgeo/geocaching/cgSettings.java +++ b/src/cgeo/geocaching/cgSettings.java @@ -4,6 +4,8 @@ import java.util.Locale; import java.util.Map; import java.util.HashMap; +import org.mapsforge.android.maps.MapDatabase; + import cgeo.geocaching.googlemaps.googleMapFactory; import cgeo.geocaching.mapinterfaces.MapFactory; import cgeo.geocaching.mapsforge.mfMapFactory; @@ -18,6 +20,7 @@ public class cgSettings { public enum mapSourceEnum { googleMap, + googleSat, mapsforgeMapnik, mapsforgeOsmarender, mapsforgeCycle, @@ -31,13 +34,19 @@ public class cgSettings { return googleMap; } } + + public boolean isGoogleMapSource() { + if (googleMap == this || googleSat == this) { + return true; + } + + return false; + } } // constants public final static int unitsMetric = 1; public final static int unitsImperial = 2; - public final static int mapSatellite = 1; - public final static int mapClassic = 2; public final static String cache = ".cgeo"; public final static String analytics = "UA-1103507-15"; @@ -64,7 +73,6 @@ public class cgSettings { public int autoLoadDesc = 0; public int units = unitsMetric; public int livelist = 1; - public int maptype = mapSatellite; public int mapzoom = 14; public int maplive = 1; public int maptrail = 1; @@ -103,12 +111,11 @@ public class cgSettings { private String passVote = null; // maps - public static final int MAP_GOOGLE = 0; - public static final int MAP_MF = 1; public MapFactory mapFactory = null; - public mapSourceEnum mapProviderUsed = mapSourceEnum.googleMap; - public mapSourceEnum mapProvider = mapSourceEnum.googleMap; - public String mapFile = null; + public mapSourceEnum mapSourceUsed = mapSourceEnum.googleMap; + public mapSourceEnum mapSource = mapSourceEnum.googleMap; + private String mapFile = null; + private boolean mapFileValid = false; public cgSettings(Context contextIn, SharedPreferences prefsIn) { context = contextIn; @@ -131,7 +138,6 @@ public class cgSettings { autoLoadDesc = prefs.getInt("autoloaddesc", 0); units = prefs.getInt("units", 1); livelist = prefs.getInt("livelist", 1); - maptype = prefs.getInt("maptype", 1); maplive = prefs.getInt("maplive", 1); mapzoom = prefs.getInt("mapzoom", 14); maptrail = prefs.getInt("maptrail", 1); @@ -152,7 +158,8 @@ public class cgSettings { tokenPublic = prefs.getString("tokenpublic", null); tokenSecret = prefs.getString("tokensecret", null); mapFile = prefs.getString("mfmapfile", null); - mapProvider = mapSourceEnum.fromInt(prefs.getInt("mapsource", 0)); + mapFileValid = checkMapfile(mapFile); + mapSource = mapSourceEnum.fromInt(prefs.getInt("mapsource", 0)); webDeviceName = prefs.getString("webDeviceName", null); webDeviceCode = prefs.getString("webDeviceCode", null); trackableAutovisit = prefs.getBoolean("trackautovisit", false); @@ -482,15 +489,15 @@ public class cgSettings { } public MapFactory getMapFactory() { - if (mapProvider == mapSourceEnum.googleMap) { - if (mapProviderUsed != mapSourceEnum.googleMap || mapFactory == null) { + if (mapSource.isGoogleMapSource()) { + if (!mapSourceUsed.isGoogleMapSource() || mapFactory == null) { mapFactory = new googleMapFactory(); - mapProviderUsed = mapProvider; + mapSourceUsed = mapSource; } - } else if (mapProvider != mapSourceEnum.googleMap) { - if (mapProviderUsed == mapSourceEnum.googleMap || mapFactory == null) { + } else if (!mapSource.isGoogleMapSource()) { + if (mapSourceUsed.isGoogleMapSource() || mapFactory == null) { mapFactory = new mfMapFactory(); - mapProviderUsed = mapProvider; + mapSourceUsed = mapSource; } } @@ -505,12 +512,23 @@ public class cgSettings { final SharedPreferences.Editor prefsEdit = prefs.edit(); prefsEdit.putString("mfmapfile", mapFileIn); + + boolean commitResult = prefsEdit.commit(); mapFile = mapFileIn; - - return prefsEdit.commit(); + mapFileValid = checkMapfile(mapFile); + + return commitResult; + } + + public boolean hasValidMapFile() { + return mapFileValid; } + private boolean checkMapfile(String mapFileIn) { + return MapDatabase.isValidMapFile(mapFileIn); + } + public Context getContext() { return context; } diff --git a/src/cgeo/geocaching/cgeoinit.java b/src/cgeo/geocaching/cgeoinit.java index 2734e1f..8cd5533 100644 --- a/src/cgeo/geocaching/cgeoinit.java +++ b/src/cgeo/geocaching/cgeoinit.java @@ -432,8 +432,6 @@ public class cgeoinit extends Activity { } }); - setMapFileEditState(); - // Cache db backup TextView lastBackup = (TextView) findViewById(R.id.backup_last); File lastBackupFile = app.isRestoreFile(); @@ -481,15 +479,6 @@ public class cgeoinit extends Activity { } } - private void setMapFileEditState() { - LinearLayout mapFileEdit = (LinearLayout) findViewById(R.id.init_mapfilegroup); - if (settings.mapProvider == mapSourceEnum.mapsforgeOffline) { - mapFileEdit.setVisibility(View.VISIBLE); - } else { - mapFileEdit.setVisibility(View.INVISIBLE); - } - } - public boolean saveValues() { String usernameNew = ((EditText) findViewById(R.id.username)).getText().toString(); String passwordNew = ((EditText) findViewById(R.id.password)).getText().toString(); @@ -941,17 +930,15 @@ public class cgeoinit extends Activity { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { - settings.mapProvider = mapSourceEnum.fromInt(arg2); + settings.mapSource = mapSourceEnum.fromInt(arg2); SharedPreferences.Editor edit = prefs.edit(); edit.putInt("mapsource", arg2); edit.commit(); - setMapFileEditState(); } @Override public void onNothingSelected(AdapterView<?> arg0) { - arg0.setSelection(settings.mapProvider.ordinal()); - setMapFileEditState(); + arg0.setSelection(settings.mapSource.ordinal()); } } diff --git a/src/cgeo/geocaching/googlemaps/googleMapView.java b/src/cgeo/geocaching/googlemaps/googleMapView.java index b63ca2e..48b8a38 100644 --- a/src/cgeo/geocaching/googlemaps/googleMapView.java +++ b/src/cgeo/geocaching/googlemaps/googleMapView.java @@ -1,5 +1,8 @@ package cgeo.geocaching.googlemaps; +import org.mapsforge.android.maps.MapDatabase; +import org.mapsforge.android.maps.MapViewMode; + import android.content.Context; import android.graphics.Canvas; import android.graphics.drawable.Drawable; @@ -103,7 +106,16 @@ public class googleMapView extends MapView implements MapViewImpl{ @Override public void setMapSource(cgSettings settings) { - // nothing to do for google maps... + + switch(settings.mapSource) { + case googleSat: + setSatellite(true); + break; + default: + setSatellite(false); + } + + } @Override diff --git a/src/cgeo/geocaching/mapcommon/cgOverlayScale.java b/src/cgeo/geocaching/mapcommon/cgOverlayScale.java index 1e4a6e6..3449061 100644 --- a/src/cgeo/geocaching/mapcommon/cgOverlayScale.java +++ b/src/cgeo/geocaching/mapcommon/cgOverlayScale.java @@ -9,6 +9,7 @@ import android.graphics.Typeface; import android.util.DisplayMetrics; import cgeo.geocaching.cgBase; import cgeo.geocaching.cgSettings; +import cgeo.geocaching.cgSettings.mapSourceEnum; import cgeo.geocaching.mapinterfaces.GeoPointImpl; import cgeo.geocaching.mapinterfaces.MapProjectionImpl; import cgeo.geocaching.mapinterfaces.OverlayBase; @@ -119,7 +120,7 @@ public class cgOverlayScale implements OverlayBase { scale.setTypeface(Typeface.DEFAULT_BOLD); } - if (mapView.isSatellite()) { + if (mapSourceEnum.googleSat == settings.mapSource) { scaleShadow.setColor(0xFF000000); scale.setColor(0xFFFFFFFF); } else { diff --git a/src/cgeo/geocaching/mapcommon/cgeomap.java b/src/cgeo/geocaching/mapcommon/cgeomap.java index 1623d93..f0e7638 100644 --- a/src/cgeo/geocaching/mapcommon/cgeomap.java +++ b/src/cgeo/geocaching/mapcommon/cgeomap.java @@ -9,6 +9,7 @@ import java.util.Locale; import android.app.Activity; import android.app.ProgressDialog; import android.content.DialogInterface; +import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Resources; import android.graphics.drawable.Drawable; @@ -18,6 +19,7 @@ import android.os.Message; import android.util.Log; import android.view.Menu; import android.view.MenuItem; +import android.view.SubMenu; import android.view.View; import android.view.WindowManager; import android.widget.ImageView; @@ -28,6 +30,7 @@ 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; @@ -43,6 +46,19 @@ import cgeo.geocaching.mapinterfaces.MapViewImpl; import cgeo.geocaching.mapinterfaces.UserOverlayItemImpl; public class cgeomap extends MapBase { + + private static final int MENU_SELECT_MAPVIEW = 1; + private static final int MENU_MAP_LIVE = 2; + private static final int MENU_STORE_CACHES = 3; + private static final int MENU_TRAIL_MODE = 4; + private static final int MENU_CIRCLE_MODE = 5; + + private static final int SUBMENU_VIEW_GOOGLE_MAP = 10; + private static final int SUBMENU_VIEW_GOOGLE_SAT = 11; + private static final int SUBMENU_VIEW_MF_MAPNIK = 13; + private static final int SUBMENU_VIEW_MF_OSMARENDER = 14; + private static final int SUBMENU_VIEW_MF_CYCLEMAP = 15; + private static final int SUBMENU_VIEW_MF_OFFLINE = 16; private Resources res = null; private Activity activity = null; @@ -64,6 +80,7 @@ public class cgeomap extends MapBase { private Double latitudeIntent = null; private Double longitudeIntent = null; private String waypointTypeIntent = null; + private int[] mapStateIntent = null; // status data private Long searchId = null; private String token = null; @@ -247,18 +264,12 @@ public class cgeomap extends MapBase { dir = app.startDir(activity, dirUpdate, warning); } + // initialize map mapView = (MapViewImpl) activity.findViewById(mapFactory.getMapViewId()); mapView.setMapSource(settings); if (!mapView.needsScaleOverlay()) { mapView.setBuiltinScale(true); } - - // initialize map - if (settings.maptype == cgSettings.mapSatellite) { - mapView.setSatellite(true); - } else { - mapView.setSatellite(false); - } mapView.setBuiltInZoomControls(true); mapView.displayZoomControls(true); mapView.preLoad(); @@ -306,6 +317,7 @@ public class cgeomap extends MapBase { latitudeIntent = extras.getDouble("latitude"); longitudeIntent = extras.getDouble("longitude"); waypointTypeIntent = extras.getString("wpttype"); + mapStateIntent = extras.getIntArray("mapstate"); if (searchIdIntent == 0l) { searchIdIntent = null; @@ -334,11 +346,12 @@ public class cgeomap extends MapBase { base.sendAnal(activity, "/map/normal"); followMyLocation = false; - - if (geocodeIntent != null || searchIdIntent != null || (latitudeIntent != null && longitudeIntent != null)) { - centerMap(geocodeIntent, searchIdIntent, latitudeIntent, longitudeIntent); - } } + if (geocodeIntent != null || searchIdIntent != null || (latitudeIntent != null && longitudeIntent != null) || mapStateIntent != null) { + centerMap(geocodeIntent, searchIdIntent, latitudeIntent, longitudeIntent, mapStateIntent); + } + + setMyLoc(null); startTimer(); } @@ -453,14 +466,28 @@ public class cgeomap extends MapBase { @Override public boolean onCreateOptionsMenu(Menu menu) { - menu.add(0, 1, 0, res.getString(R.string.caches_on_map)).setIcon(android.R.drawable.ic_menu_mapmode); - menu.add(0, 3, 0, res.getString(R.string.map_live_disable)).setIcon(android.R.drawable.ic_menu_close_clear_cancel); - menu.add(0, 4, 0, res.getString(R.string.caches_store_offline)).setIcon(android.R.drawable.ic_menu_set_as).setEnabled(false); - menu.add(0, 2, 0, res.getString(R.string.map_trail_hide)).setIcon(android.R.drawable.ic_menu_recent_history); - menu.add(0, 5, 0, res.getString(R.string.map_circles_hide)).setIcon(android.R.drawable.ic_menu_view); + + SubMenu submenu = menu.addSubMenu(1, MENU_SELECT_MAPVIEW, 0, res.getString(R.string.map_view_map)).setIcon(android.R.drawable.ic_menu_more); + addMapViewMenuItems(submenu); + + menu.add(0, MENU_MAP_LIVE, 0, res.getString(R.string.map_live_disable)).setIcon(android.R.drawable.ic_menu_close_clear_cancel); + menu.add(0, MENU_STORE_CACHES, 0, res.getString(R.string.caches_store_offline)).setIcon(android.R.drawable.ic_menu_set_as).setEnabled(false); + menu.add(0, MENU_TRAIL_MODE, 0, res.getString(R.string.map_trail_hide)).setIcon(android.R.drawable.ic_menu_recent_history); + menu.add(0, MENU_CIRCLE_MODE, 0, res.getString(R.string.map_circles_hide)).setIcon(android.R.drawable.ic_menu_view); return true; } + + private void addMapViewMenuItems(final Menu menu) { + String[] mapViews = res.getStringArray(R.array.map_sources); + + menu.add(0, SUBMENU_VIEW_GOOGLE_MAP, 0, mapViews[0]); + menu.add(0, SUBMENU_VIEW_GOOGLE_SAT, 0, mapViews[1]); + menu.add(0, SUBMENU_VIEW_MF_MAPNIK, 0, mapViews[2]); + menu.add(0, SUBMENU_VIEW_MF_OSMARENDER, 0, mapViews[3]); + menu.add(0, SUBMENU_VIEW_MF_CYCLEMAP, 0, mapViews[4]); + menu.add(0, SUBMENU_VIEW_MF_OFFLINE, 0, mapViews[5]); + } @Override public boolean onPrepareOptionsMenu(Menu menu) { @@ -468,21 +495,14 @@ public class cgeomap extends MapBase { MenuItem item; try { - item = menu.findItem(1); // view - if (mapView != null && mapView.isSatellite() == false) { - item.setTitle(res.getString(R.string.map_view_satellite)); - } else { - item.setTitle(res.getString(R.string.map_view_map)); - } - - item = menu.findItem(2); // show trail + item = menu.findItem(MENU_TRAIL_MODE); // show trail if (settings.maptrail == 1) { item.setTitle(res.getString(R.string.map_trail_hide)); } else { item.setTitle(res.getString(R.string.map_trail_show)); } - item = menu.findItem(3); // live map + item = menu.findItem(MENU_MAP_LIVE); // live map if (live == false) { item.setEnabled(false); item.setTitle(res.getString(R.string.map_live_enable)); @@ -494,19 +514,26 @@ public class cgeomap extends MapBase { } } - item = menu.findItem(4); // store loaded + item = menu.findItem(MENU_STORE_CACHES); // store loaded if (live && !isLoading() && app.getNotOfflineCount(searchId) > 0 && caches != null && caches.size() > 0) { item.setEnabled(true); } else { item.setEnabled(false); } - item = menu.findItem(5); // show circles + item = menu.findItem(MENU_CIRCLE_MODE); // show circles if (overlayCaches != null && overlayCaches.getCircles()) { item.setTitle(res.getString(R.string.map_circles_hide)); } else { item.setTitle(res.getString(R.string.map_circles_show)); } + + item = menu.findItem(SUBMENU_VIEW_MF_OFFLINE); + if (settings.hasValidMapFile()) { + item.setEnabled(true); + } else { + item.setEnabled(false); + } } catch (Exception e) { Log.e(cgSettings.tag, "cgeomap.onPrepareOptionsMenu: " + e.toString()); } @@ -518,21 +545,7 @@ public class cgeomap extends MapBase { public boolean onOptionsItemSelected(MenuItem item) { final int id = item.getItemId(); - if (id == 1) { - if (mapView != null && mapView.isSatellite() == false) { - mapView.setSatellite(true); - - prefsEdit.putInt("maptype", cgSettings.mapSatellite); - prefsEdit.commit(); - } else { - mapView.setSatellite(false); - - prefsEdit.putInt("maptype", cgSettings.mapClassic); - prefsEdit.commit(); - } - - return true; - } else if (id == 2) { + if (id == MENU_TRAIL_MODE) { if (settings.maptrail == 1) { prefsEdit.putInt("maptrail", 0); prefsEdit.commit(); @@ -544,7 +557,7 @@ public class cgeomap extends MapBase { settings.maptrail = 1; } - } else if (id == 3) { + } else if (id == MENU_MAP_LIVE) { if (settings.maplive == 1) { settings.liveMapDisable(); } else { @@ -553,7 +566,7 @@ public class cgeomap extends MapBase { liveChanged = true; searchId = null; searchIdIntent = null; - } else if (id == 4) { + } else if (id == MENU_STORE_CACHES) { if (live && !isLoading() && caches != null && !caches.isEmpty()) { final ArrayList<String> geocodes = new ArrayList<String>(); @@ -627,33 +640,92 @@ public class cgeomap extends MapBase { return true; } - } else if (id == 5) { + } else if (id == MENU_CIRCLE_MODE) { if (overlayCaches == null) { return false; } overlayCaches.switchCircles(); + + } else if (SUBMENU_VIEW_GOOGLE_MAP <= id && SUBMENU_VIEW_MF_OFFLINE >= id) { + + mapSourceEnum mapSource = getMapSourceFromMenuId(id); + + boolean mapRestartRequired = switchMapSource(mapSource); + + if (mapRestartRequired) { + Intent mapIntent = new Intent(activity, settings.getMapFactory().getMapClass()); + + mapIntent.putExtra("detail", fromDetailIntent); + mapIntent.putExtra("searchid", searchIdIntent); + mapIntent.putExtra("geocode", geocodeIntent); + mapIntent.putExtra("latitude", latitudeIntent); + mapIntent.putExtra("longitude", longitudeIntent); + mapIntent.putExtra("wpttype", waypointTypeIntent); + int[] mapState = new int[3]; + GeoPointImpl mapCenter = mapView.getMapViewCenter(); + mapState[0] = mapCenter.getLatitudeE6(); + mapState[1] = mapCenter.getLongitudeE6(); + mapState[2] = mapView.getMapZoomLevel(); + mapIntent.putExtra("mapstate", mapState); + + activity.startActivity(mapIntent); + + activity.finish(); + } + + return true; } + return false; } + + private mapSourceEnum getMapSourceFromMenuId(int menuItemId) { + + switch(menuItemId) { + case SUBMENU_VIEW_GOOGLE_MAP: + return mapSourceEnum.googleMap; + case SUBMENU_VIEW_GOOGLE_SAT: + return mapSourceEnum.googleSat; + case SUBMENU_VIEW_MF_OSMARENDER: + return mapSourceEnum.mapsforgeOsmarender; + case SUBMENU_VIEW_MF_MAPNIK: + return mapSourceEnum.mapsforgeMapnik; + case SUBMENU_VIEW_MF_CYCLEMAP: + return mapSourceEnum.mapsforgeCycle; + case SUBMENU_VIEW_MF_OFFLINE: + return mapSourceEnum.mapsforgeOffline; + default: + return mapSourceEnum.googleMap; + } + } + + private boolean switchMapSource(mapSourceEnum mapSource) { + + settings.mapSource = mapSource; + + prefsEdit.putInt("mapsource", settings.mapSource.ordinal()); + prefsEdit.commit(); + + boolean mapRestartRequired = settings.mapSource.isGoogleMapSource()!= settings.mapSourceUsed.isGoogleMapSource(); + + if (!mapRestartRequired) { + mapView.setMapSource(settings); + } + + return mapRestartRequired; + } private void savePrefs() { if (mapView == null) { return; } - if (mapView.isSatellite()) { - prefsEdit.putInt("maptype", cgSettings.mapSatellite); - settings.maptype = cgSettings.mapSatellite; - } else { - prefsEdit.putInt("maptype", cgSettings.mapClassic); - settings.maptype = cgSettings.mapClassic; - } - if (prefsEdit == null) { prefsEdit = activity.getSharedPreferences(cgSettings.preferences, 0).edit(); } + prefsEdit.putInt("mapzoom", mapView.getMapZoomLevel()); prefsEdit.commit(); } @@ -1578,8 +1650,19 @@ public class cgeomap extends MapBase { } // move map to view results of searchIdIntent - private void centerMap(String geocodeCenter, Long searchIdCenter, Double latitudeCenter, Double longitudeCenter) { - if (!centered && (geocodeCenter != null || searchIdIntent != null)) { + private void centerMap(String geocodeCenter, Long searchIdCenter, Double latitudeCenter, Double longitudeCenter, int[] mapState) { + + if (!centered && mapState != null) { + try { + mapController.setCenter(settings.getMapFactory().getGeoPointBase(mapState[0], mapState[1])); + mapController.setZoom(mapState[2]); + } catch (Exception e) { + // nothing at all + } + + centered = true; + alreadyCentered = true; + } else if (!centered && (geocodeCenter != null || searchIdIntent != null)) { try { ArrayList<Object> viewport; diff --git a/src/cgeo/geocaching/mapinterfaces/MapViewImpl.java b/src/cgeo/geocaching/mapinterfaces/MapViewImpl.java index 651b39f..5c955ed 100644 --- a/src/cgeo/geocaching/mapinterfaces/MapViewImpl.java +++ b/src/cgeo/geocaching/mapinterfaces/MapViewImpl.java @@ -16,8 +16,6 @@ public interface MapViewImpl { void invalidate(); - void setSatellite(boolean b); - void setBuiltInZoomControls(boolean b); void displayZoomControls(boolean b); @@ -32,8 +30,6 @@ public interface MapViewImpl { void destroyDrawingCache(); - boolean isSatellite(); - GeoPointImpl getMapViewCenter(); int getLatitudeSpan(); diff --git a/src/cgeo/geocaching/mapsforge/mfMapController.java b/src/cgeo/geocaching/mapsforge/mfMapController.java index 30f1c29..45efef2 100644 --- a/src/cgeo/geocaching/mapsforge/mfMapController.java +++ b/src/cgeo/geocaching/mapsforge/mfMapController.java @@ -26,7 +26,7 @@ public class mfMapController implements MapControllerImpl { @Override public void setZoom(int mapzoom) { - mapController.setZoom(mapzoom); + mapController.setZoom(mapzoom-1); } @Override @@ -36,7 +36,7 @@ public class mfMapController implements MapControllerImpl { // calculate zoomlevel int distDegree = Math.max(latSpanE6, lonSpanE6); int zoomLevel = (int) Math.floor(Math.log(360.0*1e6/distDegree)/Math.log(2)); - mapController.setZoom(zoomLevel); + mapController.setZoom(zoomLevel+1); } } } diff --git a/src/cgeo/geocaching/mapsforge/mfMapView.java b/src/cgeo/geocaching/mapsforge/mfMapView.java index 67b0ed7..4d7b31c 100644 --- a/src/cgeo/geocaching/mapsforge/mfMapView.java +++ b/src/cgeo/geocaching/mapsforge/mfMapView.java @@ -109,23 +109,13 @@ public class mfMapView extends MapView implements MapViewImpl { } @Override - public boolean isSatellite() { - return false; - } - - @Override public void preLoad() { // Nothing to do here } @Override - public void setSatellite(boolean b) { - // Nothing to do here - } - - @Override public int getMapZoomLevel() { - return getZoomLevel(); + return getZoomLevel()+1; } @Override @@ -140,21 +130,22 @@ public class mfMapView extends MapView implements MapViewImpl { @Override public void setMapSource(cgSettings settings) { - - setMapViewMode(MapViewMode.MAPNIK_TILE_DOWNLOAD); - switch(settings.mapProvider) { - case mapsforgeMapnik: - // is default - break; + switch(settings.mapSource) { case mapsforgeOsmarender: setMapViewMode(MapViewMode.OSMARENDER_TILE_DOWNLOAD); break; + case mapsforgeCycle: + setMapViewMode(MapViewMode.OPENCYCLEMAP_TILE_DOWNLOAD); + break; case mapsforgeOffline: if (MapDatabase.isValidMapFile(settings.getMapFile())) { setMapViewMode(MapViewMode.CANVAS_RENDERER); super.setMapFile(settings.getMapFile()); } + break; + default: + setMapViewMode(MapViewMode.MAPNIK_TILE_DOWNLOAD); } } } |
