diff --git a/LocationLib/src/com/TwentyCodes/android/fragments/UserOverlayMapFragment.java b/LocationLib/src/com/TwentyCodes/android/fragments/UserOverlayMapFragment.java index 5c3293d..0e32716 100644 --- a/LocationLib/src/com/TwentyCodes/android/fragments/UserOverlayMapFragment.java +++ b/LocationLib/src/com/TwentyCodes/android/fragments/UserOverlayMapFragment.java @@ -11,7 +11,7 @@ import com.TwentyCodes.android.location.LatLngListener; import com.TwentyCodes.android.location.MapView; import com.TwentyCodes.android.overlays.UserOverlay; import com.google.android.gms.maps.MapFragment; -import com.google.android.maps.GeoPoint; +import com.google.android.gms.maps.model.LatLng; /** * This is a MapFragment that maintains the UserOverlay @@ -49,7 +49,7 @@ public class UserOverlayMapFragment extends MapFragment implements LatLngListene * @return return the current destination * @author ricky barrette */ - public GeoPoint getDestination() { + public LatLng getDestination() { return mUserOverlay.getDestination(); } @@ -57,7 +57,7 @@ public class UserOverlayMapFragment extends MapFragment implements LatLngListene * @return the users current location * @author ricky barrette */ - public GeoPoint getUserLocation() { + public LatLng getUserLocation() { return mUserOverlay.getUserLocation(); } @@ -83,7 +83,7 @@ public class UserOverlayMapFragment extends MapFragment implements LatLngListene * @author ricky barrette */ @Override - public void onLocationChanged(final GeoPoint point, final int accuracy) { + public void onLocationChanged(final LatLng point, final int accuracy) { if (mLatLngListener != null) mLatLngListener.onLocationChanged(point, accuracy); } @@ -161,7 +161,7 @@ public class UserOverlayMapFragment extends MapFragment implements LatLngListene * @param destination * @author ricky barrette */ - public void setDestination(final GeoPoint destination) { + public void setDestination(final LatLng destination) { mUserOverlay.setDestination(destination); } diff --git a/LocationLib/src/com/TwentyCodes/android/overlays/BaseUserOverlay.java b/LocationLib/src/com/TwentyCodes/android/overlays/BaseUserOverlay.java index b74a503..fa6c5d9 100644 --- a/LocationLib/src/com/TwentyCodes/android/overlays/BaseUserOverlay.java +++ b/LocationLib/src/com/TwentyCodes/android/overlays/BaseUserOverlay.java @@ -7,26 +7,17 @@ package com.TwentyCodes.android.overlays; import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Matrix; -import android.graphics.Paint; +import android.graphics.*; import android.graphics.Paint.Style; -import android.graphics.Point; -import android.graphics.RectF; import android.util.Log; - import com.TwentyCodes.android.debug.Debug; import com.TwentyCodes.android.location.CompassSensor.CompassListener; import com.TwentyCodes.android.location.LatLngListener; -import com.TwentyCodes.android.location.GeoUtils; import com.TwentyCodes.android.location.R; +import com.google.android.gms.maps.model.LatLng; import com.google.android.maps.GeoPoint; import com.google.android.maps.MapView; import com.google.android.maps.Overlay; -import com.google.android.maps.Projection; /** * This class will be used to build user overlays @@ -110,7 +101,7 @@ public abstract class BaseUserOverlay extends Overlay implements LatLngListener, private AnimationThread mAnimationThread; private float mBearing = 0; private int mAccuracy; - private GeoPoint mPoint; + private LatLng mPoint; private final Context mContext; private final MapView mMapView; private boolean isFistFix = true; @@ -187,22 +178,22 @@ public abstract class BaseUserOverlay extends Overlay implements LatLngListener, */ @Override public void draw(Canvas canvas, final MapView mapView, final boolean shadow) { - if (isEnabled && mPoint != null) { - final Point center = new Point(); - final Point left = new Point(); - final Projection projection = mapView.getProjection(); - final GeoPoint leftGeo = GeoUtils.distanceFrom(mPoint, mAccuracy); - projection.toPixels(leftGeo, left); - projection.toPixels(mPoint, center); - canvas = drawAccuracyCircle(center, left, canvas); - canvas = drawUser(center, mBearing, canvas); - /* - * the following log is used to demonstrate if the leftGeo point is - * the correct - */ - if (Debug.DEBUG) - Log.d(TAG, GeoUtils.distanceKm(mPoint, leftGeo) * 1000 + "m"); - } +// if (isEnabled && mPoint != null) { +// final Point center = new Point(); +// final Point left = new Point(); +// final Projection projection = mapView.getProjection(); +// final LatLng leftGeo = GeoUtils.distanceFrom(mPoint, mAccuracy); +// projection.toPixels(leftGeo, left); +// projection.toPixels(mPoint, center); +// canvas = drawAccuracyCircle(center, left, canvas); +// canvas = drawUser(center, mBearing, canvas); +// /* +// * the following log is used to demonstrate if the leftGeo point is +// * the correct +// */ +// if (Debug.DEBUG) +// Log.d(TAG, GeoUtils.distanceKm(mPoint, leftGeo) * 1000 + "m"); +// } super.draw(canvas, mapView, shadow); } @@ -326,7 +317,7 @@ public abstract class BaseUserOverlay extends Overlay implements LatLngListener, * @return return the current destination * @author ricky barrette */ - public GeoPoint getDestination() { + public LatLng getDestination() { return mCompass.getDestination(); } @@ -346,7 +337,7 @@ public abstract class BaseUserOverlay extends Overlay implements LatLngListener, * @return * @author ricky barrette */ - public GeoPoint getUserLocation() { + public LatLng getUserLocation() { return mPoint; } @@ -362,14 +353,12 @@ public abstract class BaseUserOverlay extends Overlay implements LatLngListener, * called when the SkyHook location changes, this mthod is resposiable for * updating the overlay location and accuracy circle. (non-Javadoc) * - * @see com.TwentyCodes.android.SkyHook.GeoPointLocationListener.location.LocationListener#onLocationChanged(com.google.android.maps.GeoPoint, - * float) * @param point * @param accuracy * @author ricky barrette */ @Override - public void onLocationChanged(final GeoPoint point, final int accuracy) { + public void onLocationChanged(final LatLng point, final int accuracy) { if (mCompass != null) mCompass.setLocation(point); @@ -378,13 +367,13 @@ public abstract class BaseUserOverlay extends Overlay implements LatLngListener, * if this is the first fix set map center the users location, and zoom * to the max zoom level */ - if (point != null && isFistFix) { - mMapView.getController().setCenter(point); - mMapView.getController().setZoom(mMapView.getMaxZoomLevel() - 2); - if (mListener != null) - mListener.onFirstFix(true); - isFistFix = false; - } +// if (point != null && isFistFix) { +// mMapView.getController().setCenter(point); +// mMapView.getController().setZoom(mMapView.getMaxZoomLevel() - 2); +// if (mListener != null) +// mListener.onFirstFix(true); +// isFistFix = false; +// } // update the users point, and accuracy for the UI mPoint = point; @@ -393,8 +382,8 @@ public abstract class BaseUserOverlay extends Overlay implements LatLngListener, if (mListener != null) mListener.onLocationChanged(point, accuracy); - if (isFollowingUser) - panToUserIfOffMap(point); +// if (isFollowingUser) +// panToUserIfOffMap(point); } /** @@ -420,19 +409,19 @@ public abstract class BaseUserOverlay extends Overlay implements LatLngListener, */ private void panToUserIfOffMap(final GeoPoint user) { final GeoPoint center = mMapView.getMapCenter(); - final double distance = GeoUtils.distanceKm(center, user); - final double distanceLat = GeoUtils.distanceKm(center, new GeoPoint(center.getLatitudeE6() + mMapView.getLatitudeSpan() / 2, center.getLongitudeE6())); - final double distanceLon = GeoUtils.distanceKm(center, new GeoPoint(center.getLatitudeE6(), center.getLongitudeE6() + mMapView.getLongitudeSpan() / 2)); - - final double whichIsGreater = distanceLat > distanceLon ? distanceLat : distanceLon; - - /** - * if the user is one the map, keep them their else don't pan to user - * unless they pan pack to them - */ - if (!(distance > whichIsGreater)) - if (distance > distanceLat || distance > distanceLon) - mMapView.getController().animateTo(user); +// final double distance = GeoUtils.distanceKm(center, user); +// final double distanceLat = GeoUtils.distanceKm(center, new GeoPoint(center.getLatitudeE6() + mMapView.getLatitudeSpan() / 2, center.getLongitudeE6())); +// final double distanceLon = GeoUtils.distanceKm(center, new GeoPoint(center.getLatitudeE6(), center.getLongitudeE6() + mMapView.getLongitudeSpan() / 2)); +// +// final double whichIsGreater = distanceLat > distanceLon ? distanceLat : distanceLon; +// +// /** +// * if the user is one the map, keep them their else don't pan to user +// * unless they pan pack to them +// */ +// if (!(distance > whichIsGreater)) +// if (distance > distanceLat || distance > distanceLon) +// mMapView.getController().animateTo(user); } /** @@ -475,7 +464,7 @@ public abstract class BaseUserOverlay extends Overlay implements LatLngListener, * * @author ricky barrette */ - public void setDestination(final GeoPoint destination) { + public void setDestination(final LatLng destination) { if (mCompass != null) mCompass.setDestination(destination); } diff --git a/LocationLib/src/com/TwentyCodes/android/overlays/CompasOverlay.java b/LocationLib/src/com/TwentyCodes/android/overlays/CompasOverlay.java index b8de032..8a98a12 100644 --- a/LocationLib/src/com/TwentyCodes/android/overlays/CompasOverlay.java +++ b/LocationLib/src/com/TwentyCodes/android/overlays/CompasOverlay.java @@ -8,18 +8,13 @@ package com.TwentyCodes.android.overlays; import android.content.Context; import android.content.res.Resources; -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.graphics.Canvas; -import android.graphics.Matrix; -import android.graphics.Point; +import android.graphics.*; import android.util.TypedValue; - import com.TwentyCodes.android.location.CompassSensor; import com.TwentyCodes.android.location.CompassSensor.CompassListener; import com.TwentyCodes.android.location.GeoUtils; import com.TwentyCodes.android.location.R; -import com.google.android.maps.GeoPoint; +import com.google.android.gms.maps.model.LatLng; import com.google.android.maps.MapView; import com.google.android.maps.Overlay; @@ -33,8 +28,8 @@ public class CompasOverlay extends Overlay implements CompassListener { private float mBearing; private final Context mContext; - private GeoPoint mDestination; - private GeoPoint mLocation; + private LatLng mDestination; + private LatLng mLocation; private boolean isEnabled; private final CompassSensor mCompassSensor; private int mNeedleResId = R.drawable.needle_sm; @@ -62,7 +57,7 @@ public class CompasOverlay extends Overlay implements CompassListener { * @param destination * @author ricky barrette */ - public CompasOverlay(final Context context, final GeoPoint destination) { + public CompasOverlay(final Context context, final LatLng destination) { this(context); mDestination = destination; } @@ -80,7 +75,7 @@ public class CompasOverlay extends Overlay implements CompassListener { * dip * @author ricky barrette */ - public CompasOverlay(final Context context, final GeoPoint destination, final int needleResId, final int backgroundResId, final int x, final int y) { + public CompasOverlay(final Context context, final LatLng destination, final int needleResId, final int backgroundResId, final int x, final int y) { this(context, destination); mX = convertDipToPx(x); mY = convertDipToPx(y); @@ -105,7 +100,7 @@ public class CompasOverlay extends Overlay implements CompassListener { /** * Converts dip to px * - * @param dip + * @param i DIP * @return px * @author ricky barrette */ @@ -191,7 +186,7 @@ public class CompasOverlay extends Overlay implements CompassListener { * @return return the current destination * @author ricky barrette */ - public GeoPoint getDestination() { + public LatLng getDestination() { return mDestination; } @@ -199,7 +194,6 @@ public class CompasOverlay extends Overlay implements CompassListener { * Called from the compass Sensor to update the current bearing * (non-Javadoc) * - * @see com.TwentyCodes.android.location.CompassListener#onCompassUpdate(float) * @author ricky barrette */ @Override @@ -217,7 +211,7 @@ public class CompasOverlay extends Overlay implements CompassListener { * @param destination * @author ricky barrette */ - public void setDestination(final GeoPoint destination) { + public void setDestination(final LatLng destination) { mDestination = destination; } @@ -241,7 +235,7 @@ public class CompasOverlay extends Overlay implements CompassListener { * @param location * @author ricky barrette */ - public void setLocation(final GeoPoint location) { + public void setLocation(final LatLng location) { mLocation = location; }