diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ApiAccess.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ApiAccess.java
index e6259cf44..354bb0185 100644
--- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ApiAccess.java
+++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/utils/ApiAccess.java
@@ -15,7 +15,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
/**
- * {@link ApiAccess} provides a method to load the Mapbox access token.
+ * {@code ApiAccess} provides a method to load the Mapbox access token.
*/
public final class ApiAccess {
diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/InvalidAccessTokenException.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/InvalidAccessTokenException.java
index d8581a6fd..c32b84407 100644
--- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/InvalidAccessTokenException.java
+++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/InvalidAccessTokenException.java
@@ -3,7 +3,7 @@ package com.mapbox.mapboxsdk.views;
import android.os.Bundle;
/**
- * A {@link InvalidAccessTokenException} is thrown by {@link MapView} when there is either no access
+ * A {@code InvalidAccessTokenException} is thrown by {@link MapView} when there is either no access
* token set before {@link MapView#onCreate(Bundle)} or an invalid access token is set in {@link MapView#setAccessToken(String)}
*
* @see MapView#onCreate(Bundle)
diff --git a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java
index e9341074b..3b1fbdaaf 100644
--- a/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java
+++ b/android/java/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/views/MapView.java
@@ -76,7 +76,7 @@ import java.util.Iterator;
import java.util.List;
/**
- * A {@link MapView} provides an embeddable map interface, similar to the one provided by the Google Maps API.
+ * A {@code MapView} provides an embeddable map interface, similar to the one provided by the Google Maps API.
* You use this class to display map information and to manipulate the map contents from your application.
* You can center the map on a given coordinate, specify the size of the area you want to display,
* and style the features of the map to fit your application's use case.
@@ -1608,7 +1608,22 @@ public final class MapView extends FrameLayout implements LocationListener, Comp
mNativeMapView.setSprite(symbol, bitmap.getWidth(), bitmap.getHeight(), scale, buffer.array());
}
- public Marker addMarker(MarkerOptions markerOptions) {
+ /**
+ * Adds a marker to this map.
+ *
+ * The marker's icon is rendered on the map at the location {@code Marker.position}.
+ * If {@code Marker.title} is defined, the map shows an info box with the marker's title and snippet.
+ *
+ * @param markerOptions A marker options object that defines how to render the marker.
+ * @return The {@code Marker} that was added to the map.
+ */
+ @UiThread
+ @NonNull
+ public Marker addMarker(@NonNull MarkerOptions markerOptions) {
+ if (markerOptions == null) {
+ throw new NullPointerException("markerOptions is null");
+ }
+
Marker marker = markerOptions.getMarker();
// Load the default marker sprite
@@ -1629,7 +1644,22 @@ public final class MapView extends FrameLayout implements LocationListener, Comp
return marker;
}
- public List addMarkers(List markerOptionsList) {
+ /**
+ * Adds multiple markers to this map.
+ *
+ * The marker's icon is rendered on the map at the location {@code Marker.position}.
+ * If {@code Marker.title} is defined, the map shows an info box with the marker's title and snippet.
+ *
+ * @param markerOptionsList A list of marker options objects that defines how to render the markers.
+ * @return A list of the {@code Marker}s that were added to the map.
+ */
+ @UiThread
+ @NonNull
+ public List addMarkers(@NonNull List markerOptionsList) {
+ if (markerOptionsList == null) {
+ throw new NullPointerException("markerOptionsList is null");
+ }
+
List markers = new ArrayList<>(markerOptionsList.size());
for (MarkerOptions markerOptions : markerOptionsList) {
Marker marker = markerOptions.getMarker();
@@ -1661,7 +1691,19 @@ public final class MapView extends FrameLayout implements LocationListener, Comp
return new ArrayList<>(markers);
}
- public Polyline addPolyline(PolylineOptions polylineOptions) {
+ /**
+ * Adds a polyline to this map.
+ *
+ * @param polylineOptions A polyline options object that defines how to render the polyline.
+ * @return The {@code Polyine} that was added to the map.
+ */
+ @UiThread
+ @NonNull
+ public Polyline addPolyline(@NonNull PolylineOptions polylineOptions) {
+ if (polylineOptions == null) {
+ throw new NullPointerException("polylineOptions is null");
+ }
+
Polyline polyline = polylineOptions.getPolyline();
long id = mNativeMapView.addPolyline(polyline);
polyline.setId(id);
@@ -1670,7 +1712,19 @@ public final class MapView extends FrameLayout implements LocationListener, Comp
return polyline;
}
- public List addPolylines(List polylineOptionsList) {
+ /**
+ * Adds multiple polylines to this map.
+ *
+ * @param polylineOptionsList A list of polyline options objects that defines how to render the polylines.
+ * @return A list of the {@code Polyline}s that were added to the map.
+ */
+ @UiThread
+ @NonNull
+ public List addPolylines(@NonNull List polylineOptionsList) {
+ if (polylineOptionsList == null) {
+ throw new NullPointerException("polylineOptionsList is null");
+ }
+
// TODO make faster in JNI
List polylines = new ArrayList<>(polylineOptionsList.size());
for (PolylineOptions polylineOptions : polylineOptionsList) {
@@ -1680,7 +1734,19 @@ public final class MapView extends FrameLayout implements LocationListener, Comp
return new ArrayList<>(polylines);
}
- public Polygon addPolygon(PolygonOptions polygonOptions) {
+ /**
+ * Adds a polygon to this map.
+ *
+ * @param polygonOptions A polygon options object that defines how to render the polygon.
+ * @return The {@code Polygon} that was added to the map.
+ */
+ @UiThread
+ @NonNull
+ public Polygon addPolygon(@NonNull PolygonOptions polygonOptions) {
+ if (polygonOptions == null) {
+ throw new NullPointerException("polygonOptions is null");
+ }
+
Polygon polygon = polygonOptions.getPolygon();
long id = mNativeMapView.addPolygon(polygon);
polygon.setId(id);
@@ -1689,7 +1755,20 @@ public final class MapView extends FrameLayout implements LocationListener, Comp
return polygon;
}
- public List addPolygons(List polygonOptionsList) {
+
+ /**
+ * Adds multiple polygons to this map.
+ *
+ * @param polygonOptionsList A list of polygon options objects that defines how to render the polygons.
+ * @return A list of the {@code Polygon}s that were added to the map.
+ */
+ @UiThread
+ @NonNull
+ public List addPolygons(@NonNull List polygonOptionsList) {
+ if (polygonOptionsList == null) {
+ throw new NullPointerException("polygonOptionsList is null");
+ }
+
List polygons = new ArrayList<>(polygonOptionsList.size());
for (PolygonOptions polygonOptions : polygonOptionsList) {
polygons.add(polygonOptions.getPolygon());
@@ -1709,19 +1788,17 @@ public final class MapView extends FrameLayout implements LocationListener, Comp
return new ArrayList<>(polygons);
}
- private void removeAnnotationsWithId(long annotationId) {
- for (Iterator iterator = mAnnotations.iterator(); iterator.hasNext(); ) {
- Annotation annotation = iterator.next();
- if (annotation instanceof Marker) {
- ((Marker) annotation).hideInfoWindow();
- }
- if (annotation.getId() == annotationId) {
- iterator.remove();
- }
+ /**
+ * Removes an annotation from the map.
+ *
+ * @param annotation The annotation object to remove.
+ */
+ @UiThread
+ public void removeAnnotation(@NonNull Annotation annotation) {
+ if (annotation == null) {
+ throw new NullPointerException("annotation is null");
}
- }
- public void removeAnnotation(Annotation annotation) {
if (annotation instanceof Marker) {
((Marker) annotation).hideInfoWindow();
}
@@ -1730,13 +1807,27 @@ public final class MapView extends FrameLayout implements LocationListener, Comp
mAnnotations.remove(annotation);
}
- public void removeAnnotations(List annotationList) {
+ /**
+ * Removes multiple annotations from the map.
+ *
+ * @param annotationList A list of annotation objects to remove.
+ */
+ @UiThread
+ public void removeAnnotations(@NonNull List annotationList) {
+ if (annotationList == null) {
+ throw new NullPointerException("annotationList is null");
+ }
+
// TODO make faster in JNI
for (Annotation annotation : annotationList) {
removeAnnotation(annotation);
}
}
+ /**
+ * Removes all annotations from the map.
+ */
+ @UiThread
public void removeAllAnnotations() {
long[] ids = new long[mAnnotations.size()];
@@ -1753,11 +1844,22 @@ public final class MapView extends FrameLayout implements LocationListener, Comp
mAnnotations.clear();
}
+ /**
+ * Returns a list of all the annotations on the map.
+ *
+ * @return A list of all the annotation objects. The returned object is a copy so modifying this
+ * list will not update the map.
+ */
+ @NonNull
public List getAllAnnotations() {
return new ArrayList<>(mAnnotations);
}
- private List getMarkersInBounds(BoundingBox bbox) {
+ private List getMarkersInBounds(@NonNull BoundingBox bbox) {
+ if (bbox == null) {
+ throw new NullPointerException("bbox is null");
+ }
+
// TODO: filter in JNI using C++ parameter to getAnnotationsInBounds
long[] ids = mNativeMapView.getAnnotationsInBounds(bbox);
@@ -1791,7 +1893,8 @@ public final class MapView extends FrameLayout implements LocationListener, Comp
* @param latitude The latitude for which to return the value.
* @return The distance measured in meters.
*/
- public double getMetersPerPixelAtLatitude(double latitude) {
+ @UiThread
+ public double getMetersPerPixelAtLatitude(@FloatRange(from = -180, to = 180) double latitude) {
return mNativeMapView.getMetersPerPixelAtLatitude(latitude, getZoomLevel());
}