From 5ba3f55edae3c84b03df80df1e3426efd5022fd3 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Thu, 10 May 2012 13:04:21 -0400 Subject: [PATCH] Added some convenice methods to BaseMapFragment Signed-off-by: Ricky Barrette --- .../android/fragments/BaseMapFragment.java | 109 ++++++++++++++---- 1 file changed, 87 insertions(+), 22 deletions(-) diff --git a/LocationLib/src/com/TwentyCodes/android/fragments/BaseMapFragment.java b/LocationLib/src/com/TwentyCodes/android/fragments/BaseMapFragment.java index 189cd7b..2b17c81 100644 --- a/LocationLib/src/com/TwentyCodes/android/fragments/BaseMapFragment.java +++ b/LocationLib/src/com/TwentyCodes/android/fragments/BaseMapFragment.java @@ -49,6 +49,25 @@ public abstract class BaseMapFragment extends Fragment { mMapView.setSatellite(!mMapView.isSatellite()); } + /** + * Disables the Acquiring GPS dialog + * @author ricky barrette + */ + public void disableGPSProgess(){ + isGPSDialogEnabled = false; + mProgress.setVisibility(View.GONE); + } + + /** + * Enables the Acquiring GPS dialog if the location has not been acquired + * + * @author ricky barrette + */ + public void enableGPSProgess(){ + isGPSDialogEnabled = true; + mProgress.setVisibility(View.VISIBLE); + } + /** * @return mapview * @author ricky barrette @@ -57,6 +76,30 @@ public abstract class BaseMapFragment extends Fragment { return mMapView; } + /** + * Forces the map to redraw + * @author ricky barrette + */ + public void invalidate(){ + mMapView.invalidate(); + } + + /** + * @return true if the GPS progress is showing + * @author ricky barrette + */ + public boolean isGPSProgessShowing(){ + return isGPSDialogEnabled; + } + + /** + * @return true if the map is in satellite mode + * @author ricky barrette + */ + public boolean isSatellite(){ + return mMapView.isSatellite(); + } + /** * Called when the fragment view is first created * (non-Javadoc) @@ -75,15 +118,15 @@ public abstract class BaseMapFragment extends Fragment { return view; } - - /** + + /** * Called when the mapview has been initialized. here you want to init and add your custom overlays * @param map * @author ricky barrette */ public abstract void onMapViewCreate(MapView map); - - /** + + /** * Removes an overlay from the mapview * @param overlay * @author ricky barrette @@ -91,8 +134,35 @@ public abstract class BaseMapFragment extends Fragment { public void removeOverlay(Object overlay){ mMapView.getOverlays().remove(overlay); } - + /** + * Enables or disables the built in zoom controls + * @param isShowing + * @author ricky barrette + */ + public void setBuiltInZoomControls(boolean isShowing){ + mMapView.setBuiltInZoomControls(isShowing); + } + + /** + * Sets where or not the map view is interactive + * @param isClickable + * @author ricky barrette + */ + public void setClickable(boolean isClickable){ + mMapView.setClickable(isClickable); + } + + /** + * Sets double tap zoom + * @param isDoubleTapZoonEnabled + * @author ricky barrette + */ + public void setDoubleTapZoonEnabled(boolean isDoubleTapZoonEnabled){ + mMapView.setDoubleTapZoonEnabled(isDoubleTapZoonEnabled); + } + + /** * Sets the center of the map to the provided point * @param point * @author ricky barrette @@ -103,27 +173,22 @@ public abstract class BaseMapFragment extends Fragment { mMapView.getController().setCenter(point); return true; } - + /** - * Disables the Acquiring GPS dialog + * Sets the view of the map. true is sat, false is map + * @param isSat * @author ricky barrette */ - public void disableGPSProgess(){ - isGPSDialogEnabled = false; - mProgress.setVisibility(View.GONE); - } - - /** - * Enables the Acquiring GPS dialog if the location has not been acquired - * - * @author ricky barrette - */ - public void enableGPSProgess(){ - isGPSDialogEnabled = true; - mProgress.setVisibility(View.VISIBLE); + public void setSatellite(boolean isSat){ + mMapView.setSatellite(isSat); } - public boolean isGPSProgessShowing(){ - return isGPSDialogEnabled; + /** + * Sets the zoom level of the map + * @param zoom + * @author ricky barrette + */ + public void setZoom(int zoom){ + mMapView.getController().setZoom(zoom); } } \ No newline at end of file