diff --git a/LocationLib/.classpath b/LocationLib/.classpath
index a4763d1..bb0c759 100644
--- a/LocationLib/.classpath
+++ b/LocationLib/.classpath
@@ -4,5 +4,6 @@
+
diff --git a/LocationLib/AndroidManifest.xml b/LocationLib/AndroidManifest.xml
index aa53294..47815ab 100644
--- a/LocationLib/AndroidManifest.xml
+++ b/LocationLib/AndroidManifest.xml
@@ -15,7 +15,7 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/LocationLib/libs/.gitkeep b/LocationLib/libs/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/LocationLib/libs/android-support-v4-googlemaps-r10.jar b/LocationLib/libs/android-support-v4-googlemaps-r10.jar
deleted file mode 100644
index 93223e8..0000000
Binary files a/LocationLib/libs/android-support-v4-googlemaps-r10.jar and /dev/null differ
diff --git a/LocationLib/libs/android-support-v4-r10-googlemaps.jar b/LocationLib/libs/android-support-v4-r10-googlemaps.jar
deleted file mode 100644
index e05d3a4..0000000
Binary files a/LocationLib/libs/android-support-v4-r10-googlemaps.jar and /dev/null differ
diff --git a/LocationLib/project.properties b/LocationLib/project.properties
index b15f120..390812c 100644
--- a/LocationLib/project.properties
+++ b/LocationLib/project.properties
@@ -9,4 +9,6 @@
android.library=true
# Project target.
-target=Google Inc.:Google APIs:16
+target=Google Inc.:Google APIs:18
+android.library.reference.1=../../google-play-services_lib
+
diff --git a/LocationLib/res/layout/base_map_fragment.xml b/LocationLib/res/layout/base_map_fragment.xml
index 0c9c29a..7ac44da 100644
--- a/LocationLib/res/layout/base_map_fragment.xml
+++ b/LocationLib/res/layout/base_map_fragment.xml
@@ -13,7 +13,7 @@
android:id="@+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:apiKey="0rKmsWMM0D-LWOndcfwrmW-S0OXlnQl2SJCMeTg" />
+ android:apiKey="0rKmsWMM0D-IRAEgcSZEqwZCs_8AUwxjYjj0bnA" />
distanceKm(locationPoint, userPoint))
return true;
return false;
}
- /**
- * determines when the specified point is off the map
- *
- * @param point
- * @return true is the point is off the map
- * @author ricky barrette
- */
- public static boolean isPointOffMap(final MapView map, final GeoPoint point) {
- if (map == null)
- return false;
- if (point == null)
- return false;
- final GeoPoint center = map.getMapCenter();
- final double distance = GeoUtils.distanceKm(center, point);
- final double distanceLat = GeoUtils.distanceKm(center, new GeoPoint(center.getLatitudeE6() + map.getLatitudeSpan() / 2, center.getLongitudeE6()));
- final double distanceLon = GeoUtils.distanceKm(center, new GeoPoint(center.getLatitudeE6(), center.getLongitudeE6() + map.getLongitudeSpan() / 2));
- if (distance > distanceLat || distance > distanceLon)
- return true;
- return false;
- }
-
- /**
- * computes a geopoint the is the central geopoint between p1 and p1
- *
- * @param p1
- * first geopoint
- * @param p2
- * second geopoint
- * @return a MidPoint object
- * @author ricky barrette
- */
- public static MidPoint midPoint(final GeoPoint p1, final GeoPoint p2) {
- int minLatitude = (int) (+81 * 1E6);
- int maxLatitude = (int) (-81 * 1E6);
- int minLongitude = (int) (+181 * 1E6);
- int maxLongitude = (int) (-181 * 1E6);
- final List mPoints = new ArrayList();
- int latitude = p1.getLatitudeE6();
- int longitude = p1.getLongitudeE6();
- if (latitude != 0 && longitude != 0) {
- minLatitude = minLatitude > latitude ? latitude : minLatitude;
- maxLatitude = maxLatitude < latitude ? latitude : maxLatitude;
- minLongitude = minLongitude > longitude ? longitude : minLongitude;
- maxLongitude = maxLongitude < longitude ? longitude : maxLongitude;
- mPoints.add(new Point(latitude, longitude));
- }
-
- latitude = p2.getLatitudeE6();
- longitude = p2.getLongitudeE6();
- if (latitude != 0 && longitude != 0) {
- minLatitude = minLatitude > latitude ? latitude : minLatitude;
- maxLatitude = maxLatitude < latitude ? latitude : maxLatitude;
- minLongitude = minLongitude > longitude ? longitude : minLongitude;
- maxLongitude = maxLongitude < longitude ? longitude : maxLongitude;
- mPoints.add(new Point(latitude, longitude));
- }
- return new MidPoint(new GeoPoint((maxLatitude + minLatitude) / 2, (maxLongitude + minLongitude) / 2), minLatitude, minLongitude, maxLatitude, maxLongitude);
- }
+// /**
+// * determines when the specified point is off the map
+// *
+// * @param point
+// * @return true is the point is off the map
+// * @author ricky barrette
+// */
+// public static boolean isPointOffMap(final GoogleMap map, final LatLng point) {
+//
+// VisibleRegion vr = map.getProjection().getVisibleRegion();
+// double left = vr.latLngBounds.southwest.longitude;
+// double top = vr.latLngBounds.northeast.latitude;
+// double right = vr.latLngBounds.northeast.longitude;
+// double bottom = vr.latLngBounds.southwest.latitude;
+//
+// if (map == null)
+// return false;
+// if (point == null)
+// return false;
+// final LatLng center = map.getCameraPosition().target;
+// final double distance = GeoUtils.distanceKm(center, point);
+// final double distanceLat = GeoUtils.distanceKm(center, new LatLng(center.latitude + map.getLatitudeSpan() / 2, center.longitude));
+// final double distanceLon = GeoUtils.distanceKm(center, new LatLng(center.latitude, center.longitude + map.getLongitudeSpan() / 2));
+// if (distance > distanceLat || distance > distanceLon)
+// return true;
+// return false;
+//
+// return map.getProjection().toScreenLocation()
+// }
+//
+// /**
+// * computes a LatLng the is the central LatLng between p1 and p1
+// *
+// * @param p1
+// * first LatLng
+// * @param p2
+// * second LatLng
+// * @return a MidPoint object
+// * @author ricky barrette
+// */
+// public static MidPoint midpoint(final LatLng p1, final LatLng p2) {
+//// double minLatitude = +81 * 1E6;
+//// double maxLatitude = -81 * 1E6;
+//// double minLongitude = +181 * 1E6;
+//// double maxLongitude = -181 * 1E6;
+//// final List mPoints = new ArrayList();
+//// if (p1.latitude != 0 && p1.longitude != 0) {
+//// minLatitude = minLatitude > p1.latitude ? p1.latitude : minLatitude;
+//// maxLatitude = maxLatitude < p1.latitude ? p1.latitude : maxLatitude;
+//// minLongitude = minLongitude > p1.longitude ? p1.longitude : minLongitude;
+//// maxLongitude = maxLongitude < p1.longitude ? p1.longitude : maxLongitude;
+//// mPoints.add(new Point(p1.latitude, p1.longitude));
+//// }
+////
+//// if (p2.latitude != 0 && p2.longitude != 0) {
+//// minLatitude = minLatitude > p2.latitude ? p2.latitude : minLatitude;
+//// maxLatitude = maxLatitude < p2.latitude ? p2.latitude : maxLatitude;
+//// minLongitude = minLongitude > p2.longitude ? p2.longitude : minLongitude;
+//// maxLongitude = maxLongitude < p2.longitude ? p2.longitude : maxLongitude;
+//// mPoints.add(new Point(p2.latitude, p2.longitude));
+//// }
+//// return new MidPoint(new LatLng((maxLatitude + minLatitude) / 2, (maxLongitude + minLongitude) / 2), minLatitude, minLongitude, maxLatitude, maxLongitude);
+// LatLngBounds.Builder latLngBounds = new LatLngBounds.Builder();
+// latLngBounds.include(p1);
+// latLngBounds.include(p2);
+// return new MidPoint(latLngBounds.build().getCenter()
+// }
/**
* converts radians to bearing
diff --git a/LocationLib/src/com/TwentyCodes/android/location/GeoPointLocationListener.java b/LocationLib/src/com/TwentyCodes/android/location/LatLngListener.java
similarity index 68%
rename from LocationLib/src/com/TwentyCodes/android/location/GeoPointLocationListener.java
rename to LocationLib/src/com/TwentyCodes/android/location/LatLngListener.java
index 1c1cf03..7742999 100644
--- a/LocationLib/src/com/TwentyCodes/android/location/GeoPointLocationListener.java
+++ b/LocationLib/src/com/TwentyCodes/android/location/LatLngListener.java
@@ -5,15 +5,15 @@
*/
package com.TwentyCodes.android.location;
-import com.google.android.maps.GeoPoint;
+import com.google.android.gms.maps.model.LatLng;
/**
- * this interface will be used to interface with skyhook sdk with the rest of
+ * this interface will be used to interface with the GPS sdk with the rest of
* the application
*
* @author ricky barrette
*/
-public interface GeoPointLocationListener {
+public interface LatLngListener {
/**
* Called when first fix is aquired
@@ -30,5 +30,5 @@ public interface GeoPointLocationListener {
* @param accuracy
* @author ricky barrette
*/
- public void onLocationChanged(GeoPoint point, int accuracy);
+ public void onLocationChanged(LatLng point, int accuracy);
}
diff --git a/LocationLib/src/com/TwentyCodes/android/location/MidPoint.java b/LocationLib/src/com/TwentyCodes/android/location/MidPoint.java
deleted file mode 100644
index d1c5682..0000000
--- a/LocationLib/src/com/TwentyCodes/android/location/MidPoint.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/**
- * @author Twenty Codes, LLC
- * @author ricky barrette
- * @date Nov 30, 2010
- */
-package com.TwentyCodes.android.location;
-
-import com.google.android.maps.GeoPoint;
-
-/**
- * This MidPoint object will hold the information form the calculations
- * performed by GeoUtils.midPoint().
- *
- * @author ricky barrette
- */
-public class MidPoint {
-
- private final int mMinLatitude;
- private final int mMaxLatitude;
- private final int mMinLongitude;
- private final int mMaxLongitude;
- private final GeoPoint mMidPoint;
-
- /**
- * Creates a new MidPoint
- *
- * @author ricky barrette
- */
- public MidPoint(final GeoPoint midPoint, final int minLatitude, final int minLongitude, final int maxLatitude, final int maxLongitude) {
- mMinLatitude = minLatitude;
- mMaxLatitude = maxLatitude;
- mMinLongitude = minLongitude;
- mMaxLongitude = maxLongitude;
- mMidPoint = midPoint;
- }
-
- /**
- * returns the calculated midpoint
- *
- * @return
- * @author ricky barrette
- */
- public GeoPoint getMidPoint() {
- return mMidPoint;
- }
-
- /**
- * zooms the provided map view to the span of this mid point
- *
- * @param mMapView
- * @author ricky barrette
- */
- public void zoomToSpan(final com.google.android.maps.MapView mMapView) {
- mMapView.getController().zoomToSpan(mMaxLatitude - mMinLatitude, mMaxLongitude - mMinLongitude);
- }
-}
\ No newline at end of file
diff --git a/LocationLib/src/com/TwentyCodes/android/location/OnLocationSelectedListener.java b/LocationLib/src/com/TwentyCodes/android/location/OnLocationSelectedListener.java
index b4da14e..7cfd6b8 100644
--- a/LocationLib/src/com/TwentyCodes/android/location/OnLocationSelectedListener.java
+++ b/LocationLib/src/com/TwentyCodes/android/location/OnLocationSelectedListener.java
@@ -1,6 +1,6 @@
package com.TwentyCodes.android.location;
-import com.google.android.maps.GeoPoint;
+import com.google.android.gms.maps.model.LatLng;
/**
* This interface will be used to pass the selected location from the dialogs to
@@ -10,5 +10,5 @@ import com.google.android.maps.GeoPoint;
*/
public interface OnLocationSelectedListener {
- public void onLocationSelected(GeoPoint point);
+ public void onLocationSelected(LatLng point);
}
\ No newline at end of file
diff --git a/LocationLib/src/com/TwentyCodes/android/overlays/BaseUserOverlay.java b/LocationLib/src/com/TwentyCodes/android/overlays/BaseUserOverlay.java
index 8c9015b..b74a503 100644
--- a/LocationLib/src/com/TwentyCodes/android/overlays/BaseUserOverlay.java
+++ b/LocationLib/src/com/TwentyCodes/android/overlays/BaseUserOverlay.java
@@ -20,7 +20,7 @@ import android.util.Log;
import com.TwentyCodes.android.debug.Debug;
import com.TwentyCodes.android.location.CompassSensor.CompassListener;
-import com.TwentyCodes.android.location.GeoPointLocationListener;
+import com.TwentyCodes.android.location.LatLngListener;
import com.TwentyCodes.android.location.GeoUtils;
import com.TwentyCodes.android.location.R;
import com.google.android.maps.GeoPoint;
@@ -33,7 +33,7 @@ import com.google.android.maps.Projection;
*
* @author ricky barrette
*/
-public abstract class BaseUserOverlay extends Overlay implements GeoPointLocationListener, CompassListener {
+public abstract class BaseUserOverlay extends Overlay implements LatLngListener, CompassListener {
/**
* This thread is responsible for animating the user icon
@@ -114,7 +114,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
private final Context mContext;
private final MapView mMapView;
private boolean isFistFix = true;
- private GeoPointLocationListener mListener;
+ private LatLngListener mListener;
public boolean isFollowingUser = true;
private final CompasOverlay mCompass;
private boolean isCompassEnabled;
@@ -441,7 +441,7 @@ public abstract class BaseUserOverlay extends Overlay implements GeoPointLocatio
* @param listener
* @author Ricky Barrette
*/
- public void registerListener(final GeoPointLocationListener listener) {
+ public void registerListener(final LatLngListener listener) {
Log.d(TAG, "registerListener()");
if (mListener == null)
mListener = listener;
diff --git a/LocationLib/src/com/TwentyCodes/android/overlays/RadiusOverlay.java b/LocationLib/src/com/TwentyCodes/android/overlays/RadiusOverlay.java
index c73c378..76371cf 100644
--- a/LocationLib/src/com/TwentyCodes/android/overlays/RadiusOverlay.java
+++ b/LocationLib/src/com/TwentyCodes/android/overlays/RadiusOverlay.java
@@ -5,20 +5,9 @@
package com.TwentyCodes.android.overlays;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.Paint.Style;
-import android.graphics.Point;
-import android.graphics.RectF;
-
-import com.TwentyCodes.android.location.GeoUtils;
import com.TwentyCodes.android.location.OnLocationSelectedListener;
-import com.google.android.maps.GeoPoint;
-import com.google.android.maps.MapView;
-import com.google.android.maps.Overlay;
-import com.google.android.maps.OverlayItem;
-import com.google.android.maps.Projection;
+import com.google.android.gms.maps.model.CircleOptions;
+import com.google.android.gms.maps.model.LatLng;
/**
* This class will used to draw a radius of a specified size in a specified
@@ -26,13 +15,9 @@ import com.google.android.maps.Projection;
*
* @author ricky barrette
*/
-public class RadiusOverlay extends Overlay {
+public class RadiusOverlay {
- public OverlayItem mOverlayItem;
- private GeoPoint mPoint;
- private float mRadius = 0;
- private int mColor = Color.GREEN;
- private GeoPoint mRadiusPoint;
+ private final CircleOptions mCircleOptions;
private OnLocationSelectedListener mListener;
/**
@@ -41,6 +26,7 @@ public class RadiusOverlay extends Overlay {
* @author ricky barrette
*/
public RadiusOverlay() {
+ mCircleOptions = new CircleOptions();
}
/**
@@ -55,101 +41,48 @@ public class RadiusOverlay extends Overlay {
* desired color of the radius from Color API
* @author ricky barrette
*/
- public RadiusOverlay(final GeoPoint point, final float radius, final int color) {
- mPoint = point;
- mRadius = radius;
- mColor = color;
- }
-
- /**
- * draws a specific radius on the mapview that is handed to it
- *
- * @param canvas
- * canvas to be drawn on
- * @param mapView
- * @param shadow
- * @param when
- */
- @Override
- public void draw(final Canvas canvas, final MapView mapView, final boolean shadow) {
- if (mPoint != null) {
- final Paint paint = new Paint();
- final Point center = new Point();
- final Point left = new Point();
- final Projection projection = mapView.getProjection();
-
- /*
- * Calculate a geopoint that is "radius" meters away from geopoint
- * point and convert the given GeoPoint and leftGeo to onscreen
- * pixel coordinates, relative to the top-left of the MapView that
- * provided this Projection.
- */
- mRadiusPoint = GeoUtils.distanceFrom(mPoint, mRadius);
- projection.toPixels(mRadiusPoint, left);
- projection.toPixels(mPoint, center);
-
- /*
- * get radius of the circle being drawn by
- */
- int circleRadius = center.x - left.x;
- if (circleRadius <= 0)
- circleRadius = left.x - center.x;
-
- /*
- * paint a circle on the map
- */
- paint.setAntiAlias(true);
- paint.setStrokeWidth(2.0f);
- paint.setColor(mColor);
- paint.setStyle(Style.STROKE);
- canvas.drawCircle(center.x, center.y, circleRadius, paint);
-
- // draw a dot over the geopoint
- final RectF oval = new RectF(center.x - 2, center.y - 2, center.x + 2, center.y + 2);
- canvas.drawOval(oval, paint);
-
- // fill the radius with a nice green
- paint.setAlpha(25);
- paint.setStyle(Style.FILL);
- canvas.drawCircle(center.x, center.y, circleRadius, paint);
- }
+ public RadiusOverlay(final LatLng point, final double radius, final int color) {
+ mCircleOptions = new CircleOptions();
+ mCircleOptions.center(point);
+ mCircleOptions.radius(radius);
+ mCircleOptions.fillColor(color);
}
/**
* @return the selected location
* @author ricky barrette
*/
- public GeoPoint getLocation() {
- return mPoint;
+ public LatLng getLocation() {
+ return mCircleOptions.getCenter();
}
public int getZoomLevel() {
// GeoUtils.GeoUtils.distanceFrom(mPoint , mRadius)
return 0;
}
-
- @Override
- public boolean onTap(final GeoPoint p, final MapView mapView) {
- mPoint = p;
- if (mListener != null)
- mListener.onLocationSelected(p);
- return super.onTap(p, mapView);
- }
+//
+// @Override
+// public boolean onTap(final GeoPoint p, final MapView mapView) {
+// mPoint = p;
+// if (mListener != null)
+// mListener.onLocationSelected(p);
+// return super.onTap(p, mapView);
+// }
/**
* @param color
* @author ricky barrette
*/
public void setColor(final int color) {
- mColor = color;
+ mCircleOptions.fillColor(color);
}
/**
* @param location
* @author ricky barrette
*/
- public void setLocation(final GeoPoint location) {
- mPoint = location;
+ public void setLocation(final LatLng location) {
+ mCircleOptions.center(location);
}
public void setLocationSelectedListener(final OnLocationSelectedListener listener) {
@@ -162,7 +95,15 @@ public class RadiusOverlay extends Overlay {
* @author ricky barrette
* @param radius
*/
- public void setRadius(final int radius) {
- mRadius = radius;
+ public void setRadius(final double radius) {
+ mCircleOptions.radius(radius);
+ }
+
+ /**
+ *
+ * @return
+ */
+ public CircleOptions getCircleOptions(){
+ return mCircleOptions;
}
}
\ No newline at end of file