diff --git a/platform/android/MapboxGLAndroidSDK/build.gradle b/platform/android/MapboxGLAndroidSDK/build.gradle
index 55beb8dea..c194a8c34 100644
--- a/platform/android/MapboxGLAndroidSDK/build.gradle
+++ b/platform/android/MapboxGLAndroidSDK/build.gradle
@@ -25,7 +25,7 @@ dependencies {
compile "com.android.support:support-annotations:${supportLibVersion}"
compile "com.android.support:support-v4:${supportLibVersion}"
compile "com.android.support:design:${supportLibVersion}"
- compile 'com.squareup.okhttp3:okhttp:3.0.0'
+ compile 'com.squareup.okhttp3:okhttp:3.0.1'
compile 'com.mapzen.android:lost:1.0.1'
}
diff --git a/platform/android/MapboxGLAndroidSDK/gradle.properties b/platform/android/MapboxGLAndroidSDK/gradle.properties
index 8b50b5b17..bd2d4f385 100644
--- a/platform/android/MapboxGLAndroidSDK/gradle.properties
+++ b/platform/android/MapboxGLAndroidSDK/gradle.properties
@@ -1,5 +1,5 @@
GROUP=com.mapbox.mapboxsdk
-VERSION_NAME=3.1.0-SNAPSHOT
+VERSION_NAME=3.1.0
POM_DESCRIPTION=Mapbox GL Android SDK
POM_URL=https://github.com/mapbox/mapbox-gl-native
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/MapFragment.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/MapFragment.java
index 98d0f7965..572598996 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/MapFragment.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/MapFragment.java
@@ -10,6 +10,20 @@ import android.view.ViewGroup;
import com.mapbox.mapboxsdk.utils.ApiAccess;
import com.mapbox.mapboxsdk.views.MapView;
+/**
+ * Fragment wrapper around a {@link MapView}.
+ *
+ * A Map component in an app. This fragment is the simplest way to place a map in an application.
+ * It's a wrapper around a view of a map to automatically handle the necessary life cycle needs.
+ * Being a fragment, this component can be added to an activity's layout or can dynamically be added
+ * using a FragmentManager.
+ *
+ *
+ * To get a reference to the MapView, use {@link #getMap()}
+ *
+ *
+ * @see #getMap()
+ */
public class MapFragment extends Fragment {
//
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Annotation.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Annotation.java
index bf8999878..813e489e9 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Annotation.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Annotation.java
@@ -5,10 +5,12 @@ import android.support.annotation.NonNull;
import com.mapbox.mapboxsdk.views.MapView;
/**
- * Annotation is the most general kind of overlay on top of a map,
- * from which {@link InfoWindow} and {@link Marker} are derived: it manages
- * attachment to a map and identification, but does not require
+ * Annotation is a overlay on top of a {@link MapView},
+ * from which {@link Polygon}, {@link Polyline} and {@link Marker} are derived.
+ *
+ * it manages attachment to a map and identification, but does not require
* content to be placed at a geographical point.
+ *
*/
public abstract class Annotation implements Comparable {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java
index d7e28dde7..b9691914e 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Icon.java
@@ -2,6 +2,10 @@ package com.mapbox.mapboxsdk.annotations;
import android.graphics.Bitmap;
+/**
+ * Icon is the visual representation of a {@link Marker} on a {@link com.mapbox.mapboxsdk.views.MapView}.
+ * @see Marker
+ */
public final class Icon {
private Bitmap mBitmap;
private String mId;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java
index 8d58866ac..bee4ec47c 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/IconFactory.java
@@ -22,6 +22,10 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
+/**
+ * Factory for creating {@link Icon} objects.
+ * @see Icon
+ */
public final class IconFactory {
private static final String ICON_ID_PREFIX = "com.mapbox.icons.icon_";
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java
index c74cf478d..696301cf5 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/InfoWindow.java
@@ -1,8 +1,8 @@
package com.mapbox.mapboxsdk.annotations;
-import android.content.Context;
import android.content.res.Resources;
import android.graphics.PointF;
+import android.support.annotation.LayoutRes;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
@@ -17,32 +17,29 @@ import java.lang.ref.WeakReference;
/**
*
- * A tooltip view. This is a UI element placed over a map at a specific geographic
- * location.
+ * InfoWindow is a tooltip shown when a {@link Marker} is tapped.
+ *
+ *
+ * This is a UI element placed over a map at a specific geographic location.
*
*/
public class InfoWindow {
private WeakReference mBoundMarker;
private WeakReference mMapView;
+ protected WeakReference mView;
+
private float mMarkerHeightOffset;
private float mViewWidthOffset;
private PointF mCoordinates;
private boolean mIsVisible;
- protected WeakReference mView;
- static int mTitleId = 0;
- static int mDescriptionId = 0;
- static int mSubDescriptionId = 0;
- static int mImageId = 0;
+ @LayoutRes
+ private int mLayoutRes;
InfoWindow(int layoutResId, MapView mapView) {
+ mLayoutRes = layoutResId;
View view = LayoutInflater.from(mapView.getContext()).inflate(layoutResId, mapView, false);
-
- if (mTitleId == 0) {
- setResIds(mapView.getContext());
- }
-
initialize(view, mapView);
}
@@ -86,7 +83,7 @@ public class InfoWindow {
* This allows to offset the view from the object position.
* @return this infowindow
*/
- InfoWindow open(Marker boundMarker, LatLng position, int offsetX, int offsetY) {
+ InfoWindow open(MapView mapView, Marker boundMarker, LatLng position, int offsetX, int offsetY) {
setBoundMarker(boundMarker);
MapView.LayoutParams lp = new MapView.LayoutParams(MapView.LayoutParams.WRAP_CONTENT, MapView.LayoutParams.WRAP_CONTENT);
@@ -99,21 +96,21 @@ public class InfoWindow {
mMarkerHeightOffset = -view.getMeasuredHeight() + offsetY;
// Calculate default Android x,y coordinate
- mCoordinates = mMapView.get().toScreenLocation(position);
+ mCoordinates = mapView.toScreenLocation(position);
float x = mCoordinates.x - (view.getMeasuredWidth() / 2) + offsetX;
float y = mCoordinates.y - view.getMeasuredHeight() + offsetY;
if (view instanceof InfoWindowView) {
// only apply repositioning/margin for InfoWindowView
- Resources resources = mMapView.get().getContext().getResources();
+ Resources resources = mapView.getContext().getResources();
// get right/left popup window
float rightSideInfowWindow = x + view.getMeasuredWidth();
float leftSideInfoWindow = x;
// get right/left map view
- final float mapRight = mMapView.get().getRight();
- final float mapLeft = mMapView.get().getLeft();
+ final float mapRight = mapView.getRight();
+ final float mapLeft = mapView.getLeft();
float marginHorizontal = resources.getDimension(R.dimen.infowindow_margin);
float tipViewOffset = resources.getDimension(R.dimen.infowindow_tipview_width) / 2;
@@ -164,7 +161,7 @@ public class InfoWindow {
mViewWidthOffset = x - mCoordinates.x - offsetX;
close(); //if it was already opened
- mMapView.get().addView(view, lp);
+ mapView.addView(view, lp);
mIsVisible = true;
}
return this;
@@ -194,25 +191,17 @@ public class InfoWindow {
*
* @param overlayItem the tapped overlay item
*/
- void adaptDefaultMarker(Marker overlayItem) {
+ void adaptDefaultMarker(Marker overlayItem, MapView mapView) {
View view = mView.get();
- if (view != null) {
- String title = overlayItem.getTitle();
- ((TextView) view.findViewById(mTitleId /*R.id.title*/)).setText(title);
- String snippet = overlayItem.getSnippet();
- ((TextView) view.findViewById(mDescriptionId /*R.id.description*/)).setText(snippet);
+ if (view == null) {
+ view = LayoutInflater.from(mapView.getContext()).inflate(mLayoutRes, mapView, false);
+ initialize(view, mapView);
}
-/*
- //handle sub-description, hiding or showing the text view:
- TextView subDescText = (TextView) mView.findViewById(mSubDescriptionId);
- String subDesc = overlayItem.getSubDescription();
- if ("".equals(subDesc)) {
- subDescText.setVisibility(View.GONE);
- } else {
- subDescText.setText(subDesc);
- subDescText.setVisibility(View.VISIBLE);
- }
-*/
+ mMapView = new WeakReference<>(mapView);
+ String title = overlayItem.getTitle();
+ ((TextView) view.findViewById(R.id.infowindow_title)).setText(title);
+ String snippet = overlayItem.getSnippet();
+ ((TextView) view.findViewById(R.id.infowindow_description)).setText(snippet);
}
private void onClose() {
@@ -231,22 +220,6 @@ public class InfoWindow {
return mBoundMarker.get();
}
- /**
- * Given a context, set the resource ids for the layout
- * of the InfoWindow.
- *
- * @param context the apps Context
- */
- private static void setResIds(Context context) {
- String packageName = context.getPackageName(); //get application package name
- mTitleId = context.getResources().getIdentifier("id/infowindow_title", null, packageName);
- mDescriptionId =
- context.getResources().getIdentifier("id/infowindow_description", null, packageName);
- mSubDescriptionId = context.getResources()
- .getIdentifier("id/infowindow_subdescription", null, packageName);
- mImageId = context.getResources().getIdentifier("id/infowindow_image", null, packageName);
- }
-
public void update() {
MapView mapView = mMapView.get();
Marker marker = mBoundMarker.get();
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java
index 8978d4be4..346380144 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/Marker.java
@@ -1,5 +1,6 @@
package com.mapbox.mapboxsdk.annotations;
+import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.view.View;
@@ -8,9 +9,10 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.views.MapView;
/**
- * A marker is a map overlay that shows an icon image at a specific
- * geographical location and can be associated with a {@link InfoWindow}
- * that is shown when the marker is tapped.
+ * Marker is an annotation that shows an icon image at a geographical location.
+ *
+ * An {@link InfoWindow} can be shown when a Marker is pressed
+ *
*/
public final class Marker extends Annotation {
@@ -53,6 +55,8 @@ public final class Marker extends Annotation {
/**
* Do not use this method. Used internally by the SDK.
+ *
+ * @return boolean State of a InfoWindow
*/
public boolean isInfoWindowShown() {
return infoWindowShown;
@@ -68,6 +72,8 @@ public final class Marker extends Annotation {
/**
* Do not use this method. Used internally by the SDK.
+ *
+ * @param icon The icon to be used as Marker image
*/
public void setIcon(@Nullable Icon icon) {
this.icon = icon;
@@ -83,29 +89,29 @@ public final class Marker extends Annotation {
/**
* Do not use this method. Used internally by the SDK.
+ *
+ * @param mapView The MapView to show the InfoWindow on.
+ * @return infoWindow The infoWindow to show
*/
- public InfoWindow showInfoWindow() {
- if (getMapView() == null) {
- return null;
- }
-
+ public InfoWindow showInfoWindow(@NonNull MapView mapView) {
+ setMapView(mapView);
MapView.InfoWindowAdapter infoWindowAdapter = getMapView().getInfoWindowAdapter();
if (infoWindowAdapter != null) {
// end developer is using a custom InfoWindowAdapter
View content = infoWindowAdapter.getInfoWindow(this);
if (content != null) {
infoWindow = new InfoWindow(content, getMapView());
- showInfoWindow(infoWindow);
+ showInfoWindow(infoWindow, mapView);
return infoWindow;
}
}
- getInfoWindow().adaptDefaultMarker(this);
- return showInfoWindow(getInfoWindow());
+ getInfoWindow().adaptDefaultMarker(this, mapView);
+ return showInfoWindow(getInfoWindow(), mapView);
}
- private InfoWindow showInfoWindow(InfoWindow iw) {
- iw.open(this, getPosition(), 0, topOffsetPixels);
+ private InfoWindow showInfoWindow(InfoWindow iw, MapView mapView) {
+ iw.open(mapView, this, getPosition(), 0, topOffsetPixels);
infoWindowShown = true;
return iw;
}
@@ -129,6 +135,8 @@ public final class Marker extends Annotation {
/**
* Do not use this method. Used internally by the SDK.
+ *
+ * @param topOffsetPixels the pixels to have as offset
*/
public void setTopOffsetPixels(int topOffsetPixels) {
this.topOffsetPixels = topOffsetPixels;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerOptions.java
index 69e8b03bd..a83a6991b 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerOptions.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MarkerOptions.java
@@ -10,9 +10,7 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
/**
*
- * A builder object for the options configuration {@link com.mapbox.mapboxsdk.annotations.Marker} and
- * {@link com.mapbox.mapboxsdk.annotations.InfoWindow}
- * instances on maps.
+ * Builder for composing {@link com.mapbox.mapboxsdk.annotations.Marker} objects.
*
*
* Example
@@ -70,6 +68,8 @@ public final class MarkerOptions implements Parcelable {
/**
* Do not use this method. Used internally by the SDK.
+ *
+ * @return Marker The build marker
*/
public Marker getMarker() {
return marker;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MultiPoint.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MultiPoint.java
index 5c1dfb119..d2aaea1d1 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MultiPoint.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/MultiPoint.java
@@ -5,6 +5,9 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
import java.util.ArrayList;
import java.util.List;
+/**
+ * Multipoint is an abstract annotation for combining geographical locations.
+ */
public abstract class MultiPoint extends Annotation {
private List points;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolygonOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolygonOptions.java
index c716d10ed..30847807b 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolygonOptions.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolygonOptions.java
@@ -9,6 +9,9 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
import java.util.ArrayList;
import java.util.List;
+/**
+ * Builder for composing {@link Polygon} objects.
+ */
public final class PolygonOptions implements Parcelable {
public static final Parcelable.Creator CREATOR
@@ -96,6 +99,8 @@ public final class PolygonOptions implements Parcelable {
/**
* Do not use this method. Used internally by the SDK.
+ *
+ * @return Polygon the Polygon to return
*/
public Polygon getPolygon() {
return polygon;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolylineOptions.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolylineOptions.java
index d48858c7d..1e625c10f 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolylineOptions.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/annotations/PolylineOptions.java
@@ -8,6 +8,9 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
import java.util.ArrayList;
import java.util.List;
+/**
+ * Builder for composing {@link Polyline} objects.
+ */
public final class PolylineOptions implements Parcelable {
@@ -83,6 +86,7 @@ public final class PolylineOptions implements Parcelable {
* Sets the color of the polyline.
*
* @param color - the color in ARGB format
+ * @return PolyLineOptions The builder used to build a Polyline
*/
public PolylineOptions color(int color) {
polyline.setColor(color);
@@ -95,6 +99,7 @@ public final class PolylineOptions implements Parcelable {
/**
* Do not use this method. Used internally by the SDK.
+ * @return PolyLine The polyline build by this class.
*/
public Polyline getPolyline() {
return polyline;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/BoundingBox.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/BoundingBox.java
index ca805b38e..72a851e1a 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/BoundingBox.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/BoundingBox.java
@@ -9,7 +9,7 @@ import java.util.List;
/**
* A rectangular geographical area defined in latitude and longitude units.
*/
-public final class BoundingBox implements Parcelable, Serializable {
+public final class BoundingBox implements Parcelable {
private final double mLatNorth;
private final double mLatSouth;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateBounds.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateBounds.java
index 1ad584f8c..fefc2502d 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateBounds.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateBounds.java
@@ -1,41 +1,52 @@
package com.mapbox.mapboxsdk.geometry;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.support.annotation.NonNull;
+
/**
- * Implementation of iOS MGLCoordinateBounds
+ * A rectangular geograpical region defined by a south west {@link LatLng} and a north east {@link LatLng}.
*/
-public class CoordinateBounds {
+public class CoordinateBounds implements Parcelable {
- private LatLng southWest;
- private LatLng northEast;
+ private LatLng mSouthWest;
+ private LatLng mNorthEast;
- public CoordinateBounds(LatLng southWest, LatLng northEast) {
- this.southWest = southWest;
- this.northEast = northEast;
+ public CoordinateBounds(@NonNull Parcel in) {
+ mSouthWest = in.readParcelable(LatLng.class.getClassLoader());
+ mNorthEast = in.readParcelable(LatLng.class.getClassLoader());
}
+ public CoordinateBounds(@NonNull LatLng southWest, @NonNull LatLng northEast) {
+ mSouthWest = southWest;
+ mNorthEast = northEast;
+ }
+
+ @NonNull
public LatLng getSouthWest() {
- return southWest;
+ return mSouthWest;
}
- public void setSouthWest(LatLng southWest) {
- this.southWest = southWest;
+ public void setSouthWest(@NonNull LatLng mSouthWest) {
+ this.mSouthWest = mSouthWest;
}
+ @NonNull
public LatLng getNorthEast() {
- return northEast;
+ return mNorthEast;
}
- public void setNorthEast(LatLng northEast) {
- this.northEast = northEast;
+ public void setNorthEast(@NonNull LatLng mNorthEast) {
+ this.mNorthEast = mNorthEast;
}
@Override
public int hashCode() {
int result;
long temp;
- temp = southWest.hashCode();
+ temp = mSouthWest.hashCode();
result = (int) (temp ^ (temp >>> 32));
- temp = northEast.hashCode();
+ temp = mNorthEast.hashCode();
result = 31 * result + (int) (temp ^ (temp >>> 32));
return result;
}
@@ -53,6 +64,30 @@ public class CoordinateBounds {
@Override
public String toString() {
- return "CoordinateBounds [northEast[" + getNorthEast() + "], southWest[]" + getSouthWest() + "]";
+ return "CoordinateBounds [mNorthEast[" + getNorthEast() + "], mSouthWest[]" + getSouthWest() + "]";
+ }
+
+ public static final Parcelable.Creator CREATOR =
+ new Parcelable.Creator() {
+ @Override
+ public CoordinateBounds createFromParcel(Parcel in) {
+ return new CoordinateBounds(in);
+ }
+
+ @Override
+ public CoordinateBounds[] newArray(int size) {
+ return new CoordinateBounds[size];
+ }
+ };
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int arg1) {
+ out.writeParcelable(mSouthWest, arg1);
+ out.writeParcelable(mNorthEast, arg1);
}
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateRegion.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateRegion.java
index a70bb05a4..c7c0aa1c4 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateRegion.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateRegion.java
@@ -1,30 +1,64 @@
package com.mapbox.mapboxsdk.geometry;
-/**
- * Implementation of iOS MKCoordinateRegion
- */
-public class CoordinateRegion {
- private LatLng center;
- private CoordinateSpan span;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.support.annotation.NonNull;
- public CoordinateRegion(final LatLng center, final CoordinateSpan span) {
- this.center = center;
- this.span = span;
+/**
+ * A geographical region defined by a {@link LatLng} and a {@link CoordinateSpan}.
+ */
+public class CoordinateRegion implements Parcelable{
+
+ private LatLng mCenter;
+ private CoordinateSpan mSpan;
+
+ public CoordinateRegion(@NonNull Parcel in){
+ mCenter = in.readParcelable(LatLng.class.getClassLoader());
+ mSpan = in.readParcelable(CoordinateSpan.class.getClassLoader());
+ }
+
+ public CoordinateRegion(@NonNull LatLng center, @NonNull CoordinateSpan span) {
+ mCenter = center;
+ mSpan = span;
}
public LatLng getCenter() {
- return center;
+ return mCenter;
}
- public void setCenter(final LatLng center) {
- this.center = center;
+ public void setCenter(@NonNull LatLng center) {
+ mCenter = center;
}
public CoordinateSpan getSpan() {
- return span;
+ return mSpan;
}
- public void setSpan(final CoordinateSpan span) {
- this.span = span;
+ public void setSpan(@NonNull CoordinateSpan span) {
+ this.mSpan = span;
+ }
+
+ public static final Parcelable.Creator CREATOR =
+ new Parcelable.Creator() {
+ @Override
+ public CoordinateRegion createFromParcel(Parcel in) {
+ return new CoordinateRegion(in);
+ }
+
+ @Override
+ public CoordinateRegion[] newArray(int size) {
+ return new CoordinateRegion[size];
+ }
+ };
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int arg1) {
+ out.writeParcelable(mCenter, arg1);
+ out.writeParcelable(mSpan, arg1);
}
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateSpan.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateSpan.java
index 79361f725..a43757713 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateSpan.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/CoordinateSpan.java
@@ -1,32 +1,41 @@
package com.mapbox.mapboxsdk.geometry;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.support.annotation.NonNull;
+
/**
- * Implementation of iOS MKCoordinateSpan
+ * A geographical span defined by its latitude and longitude span.
*/
-public class CoordinateSpan {
+public class CoordinateSpan implements Parcelable {
- private double latitudeSpan;
- private double longitudeSpan;
+ private double mLatitudeSpan;
+ private double mLongitudeSpan;
- public CoordinateSpan(final double latitudeSpan, final double longitudeSpan) {
- this.latitudeSpan = latitudeSpan;
- this.longitudeSpan = longitudeSpan;
+ public CoordinateSpan(@NonNull Parcel in){
+ mLatitudeSpan = in.readDouble();
+ mLongitudeSpan = in.readDouble();
+ }
+
+ public CoordinateSpan(double latitudeSpan, double longitudeSpan) {
+ mLatitudeSpan = latitudeSpan;
+ mLongitudeSpan = longitudeSpan;
}
public double getLatitudeSpan() {
- return latitudeSpan;
+ return mLatitudeSpan;
}
- public void setLatitudeSpan(final double latitudeSpan) {
- this.latitudeSpan = latitudeSpan;
+ public void setLatitudeSpan(double latitudeSpan) {
+ mLatitudeSpan = latitudeSpan;
}
public double getLongitudeSpan() {
- return longitudeSpan;
+ return mLongitudeSpan;
}
- public void setLongitudeSpan(final double longitudeSpan) {
- this.longitudeSpan = longitudeSpan;
+ public void setLongitudeSpan(double longitudeSpan) {
+ mLongitudeSpan = longitudeSpan;
}
@Override
@@ -34,10 +43,33 @@ public class CoordinateSpan {
if (this == o) return true;
if (o instanceof CoordinateSpan) {
CoordinateSpan other = (CoordinateSpan) o;
- return longitudeSpan == other.getLongitudeSpan()
- && latitudeSpan == other.getLatitudeSpan();
+ return mLongitudeSpan == other.getLongitudeSpan()
+ && mLatitudeSpan == other.getLatitudeSpan();
}
return false;
}
-}
+ public static final Parcelable.Creator CREATOR =
+ new Parcelable.Creator() {
+ @Override
+ public CoordinateSpan createFromParcel(Parcel in) {
+ return new CoordinateSpan(in);
+ }
+
+ @Override
+ public CoordinateSpan[] newArray(int size) {
+ return new CoordinateSpan[size];
+ }
+ };
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(Parcel out, int arg1) {
+ out.writeDouble(mLatitudeSpan);
+ out.writeDouble(mLongitudeSpan);
+ }
+}
\ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java
index 892d0ad4a..afd22e5dd 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ILatLng.java
@@ -1,7 +1,7 @@
package com.mapbox.mapboxsdk.geometry;
/**
- * A Latitude, Longitude point.
+ * Describes a latitude, longitude point.
*/
public interface ILatLng {
double getLatitude();
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java
index 5aa5f607e..43fe25f8e 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/IProjectedMeters.java
@@ -1,5 +1,8 @@
package com.mapbox.mapboxsdk.geometry;
+/**
+ * Describes a projection in Mercator meters.
+ */
public interface IProjectedMeters {
double getNorthing();
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java
index c340b09e0..f24c2ed43 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLng.java
@@ -10,9 +10,10 @@ import com.mapbox.mapboxsdk.constants.MathConstants;
import java.io.Serializable;
/**
+ * A geographical location which contains a single latitude, longitude pair, with
+ * optional altitude.
*
- * This class is container for a single latitude, longitude pair, with
- * optional altitude. Latitude and longitude are expressed as decimal degrees
+ * Latitude and longitude are expressed as decimal degrees
* in the WGS84 datum. By default, altitude is 0.0, or sea level.
*
*
@@ -20,7 +21,7 @@ import java.io.Serializable;
* data automatically, so all data enters in the WGS84 datum.
*
*/
-public class LatLng implements ILatLng, Parcelable, Serializable {
+public class LatLng implements ILatLng, Parcelable {
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
public LatLng createFromParcel(Parcel in) {
@@ -129,7 +130,6 @@ public class LatLng implements ILatLng, Parcelable, Serializable {
LatLng latLng = (LatLng) o;
return Double.compare(latLng.altitude, altitude) == 0 && Double.compare(latLng.latitude, latitude) == 0 && Double.compare(latLng.longitude, longitude) == 0;
-
}
@Override
@@ -168,6 +168,10 @@ public class LatLng implements ILatLng, Parcelable, Serializable {
* @return distance in meters
*/
public double distanceTo(LatLng other) {
+ if(latitude == other.latitude && longitude == other.longitude){
+ // return 0.0 to avoid a NaN
+ return 0.0;
+ }
final double a1 = MathConstants.DEG2RAD * this.latitude;
final double a2 = MathConstants.DEG2RAD * this.longitude;
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngZoom.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngZoom.java
index 9e453a391..6e24faaa9 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngZoom.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/LatLngZoom.java
@@ -5,7 +5,10 @@ import android.os.Parcelable;
import java.io.Serializable;
-public class LatLngZoom extends LatLng implements Parcelable, Serializable {
+/**
+ * A geographical location which contains a {@link LatLng}, zoom pair.
+ */
+public class LatLngZoom extends LatLng implements Parcelable {
public static final Parcelable.Creator CREATOR = new Parcelable.Creator() {
public LatLngZoom createFromParcel(Parcel in) {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java
index fc821e887..06a58fe8a 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/geometry/ProjectedMeters.java
@@ -6,12 +6,14 @@ import android.os.Parcelable;
import java.io.Serializable;
/**
- * ProjectedMeters is an internal representation of longitude, latitude points that
- * have been projected into Mapbox GL's Mercator projection. Instead of decimal
+ * ProjectedMeters is a projection of longitude, latitude points in Mercator meters.
+ *
+ * these have been projected into Mapbox GL's Mercator projection. Instead of decimal
* degrees, it uses Mercator meters (which are notably not equivalent to SI meters)
* except at the equator.
+ *
*/
-public class ProjectedMeters implements IProjectedMeters, Parcelable, Serializable {
+public class ProjectedMeters implements IProjectedMeters, Parcelable {
public static final Creator CREATOR = new Creator() {
public ProjectedMeters createFromParcel(Parcel in) {
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java
index 9f6a67571..7ffe338d8 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java
@@ -139,6 +139,7 @@ public final class MapView extends FrameLayout {
private static final String STATE_DEFAULT_TRANSITION_DURATION = "defaultTransitionDuration";
private static final String STATE_MY_LOCATION_ENABLED = "myLocationEnabled";
private static final String STATE_MY_LOCATION_TRACKING_MODE = "myLocationTracking";
+ private static final String STATE_MY_BEARING_TRACKING_MODE = "myBearingTracking";
private static final String STATE_COMPASS_ENABLED = "compassEnabled";
private static final String STATE_COMPASS_GRAVITY = "compassGravity";
private static final String STATE_COMPASS_MARGIN_LEFT = "compassMarginLeft";
@@ -804,7 +805,7 @@ public final class MapView extends FrameLayout {
mZoomButtonsController.setOnZoomListener(new OnZoomListener());
// Check current connection status
- ConnectivityManager connectivityManager = (ConnectivityManager) context
+ ConnectivityManager connectivityManager = (ConnectivityManager) context.getApplicationContext()
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo activeNetwork = connectivityManager.getActiveNetworkInfo();
boolean isConnected = (activeNetwork != null) && activeNetwork.isConnectedOrConnecting();
@@ -973,6 +974,8 @@ public final class MapView extends FrameLayout {
//noinspection ResourceType
setMyLocationTrackingMode(savedInstanceState.getInt(STATE_MY_LOCATION_TRACKING_MODE, MyLocationTracking.TRACKING_NONE));
+ //noinspection ResourceType
+ setMyBearingTrackingMode(savedInstanceState.getInt(STATE_MY_BEARING_TRACKING_MODE, MyBearingTracking.NONE));
}
// Force a check for an access token
@@ -1025,6 +1028,7 @@ public final class MapView extends FrameLayout {
outState.putLong(STATE_DEFAULT_TRANSITION_DURATION, mNativeMapView.getDefaultTransitionDuration());
outState.putBoolean(STATE_MY_LOCATION_ENABLED, isMyLocationEnabled());
outState.putInt(STATE_MY_LOCATION_TRACKING_MODE, mUserLocationView.getMyLocationTrackingMode());
+ outState.putInt(STATE_MY_BEARING_TRACKING_MODE, mUserLocationView.getMyBearingTrackingMode());
// Compass
LayoutParams compassParams = (LayoutParams) mCompassView.getLayoutParams();
@@ -2694,8 +2698,9 @@ public final class MapView extends FrameLayout {
}
if (!handledDefaultClick) {
- // default behaviour show InfoWindow
- mInfoWindows.add(marker.showInfoWindow());
+ if (isInfoWindowValidForMarker(marker)) {
+ mInfoWindows.add(marker.showInfoWindow(this));
+ }
}
mSelectedMarkers.add(marker);
@@ -2736,6 +2741,10 @@ public final class MapView extends FrameLayout {
mSelectedMarkers.remove(marker);
}
+ private boolean isInfoWindowValidForMarker(@NonNull Marker marker) {
+ return !TextUtils.isEmpty(marker.getTitle()) || !TextUtils.isEmpty(marker.getSnippet());
+ }
+
//
// Mapbox Core GL Camera
//
@@ -2873,10 +2882,8 @@ public final class MapView extends FrameLayout {
for (Marker marker : mSelectedMarkers) {
if (marker.isInfoWindowShown()) {
- Marker temp = marker;
- temp.hideInfoWindow();
- temp.showInfoWindow();
- marker = temp;
+ marker.hideInfoWindow();
+ marker.showInfoWindow(this);
}
}
}
@@ -3173,9 +3180,9 @@ public final class MapView extends FrameLayout {
// Open / Close InfoWindow
PointF tapPoint = new PointF(e.getX(), e.getY());
- final float toleranceSides = 30 * mScreenDensity;
- final float toleranceTop = 40 * mScreenDensity;
- final float toleranceBottom = 10 * mScreenDensity;
+ final float toleranceSides = 15 * mScreenDensity;
+ final float toleranceTop = 20 * mScreenDensity;
+ final float toleranceBottom = 5 * mScreenDensity;
RectF tapRect = new RectF(tapPoint.x - toleranceSides, tapPoint.y + toleranceTop,
tapPoint.x + toleranceSides, tapPoint.y - toleranceBottom);
@@ -3188,52 +3195,27 @@ public final class MapView extends FrameLayout {
);
BoundingBox tapBounds = BoundingBox.fromLatLngs(corners);
-
List nearbyMarkers = getMarkersInBounds(tapBounds);
+ long newSelectedMarkerId = -1;
- long newSelectedMarkerId;
-
- if (nearbyMarkers.size() > 0) {
-
- // there is at least one nearby marker; select one
- //
- // first, sort for comparison and iteration
+ if (nearbyMarkers!=null && nearbyMarkers.size() > 0) {
Collections.sort(nearbyMarkers);
-
- if (nearbyMarkers == mMarkersNearLastTap) {
-
- // TODO: We still need to adapt this logic to the new mSelectedMarkers list,
- // though the basic functionality is there.
-
- // the selection candidates haven't changed; cycle through them
-// if (mSelectedMarker != null
-// && (mSelectedMarker.getId() == mMarkersNearLastTap.get(mMarkersNearLastTap.size() - 1).getId())) {
-// // the selected marker is the last in the set; cycle back to the first
-// // note: this could be the selected marker if only one in set
-// newSelectedMarkerId = mMarkersNearLastTap.get(0).getId();
-// } else if (mSelectedMarker != null) {
-// // otherwise increment the selection through the candidates
-// long result = mMarkersNearLastTap.indexOf(mSelectedMarker);
-// newSelectedMarkerId = mMarkersNearLastTap.get((int) result + 1).getId();
-// } else {
- // no current selection; select the first one
- newSelectedMarkerId = mMarkersNearLastTap.get(0).getId();
-// }
- } else {
- // start tracking a new set of nearby markers
- mMarkersNearLastTap = nearbyMarkers;
-
- // select the first one
- newSelectedMarkerId = mMarkersNearLastTap.get(0).getId();
+ for (Marker nearbyMarker : nearbyMarkers) {
+ boolean found = false;
+ for (Marker selectedMarker : mSelectedMarkers) {
+ if(selectedMarker.equals(nearbyMarker)){
+ found = true;
+ }
+ }
+ if(!found){
+ newSelectedMarkerId = nearbyMarker.getId();
+ break;
+ }
}
-
- } else {
- // there are no nearby markers; deselect if necessary
- newSelectedMarkerId = -1;
+ mMarkersNearLastTap = nearbyMarkers;
}
if (newSelectedMarkerId >= 0) {
-
int count = mAnnotations.size();
for (int i = 0; i < count; i++) {
Annotation annotation = mAnnotations.get(i);
@@ -3246,7 +3228,6 @@ public final class MapView extends FrameLayout {
}
}
}
-
} else {
// deselect any selected marker
deselectMarkers();
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/UserLocationView.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/UserLocationView.java
index 67dc9a349..d0f278a52 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/UserLocationView.java
+++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/UserLocationView.java
@@ -34,11 +34,13 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.location.LocationListener;
import com.mapbox.mapboxsdk.location.LocationServices;
+import java.lang.ref.WeakReference;
+
/**
* This view shows the user's location, as determined from GPS, on the map
* as a dot annotation.
*/
-final class UserLocationView extends View implements LocationListener {
+final class UserLocationView extends View {
private MapView mMapView;
@@ -85,6 +87,7 @@ final class UserLocationView extends View implements LocationListener {
private boolean mPaused = false;
private Location mUserLocation;
+ private UserLocationListener mUserLocationListener;
MapView.OnMyLocationChangeListener mOnMyLocationChangeListener;
@@ -377,14 +380,18 @@ final class UserLocationView extends View implements LocationListener {
setLocation(lastLocation);
}
+ if(mUserLocationListener==null){
+ mUserLocationListener = new UserLocationListener(this);
+ }
+
// Register for Location Updates
- locationServices.addLocationListener(this);
+ locationServices.addLocationListener(mUserLocationListener);
} else {
// Disable location and user dot
setLocation(null);
// Deregister for Location Updates
- locationServices.removeLocationListener(this);
+ locationServices.removeLocationListener(mUserLocationListener);
}
locationServices.toggleGPS(enableGps);
@@ -498,17 +505,27 @@ final class UserLocationView extends View implements LocationListener {
}
}
- /**
- * Callback method for receiving location updates from LocationServices.
- *
- * @param location The new Location data
- */
- @Override
- public void onLocationChanged(Location location) {
- if (mPaused) {
- return;
+ private static class UserLocationListener implements LocationListener{
+
+ private WeakReference mUserLocationView;
+
+ public UserLocationListener(UserLocationView userLocationView) {
+ mUserLocationView = new WeakReference<>(userLocationView);
+ }
+
+
+ /**
+ * Callback method for receiving location updates from LocationServices.
+ *
+ * @param location The new Location data
+ */
+ @Override
+ public void onLocationChanged(Location location) {
+ UserLocationView locationView = mUserLocationView.get();
+ if(locationView!=null && !locationView.isPaused()){
+ locationView.setLocation(location);
+ }
}
- setLocation(location);
}
private boolean isStale(Location location) {
@@ -751,4 +768,8 @@ final class UserLocationView extends View implements LocationListener {
}
}
+ public boolean isPaused(){
+ return mPaused;
+ }
+
}
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties b/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties
index 030ebae5c..e09bb0110 100644
--- a/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties
+++ b/platform/android/MapboxGLAndroidSDK/src/main/resources/fabric/com.mapbox.mapboxsdk.mapbox-android-sdk.properties
@@ -1,3 +1,3 @@
fabric-identifier=com.mapbox.mapboxsdk.mapbox-android-sdk
-fabric-version=3.0.0
+fabric-version=3.1.0
fabric-build-type=binary
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
index 815fe8d00..41d75cc0b 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
+++ b/platform/android/MapboxGLAndroidSDKTestApp/build.gradle
@@ -86,6 +86,11 @@ dependencies {
transitive=true
}
+ // Geocoder SDK
+ compile ('com.mapbox.mapboxsdk:mapbox-android-geocoder:1.0.0@aar'){
+ transitive=true
+ }
+
// Testing dependencies
testCompile 'junit:junit:4.12'
testCompile 'org.mockito:mockito-core:1.10.19'
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
index af74d52c2..d5a6df956 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/AndroidManifest.xml
@@ -66,6 +66,12 @@
+
+
() {
+ @Override
+ public void onResponse(Response response, Retrofit retrofit) {
+ List results = response.body().getFeatures();
+ if (results.size() > 0) {
+ String placeName = results.get(0).getPlaceName();
+ setSuccess(placeName);
+ } else {
+ setMessage("No results.");
+ }
+ }
+
+ @Override
+ public void onFailure(Throwable t) {
+ setError(t.getMessage());
+ }
+ });
+
+ }
+
+ /*
+ * Update text view
+ */
+
+ private void setMessage(String message) {
+ Log.d(LOG_TAG, "Message: " + message);
+ textView.setText(message);
+ }
+
+ private void setSuccess(String placeName) {
+ Log.d(LOG_TAG, "Place name: " + placeName);
+ textView.setText(placeName);
+ }
+
+ private void setError(String message) {
+ Log.e(LOG_TAG, "Error: " + message);
+ textView.setText("Error: " + message);
+ }
+
+}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java
index 63fa396af..645104644 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/MainActivity.java
@@ -389,8 +389,6 @@ public class MainActivity extends AppCompatActivity {
} else {
startActivity(new Intent(getApplicationContext(), MyLocationTrackingModeActivity.class));
}
-
-
return true;
case R.id.action_polyline:
@@ -409,6 +407,23 @@ public class MainActivity extends AppCompatActivity {
startActivity(new Intent(getApplicationContext(), DirectionsActivity.class));
return true;
+ case R.id.action_double_mapview:
+ if ((ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_COARSE_LOCATION)
+ != PackageManager.PERMISSION_GRANTED) ||
+ (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION)
+ != PackageManager.PERMISSION_GRANTED)) {
+ ActivityCompat.requestPermissions(MainActivity.this,
+ new String[]{Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_FINE_LOCATION},
+ PERMISSIONS_TRACKING_MODE_ACTIVITY);
+ } else {
+ startActivity(new Intent(getApplicationContext(), DoubleMapActivity.class));
+ }
+ return true;
+
+ case R.id.action_geocoder:
+ startActivity(new Intent(getApplicationContext(), GeocoderActivity.class));
+ return true;
+
default:
return changeMapStyle(menuItem.getItemId());
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/PolylineActivity.java b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/PolylineActivity.java
index e000cf079..d2d266a31 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/PolylineActivity.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/java/com/mapbox/mapboxsdk/testapp/PolylineActivity.java
@@ -22,6 +22,12 @@ import java.util.List;
public class PolylineActivity extends AppCompatActivity {
private static final String STATE_POLYLINE_OPTIONS = "polylineOptions";
+ private static final LatLng ANDORRA = new LatLng(42.505777, 1.52529);
+ private static final LatLng LUXEMBOURG = new LatLng(49.815273, 6.129583);
+ private static final LatLng MONACO = new LatLng(43.738418, 7.424616);
+ private static final LatLng VATICAN_CITY = new LatLng(41.902916, 12.453389);
+ private static final LatLng SAN_MARINO = new LatLng(43.942360, 12.457777);
+ private static final LatLng LIECHTENSTEIN = new LatLng(47.166000, 9.555373);
private List mPolylines;
private ArrayList mPolylineOptions = new ArrayList<>();
@@ -48,8 +54,9 @@ public class PolylineActivity extends AppCompatActivity {
if (savedInstanceState != null) {
mPolylineOptions = savedInstanceState.getParcelableArrayList(STATE_POLYLINE_OPTIONS);
} else {
- mPolylineOptions.addAll(PolylineProvider.getAll());
+ mPolylineOptions.addAll(getAllPolylines());
}
+
mPolylines = mMapView.addPolylines(mPolylineOptions);
findViewById(R.id.fab).setOnClickListener(new View.OnClickListener() {
@@ -65,12 +72,38 @@ public class PolylineActivity extends AppCompatActivity {
}
}
mPolylineOptions.clear();
- mPolylineOptions.addAll(PolylineProvider.getRandomLine());
+ mPolylineOptions.addAll(getRandomLine());
mPolylines = mMapView.addPolylines(mPolylineOptions);
}
});
}
+ private List getAllPolylines() {
+ List options = new ArrayList<>();
+ options.add(generatePolyline(ANDORRA, LUXEMBOURG, "#F44336"));
+ options.add(generatePolyline(ANDORRA, MONACO, "#FF5722"));
+ options.add(generatePolyline(MONACO, VATICAN_CITY, "#673AB7"));
+ options.add(generatePolyline(VATICAN_CITY, SAN_MARINO, "#009688"));
+ options.add(generatePolyline(SAN_MARINO, LIECHTENSTEIN, "#795548"));
+ options.add(generatePolyline(LIECHTENSTEIN, LUXEMBOURG, "#3F51B5"));
+ return options;
+ }
+
+ private PolylineOptions generatePolyline(LatLng start, LatLng end, String color) {
+ PolylineOptions line = new PolylineOptions();
+ line.add(start);
+ line.add(end);
+ line.color(Color.parseColor(color));
+ return line;
+ }
+
+ public List getRandomLine() {
+ final List randomLines = getAllPolylines();
+ Collections.shuffle(randomLines);
+ return new ArrayList(){{
+ add(randomLines.get(0));
+ }};
+ }
@Override
protected void onStart() {
@@ -139,42 +172,4 @@ public class PolylineActivity extends AppCompatActivity {
}
}
- private static class PolylineProvider {
- private static final LatLng ANDORRA = new LatLng(42.505777, 1.52529);
- private static final LatLng LUXEMBOURG = new LatLng(49.815273, 6.129583);
- private static final LatLng MONACO = new LatLng(43.738418, 7.424616);
- private static final LatLng VATICAN_CITY = new LatLng(41.902916, 12.453389);
- private static final LatLng SAN_MARINO = new LatLng(43.942360, 12.457777);
- private static final LatLng LIECHTENSTEIN = new LatLng(47.166000, 9.555373);
-
- private static final List POLYLINES = new ArrayList() {{
- add(generatePolyline(ANDORRA, LUXEMBOURG, "#F44336"));
- add(generatePolyline(ANDORRA, MONACO, "#FF5722"));
- add(generatePolyline(MONACO, VATICAN_CITY, "#673AB7"));
- add(generatePolyline(VATICAN_CITY, SAN_MARINO, "#009688"));
- add(generatePolyline(SAN_MARINO, LIECHTENSTEIN, "#795548"));
- add(generatePolyline(LIECHTENSTEIN, LUXEMBOURG, "#3F51B5"));
- }};
-
- private static PolylineOptions generatePolyline(LatLng start, LatLng end, String color) {
- PolylineOptions line = new PolylineOptions();
- line.add(start);
- line.add(end);
- line.color(Color.parseColor(color));
- return line;
- }
-
- public static List getAll() {
- return POLYLINES;
- }
-
- public static List getRandomLine() {
- List randomLines = new ArrayList<>();
- Collections.shuffle(POLYLINES);
- randomLines.add(POLYLINES.get(0));
- return randomLines;
- }
-
- }
-
}
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_dns_24dp.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_dns_24dp.xml
new file mode 100644
index 000000000..5b7b1bce6
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/drawable/ic_dns_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_geocoder.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_geocoder.xml
new file mode 100644
index 000000000..ce0802385
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/activity_geocoder.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/fragment_double_map.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/fragment_double_map.xml
new file mode 100644
index 000000000..0695fafd1
--- /dev/null
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/layout/fragment_double_map.xml
@@ -0,0 +1,27 @@
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml
index ad9deba18..2fd9e6c75 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/menu/menu_drawer.xml
@@ -155,6 +155,18 @@
android:icon="@drawable/ic_directions"
android:title="@string/activity_directions" />
+
+
+
+
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml
index c096284fd..6caf0f7df 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/main/res/values/strings.xml
@@ -20,6 +20,8 @@
Animate Coordinate Change
Custom Layer
Directions Activity
+ Geocoder Activity
+ Double Map Activity
Main Activity Controls
Main Activity Styles
@@ -43,6 +45,7 @@
Set Visible Bounds
Center map around 2 markers
Remove polylines
+ Double MapView
Move
Ease
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateBoundsTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateBoundsTest.java
index a5d389130..1dc4be723 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateBoundsTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/CoordinateBoundsTest.java
@@ -44,7 +44,7 @@ public class CoordinateBoundsTest {
CoordinateBounds coordinateBounds = new CoordinateBounds(northEast, southWest);
assertEquals("string should match",
coordinateBounds.toString(),
- "CoordinateBounds [northEast[" + coordinateBounds.getNorthEast() + "], southWest[]" + coordinateBounds.getSouthWest() + "]");
+ "CoordinateBounds [mNorthEast[" + coordinateBounds.getNorthEast() + "], mSouthWest[]" + coordinateBounds.getSouthWest() + "]");
}
@Test
diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/LatLngTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/LatLngTest.java
index dd075f327..5b24f32b6 100644
--- a/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/LatLngTest.java
+++ b/platform/android/MapboxGLAndroidSDKTestApp/src/test/java/LatLngTest.java
@@ -6,6 +6,7 @@ import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -43,6 +44,23 @@ public class LatLngTest {
assertEquals("altitude default value", latLng2.getAltitude(), altitude, DELTA);
}
+ @Test
+ public void testDistanceTo() {
+ LatLng latLng1 = new LatLng(0.0, 0.0);
+ LatLng latLng2 = new LatLng(1.0, 1.0);
+ assertEquals("distances should match",
+ latLng1.distanceTo(latLng2),
+ 157425.53710839353, DELTA);
+ }
+
+ @Test
+ public void testDistanceToSamePoint() {
+ LatLng latLng1 = new LatLng(40.71199035644531, -74.0081);
+ LatLng latLng2 = new LatLng(40.71199035644531, -74.0081);
+ double distance = latLng1.distanceTo(latLng2);
+ assertEquals("distance should match", 0.0, distance, DELTA);
+ }
+
/*
* A sample test where Mockito is necessary
*/
@@ -86,13 +104,4 @@ public class LatLngTest {
"LatLng [longitude=3.4, latitude=1.2, altitude=5.6]");
}
- @Test
- public void testDistanceTo() {
- LatLng latLng1 = new LatLng(0.0, 0.0);
- LatLng latLng2 = new LatLng(1.0, 1.0);
- assertEquals("distances should match",
- latLng1.distanceTo(latLng2),
- 157425.53710839353, DELTA);
- }
-
}
diff --git a/platform/android/build.gradle b/platform/android/build.gradle
index 2f5700c87..f3a1cc06b 100644
--- a/platform/android/build.gradle
+++ b/platform/android/build.gradle
@@ -22,5 +22,5 @@ allprojects {
}
task wrapper(type: Wrapper) {
- gradleVersion = '2.8'
+ gradleVersion = '2.10'
}
diff --git a/platform/android/gradle/wrapper/gradle-wrapper.jar b/platform/android/gradle/wrapper/gradle-wrapper.jar
index 085a1cdc2..13372aef5 100644
Binary files a/platform/android/gradle/wrapper/gradle-wrapper.jar and b/platform/android/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/platform/android/gradle/wrapper/gradle-wrapper.properties b/platform/android/gradle/wrapper/gradle-wrapper.properties
index 426759170..b4ada9d74 100644
--- a/platform/android/gradle/wrapper/gradle-wrapper.properties
+++ b/platform/android/gradle/wrapper/gradle-wrapper.properties
@@ -1,7 +1,7 @@
-#Thu Nov 05 15:43:10 CST 2015
+#Fri Jan 15 17:23:43 CET 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.8-bin.zip
-distributionSha256Sum=a88db9c2f104defdaa8011c58cf6cda6c114298ae3695ecfb8beb30da3a903cb
+distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-bin.zip
+distributionSha256Sum=66406247f745fc6f05ab382d3f8d3e120c339f34ef54b86f6dc5f6efc18fbb13
diff --git a/platform/android/gradlew b/platform/android/gradlew
index 91a7e269e..9d82f7891 100755
--- a/platform/android/gradlew
+++ b/platform/android/gradlew
@@ -42,11 +42,6 @@ case "`uname`" in
;;
esac
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
@@ -61,9 +56,9 @@ while [ -h "$PRG" ] ; do
fi
done
SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
+cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
+cd "$SAVED" >/dev/null
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
@@ -114,6 +109,7 @@ fi
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
diff --git a/platform/android/gradlew.bat b/platform/android/gradlew.bat
index 8a0b282aa..aec99730b 100644
--- a/platform/android/gradlew.bat
+++ b/platform/android/gradlew.bat
@@ -1,90 +1,90 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windowz variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windowz variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+if "%@eval[2+2]" == "4" goto 4NT_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+goto execute
+
+:4NT_args
+@rem Get arguments from the 4NT Shell from JP Software
+set CMD_LINE_ARGS=%$
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega