Merge branch 'release-ios-v3.5.0-android-v5.0.0'
This commit is contained in:
@@ -37,7 +37,8 @@ public final class Mapbox {
|
||||
INSTANCE = new Mapbox(appContext, accessToken);
|
||||
LocationEngine locationEngine = new LocationSource(appContext);
|
||||
locationEngine.setPriority(LocationEnginePriority.NO_POWER);
|
||||
MapboxTelemetry.getInstance().initialize(appContext, accessToken, locationEngine);
|
||||
MapboxTelemetry.getInstance().initialize(
|
||||
appContext, accessToken, BuildConfig.MAPBOX_EVENTS_USER_AGENT, locationEngine);
|
||||
ConnectivityReceiver.instance(appContext);
|
||||
}
|
||||
return INSTANCE;
|
||||
@@ -106,4 +107,4 @@ public final class Mapbox {
|
||||
NetworkInfo activeNetwork = cm.getActiveNetworkInfo();
|
||||
return (activeNetwork != null && activeNetwork.isConnected());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,10 +6,12 @@ import com.mapbox.mapboxsdk.maps.MapView;
|
||||
import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
|
||||
/**
|
||||
* Annotation is an overlay on top of a {@link MapView},
|
||||
* from which {@link Polygon}, {@link Polyline} and {@link Marker} are derived.
|
||||
* Annotation is an overlay on top of a Map.
|
||||
* <p>
|
||||
* it manages attachment to a map and identification, but does not require
|
||||
* Known subclasses are {@link Polygon}, {@link Polyline} and {@link Marker}.
|
||||
* </p>
|
||||
* <p>
|
||||
* This class manages attachment to a map and identification, but does not require
|
||||
* content to be placed at a geographical point.
|
||||
* </p>
|
||||
*/
|
||||
@@ -96,6 +98,12 @@ public abstract class Annotation implements Comparable<Annotation> {
|
||||
return mapView;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares this Annotation object with another Annotation.
|
||||
*
|
||||
* @param annotation Another Annotation to compare with this object.
|
||||
* @return returns 0 if id's match, 1 if id is lower, -1 if id is higher of another Annotation
|
||||
*/
|
||||
@Override
|
||||
public int compareTo(@NonNull Annotation annotation) {
|
||||
if (id < annotation.getId()) {
|
||||
@@ -107,12 +115,10 @@ public abstract class Annotation implements Comparable<Annotation> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares this {@link PolylineOptions} object with another {@link PolylineOptions} and
|
||||
* determines if their color, alpha, width, and vertices match.
|
||||
* Checks if this Annotation object is equal to another Annotation.
|
||||
*
|
||||
* @param object Another {@link PolylineOptions} to compare with this object.
|
||||
* @return True if color, alpha, width, and vertices match this {@link PolylineOptions} object.
|
||||
* Else, false.
|
||||
* @param object Another Annotation to check equality with this object.
|
||||
* @return returns true both id's match else returns false.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
|
||||
@@ -8,12 +8,12 @@ import java.util.List;
|
||||
/**
|
||||
* Multipoint is an abstract annotation for combining geographical locations.
|
||||
*/
|
||||
public abstract class MultiPoint extends Annotation {
|
||||
public abstract class BasePointCollection extends Annotation {
|
||||
|
||||
private List<LatLng> points;
|
||||
private float alpha = 1.0f;
|
||||
|
||||
protected MultiPoint() {
|
||||
protected BasePointCollection() {
|
||||
super();
|
||||
points = new ArrayList<>();
|
||||
}
|
||||
@@ -58,7 +58,7 @@ public abstract class MultiPoint extends Annotation {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set this {@link MultiPoint}s alpha.
|
||||
* Set this {@link BasePointCollection}s alpha.
|
||||
*
|
||||
* @param alpha float value between 0 and 1.
|
||||
*/
|
||||
@@ -14,7 +14,7 @@ import com.mapbox.mapboxsdk.R;
|
||||
/**
|
||||
* Bubble View for Android with custom stroke width and color, arrow size, position and direction.
|
||||
*/
|
||||
class BubbleLayout extends LinearLayout {
|
||||
public class BubbleLayout extends LinearLayout {
|
||||
|
||||
public static final float DEFAULT_STROKE_WIDTH = -1;
|
||||
private ArrowDirection arrowDirection;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.mapbox.mapboxsdk.annotations;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
/**
|
||||
* ViewGroup that dispatches TouchEvents to the parent ViewGroup.
|
||||
* <p>
|
||||
* This allows to dispatch touch events that occur on MarkerView to MapView.
|
||||
* https://github.com/mapbox/mapbox-gl-native/issues/5388
|
||||
* </p>
|
||||
*/
|
||||
public class MarkerViewContainer extends FrameLayout {
|
||||
|
||||
public MarkerViewContainer(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
setTag(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean dispatchTouchEvent(MotionEvent ev) {
|
||||
super.dispatchTouchEvent(ev);
|
||||
boolean actionUp = (boolean) getTag();
|
||||
if (!actionUp) {
|
||||
((ViewGroup) getParent()).onTouchEvent(ev);
|
||||
} else {
|
||||
setTag(false);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.util.LongSparseArray;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
@@ -503,6 +504,26 @@ public class MarkerViewManager implements MapView.OnMapChangedListener {
|
||||
}
|
||||
}
|
||||
|
||||
adaptedView.setOnTouchListener(new View.OnTouchListener() {
|
||||
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
boolean clickHandled = false;
|
||||
if (onMarkerViewClickListener != null) {
|
||||
clickHandled = onMarkerViewClickListener.onMarkerClick(marker, v, adapter);
|
||||
markerViewContainer.setTag(true);
|
||||
}
|
||||
|
||||
if (!clickHandled) {
|
||||
ensureInfoWindowOffset(marker);
|
||||
select(marker, v, adapter);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
marker.setMapboxMap(mapboxMap);
|
||||
markerViewMap.put(marker, adaptedView);
|
||||
if (convertView == null) {
|
||||
@@ -530,34 +551,6 @@ public class MarkerViewManager implements MapView.OnMapChangedListener {
|
||||
updateMarkerViewsPosition();
|
||||
}
|
||||
|
||||
/**
|
||||
* When the provided {@link MarkerView} is clicked on by a user, we check if a custom click
|
||||
* event has been created and if not, display a {@link InfoWindow}.
|
||||
*
|
||||
* @param markerView that the click event occurred.
|
||||
*/
|
||||
public boolean onClickMarkerView(MarkerView markerView) {
|
||||
boolean clickHandled = false;
|
||||
|
||||
MapboxMap.MarkerViewAdapter adapter = getViewAdapter(markerView);
|
||||
View view = getView(markerView);
|
||||
if (adapter == null || view == null) {
|
||||
// not a valid state
|
||||
return true;
|
||||
}
|
||||
|
||||
if (onMarkerViewClickListener != null) {
|
||||
clickHandled = onMarkerViewClickListener.onMarkerClick(markerView, view, adapter);
|
||||
}
|
||||
|
||||
if (!clickHandled) {
|
||||
ensureInfoWindowOffset(markerView);
|
||||
select(markerView, view, adapter);
|
||||
}
|
||||
|
||||
return clickHandled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles the {@link MarkerView}'s info window offset.
|
||||
*
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
/**
|
||||
* Polygon is a geometry annotation that's a closed loop of coordinates.
|
||||
*/
|
||||
public final class Polygon extends MultiPoint {
|
||||
public final class Polygon extends BasePointCollection {
|
||||
|
||||
private int fillColor = Color.BLACK; // default fillColor is black
|
||||
private int strokeColor = Color.BLACK; // default strokeColor is black
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.mapbox.mapboxsdk.maps.MapboxMap;
|
||||
/**
|
||||
* Polyline is a geometry feature with an unclosed list of coordinates drawn as a line
|
||||
*/
|
||||
public final class Polyline extends MultiPoint {
|
||||
public final class Polyline extends BasePointCollection {
|
||||
|
||||
private int color = Color.BLACK; // default color is black
|
||||
private float width = 10; // As specified by Google API Docs (in pixels)
|
||||
|
||||
@@ -1,22 +1,11 @@
|
||||
package com.mapbox.mapboxsdk.exceptions;
|
||||
|
||||
/**
|
||||
* Thrown on conversion errors
|
||||
* A ConversionException is thrown when a conversion failed to execute.
|
||||
*/
|
||||
public class ConversionException extends RuntimeException {
|
||||
|
||||
public ConversionException() {
|
||||
}
|
||||
|
||||
public ConversionException(String detailMessage) {
|
||||
super(detailMessage);
|
||||
}
|
||||
|
||||
public ConversionException(String detailMessage, Throwable throwable) {
|
||||
super(detailMessage, throwable);
|
||||
}
|
||||
|
||||
public ConversionException(Throwable throwable) {
|
||||
super(throwable);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
package com.mapbox.mapboxsdk.exceptions;
|
||||
|
||||
/**
|
||||
* A InvalidMarkerPositionException is thrown when a Marker object is created with an invalid LatLng position.
|
||||
*/
|
||||
public class InvalidMarkerPositionException extends RuntimeException {
|
||||
|
||||
public InvalidMarkerPositionException() {
|
||||
|
||||
@@ -183,7 +183,7 @@ class HTTPRequest implements Callback {
|
||||
return USER_AGENT_STRING = Util.toHumanReadableAscii(
|
||||
String.format("%s %s (%s) Android/%s (%s)",
|
||||
getApplicationIdentifier(),
|
||||
com.mapbox.services.android.telemetry.BuildConfig.MAPBOX_VERSION_STRING,
|
||||
BuildConfig.MAPBOX_VERSION_STRING,
|
||||
BuildConfig.GIT_REVISION_SHORT,
|
||||
Build.VERSION.SDK_INT,
|
||||
Build.CPU_ABI)
|
||||
|
||||
@@ -102,6 +102,7 @@ public class LocationSource extends LocationEngine implements
|
||||
public void requestLocationUpdates() {
|
||||
// Common params
|
||||
LocationRequest request = LocationRequest.create()
|
||||
.setInterval(1000)
|
||||
.setFastestInterval(1000)
|
||||
.setSmallestDisplacement(3.0f);
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.mapbox.mapboxsdk.annotations.Annotation;
|
||||
import com.mapbox.mapboxsdk.annotations.BaseMarkerOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.BaseMarkerViewOptions;
|
||||
import com.mapbox.mapboxsdk.annotations.Icon;
|
||||
import com.mapbox.mapboxsdk.annotations.IconFactory;
|
||||
import com.mapbox.mapboxsdk.annotations.Marker;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerView;
|
||||
import com.mapbox.mapboxsdk.annotations.MarkerViewManager;
|
||||
@@ -256,7 +257,11 @@ class AnnotationManager {
|
||||
|
||||
private MarkerView prepareViewMarker(BaseMarkerViewOptions markerViewOptions) {
|
||||
MarkerView marker = markerViewOptions.getMarker();
|
||||
iconManager.loadIconForMarkerView(marker);
|
||||
Icon icon = markerViewOptions.getIcon();
|
||||
if (icon == null) {
|
||||
icon = IconFactory.getInstance(mapView.getContext()).defaultMarkerView();
|
||||
}
|
||||
marker.setIcon(icon);
|
||||
return marker;
|
||||
}
|
||||
|
||||
@@ -660,24 +665,16 @@ class AnnotationManager {
|
||||
if (annotation.getId() == newSelectedMarkerId) {
|
||||
Marker marker = (Marker) annotation;
|
||||
|
||||
if (marker instanceof MarkerView) {
|
||||
handledDefaultClick = markerViewManager.onClickMarkerView((MarkerView) marker);
|
||||
} else {
|
||||
if (!(marker instanceof MarkerView)) {
|
||||
if (onMarkerClickListener != null) {
|
||||
// end developer has provided a custom click listener
|
||||
handledDefaultClick = onMarkerClickListener.onMarkerClick(marker);
|
||||
}
|
||||
}
|
||||
|
||||
if (annotation instanceof MarkerView) {
|
||||
markerViewManager.onClickMarkerView((MarkerView) annotation);
|
||||
} else {
|
||||
if (!handledDefaultClick) {
|
||||
// only select marker if user didn't handle the click event themselves
|
||||
selectMarker(marker);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,27 +71,6 @@ class IconManager {
|
||||
return icon;
|
||||
}
|
||||
|
||||
Icon loadIconForMarkerView(MarkerView marker) {
|
||||
Icon icon = marker.getIcon();
|
||||
int iconSize = icons.size() + 1;
|
||||
if (icon == null) {
|
||||
icon = IconFactory.getInstance(nativeMapView.getContext()).defaultMarkerView();
|
||||
marker.setIcon(icon);
|
||||
}
|
||||
Bitmap bitmap = icon.getBitmap();
|
||||
averageIconHeight = averageIconHeight + (bitmap.getHeight() - averageIconHeight) / iconSize;
|
||||
averageIconWidth = averageIconWidth + (bitmap.getWidth() - averageIconWidth) / iconSize;
|
||||
if (!icons.contains(icon)) {
|
||||
icons.add(icon);
|
||||
} else {
|
||||
Icon oldIcon = icons.get(icons.indexOf(icon));
|
||||
if (!oldIcon.getBitmap().sameAs(icon.getBitmap())) {
|
||||
throw new IconBitmapChangedException();
|
||||
}
|
||||
}
|
||||
return icon;
|
||||
}
|
||||
|
||||
int getTopOffsetPixelsForIcon(Icon icon) {
|
||||
return (int) (nativeMapView.getTopOffsetPixelsForAnnotationSymbol(icon.getId()) * nativeMapView.getPixelRatio());
|
||||
}
|
||||
|
||||
@@ -4,13 +4,13 @@ import android.content.Context;
|
||||
import android.graphics.PointF;
|
||||
import android.location.Location;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.view.GestureDetectorCompat;
|
||||
import android.support.v4.view.ScaleGestureDetectorCompat;
|
||||
import android.view.InputDevice;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.ScaleGestureDetector;
|
||||
import android.view.ViewConfiguration;
|
||||
import android.widget.ZoomButtonsController;
|
||||
|
||||
import com.almeros.android.multitouch.gesturedetectors.RotateGestureDetector;
|
||||
import com.almeros.android.multitouch.gesturedetectors.ShoveGestureDetector;
|
||||
@@ -92,6 +92,20 @@ final class MapGestureDetector {
|
||||
this.focalPoint = focalPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current active gesture focal point.
|
||||
* <p>
|
||||
* This could be either the user provided focal point in {@link UiSettings#setFocalPoint(PointF)} or the focal point
|
||||
* defined as a result of {@link TrackingSettings#setMyLocationEnabled(boolean)}.
|
||||
* </p>
|
||||
*
|
||||
* @return the current active gesture focal point.
|
||||
*/
|
||||
@Nullable
|
||||
PointF getFocalPoint() {
|
||||
return focalPoint;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given coordinates from a gesture, use the current projection to translate it into
|
||||
* a Location object.
|
||||
@@ -159,10 +173,10 @@ final class MapGestureDetector {
|
||||
|
||||
if (twoTap && isTap && !inProgress) {
|
||||
if (focalPoint != null) {
|
||||
transform.zoom(false, focalPoint.x, focalPoint.y);
|
||||
transform.zoom(false, focalPoint);
|
||||
} else {
|
||||
PointF focalPoint = TwoFingerGestureDetector.determineFocalPoint(event);
|
||||
transform.zoom(false, focalPoint.x, focalPoint.y);
|
||||
transform.zoom(false, focalPoint);
|
||||
}
|
||||
twoTap = false;
|
||||
return true;
|
||||
@@ -262,10 +276,10 @@ final class MapGestureDetector {
|
||||
// Single finger double tap
|
||||
if (focalPoint != null) {
|
||||
// User provided focal point
|
||||
transform.zoom(true, focalPoint.x, focalPoint.y);
|
||||
transform.zoom(true, focalPoint);
|
||||
} else {
|
||||
// Zoom in on gesture
|
||||
transform.zoom(true, e.getX(), e.getY());
|
||||
transform.zoom(true, new PointF(e.getX(), e.getY()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -636,34 +650,6 @@ final class MapGestureDetector {
|
||||
}
|
||||
}
|
||||
|
||||
// This class handles input events from the zoom control buttons
|
||||
// Zoom controls allow single touch only devices to zoom in and out
|
||||
private static class OnZoomListener implements ZoomButtonsController.OnZoomListener {
|
||||
|
||||
private UiSettings uiSettings;
|
||||
private Transform transform;
|
||||
|
||||
OnZoomListener(UiSettings uiSettings, Transform transform) {
|
||||
this.uiSettings = uiSettings;
|
||||
this.transform = transform;
|
||||
}
|
||||
|
||||
// Not used
|
||||
@Override
|
||||
public void onVisibilityChanged(boolean visible) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
// Called when user pushes a zoom button
|
||||
@Override
|
||||
public void onZoom(boolean zoomIn) {
|
||||
if (!uiSettings.isZoomGesturesEnabled()) {
|
||||
return;
|
||||
}
|
||||
transform.zoom(zoomIn);
|
||||
}
|
||||
}
|
||||
|
||||
void setOnMapClickListener(MapboxMap.OnMapClickListener onMapClickListener) {
|
||||
this.onMapClickListener = onMapClickListener;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.maps;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.os.Handler;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.view.KeyEvent;
|
||||
@@ -125,7 +126,8 @@ final class MapKeyListener {
|
||||
}
|
||||
|
||||
// Zoom out
|
||||
transform.zoom(false, uiSettings.getWidth() / 2, uiSettings.getHeight() / 2);
|
||||
PointF focalPoint = new PointF(uiSettings.getWidth() / 2, uiSettings.getHeight() / 2);
|
||||
transform.zoom(false, focalPoint);
|
||||
return true;
|
||||
|
||||
default:
|
||||
@@ -160,7 +162,8 @@ final class MapKeyListener {
|
||||
}
|
||||
|
||||
// Zoom in
|
||||
transform.zoom(true, uiSettings.getWidth() / 2, uiSettings.getHeight() / 2);
|
||||
PointF focalPoint = new PointF(uiSettings.getWidth() / 2, uiSettings.getHeight() / 2);
|
||||
transform.zoom(true, focalPoint);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -214,7 +217,8 @@ final class MapKeyListener {
|
||||
// Only handle if we have not already long pressed
|
||||
if (currentTrackballLongPressTimeOut != null) {
|
||||
// Zoom in
|
||||
transform.zoom(true, uiSettings.getWidth() / 2, uiSettings.getHeight() / 2);
|
||||
PointF focalPoint = new PointF(uiSettings.getWidth() / 2, uiSettings.getHeight() / 2);
|
||||
transform.zoom(true, focalPoint);
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -255,7 +259,8 @@ final class MapKeyListener {
|
||||
// Check if the trackball is still pressed
|
||||
if (!cancelled) {
|
||||
// Zoom out
|
||||
transform.zoom(false, uiSettings.getWidth() / 2, uiSettings.getHeight() / 2);
|
||||
PointF pointF = new PointF(uiSettings.getWidth() / 2, uiSettings.getHeight() / 2);
|
||||
transform.zoom(false, pointF);
|
||||
|
||||
// Ensure the up action is not run
|
||||
currentTrackballLongPressTimeOut = null;
|
||||
|
||||
@@ -31,6 +31,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ZoomButtonsController;
|
||||
|
||||
import com.mapbox.mapboxsdk.Mapbox;
|
||||
import com.mapbox.mapboxsdk.R;
|
||||
@@ -147,7 +148,9 @@ public class MapView extends FrameLayout {
|
||||
// user input
|
||||
mapGestureDetector = new MapGestureDetector(context, transform, proj, uiSettings, trackingSettings, annotations);
|
||||
mapKeyListener = new MapKeyListener(transform, trackingSettings, uiSettings);
|
||||
mapZoomButtonController = new MapZoomButtonController(this, uiSettings, transform);
|
||||
|
||||
MapZoomControllerListener zoomListener = new MapZoomControllerListener(mapGestureDetector, uiSettings, transform);
|
||||
mapZoomButtonController = new MapZoomButtonController(this, uiSettings, zoomListener);
|
||||
|
||||
// inject widgets with MapboxMap
|
||||
compassView.setMapboxMap(mapboxMap);
|
||||
@@ -508,7 +511,7 @@ public class MapView extends FrameLayout {
|
||||
if (destroyed) {
|
||||
return;
|
||||
}
|
||||
mapboxMap.onUpdate();
|
||||
mapboxMap.onUpdateRegionChange();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -521,13 +524,15 @@ public class MapView extends FrameLayout {
|
||||
@CallSuper
|
||||
protected void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
mapZoomButtonController.setVisible(false);
|
||||
if (mapZoomButtonController != null) {
|
||||
mapZoomButtonController.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
// Called when view is hidden and shown
|
||||
@Override
|
||||
protected void onVisibilityChanged(@NonNull View changedView, int visibility) {
|
||||
if (isInEditMode()) {
|
||||
if (isInEditMode() || mapZoomButtonController == null) {
|
||||
return;
|
||||
}
|
||||
mapZoomButtonController.setVisible(visibility == View.VISIBLE);
|
||||
@@ -801,7 +806,7 @@ public class MapView extends FrameLayout {
|
||||
public static final int DID_FINISH_RENDERING_FRAME = 9;
|
||||
|
||||
/**
|
||||
* This event is triggered when the map finished rendeirng the frame fully.
|
||||
* This event is triggered when the map finished rendering the frame fully.
|
||||
* <p>
|
||||
* Register to {@link MapChange} events with {@link MapView#addOnMapChangedListener(OnMapChangedListener)}.
|
||||
* </p>
|
||||
@@ -937,12 +942,59 @@ public class MapView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
|
||||
private class MapZoomControllerListener implements ZoomButtonsController.OnZoomListener {
|
||||
|
||||
private final MapGestureDetector mapGestureDetector;
|
||||
private final UiSettings uiSettings;
|
||||
private final Transform transform;
|
||||
|
||||
MapZoomControllerListener(MapGestureDetector detector, UiSettings uiSettings, Transform transform) {
|
||||
this.mapGestureDetector = detector;
|
||||
this.uiSettings = uiSettings;
|
||||
this.transform = transform;
|
||||
}
|
||||
|
||||
// Not used
|
||||
@Override
|
||||
public void onVisibilityChanged(boolean visible) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
// Called when user pushes a zoom button on the ZoomButtonController
|
||||
@Override
|
||||
public void onZoom(boolean zoomIn) {
|
||||
if (uiSettings.isZoomGesturesEnabled()) {
|
||||
onZoom(zoomIn, mapGestureDetector.getFocalPoint());
|
||||
}
|
||||
}
|
||||
|
||||
private void onZoom(boolean zoomIn, @Nullable PointF focalPoint) {
|
||||
if (focalPoint != null) {
|
||||
transform.zoom(zoomIn, focalPoint);
|
||||
} else {
|
||||
PointF centerPoint = new PointF(getMeasuredWidth() / 2, getMeasuredHeight() / 2);
|
||||
transform.zoom(zoomIn, centerPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class CameraZoomInvalidator implements TrackingSettings.CameraZoomInvalidator {
|
||||
|
||||
@Override
|
||||
public void zoomTo(double zoomLevel) {
|
||||
double currentZoomLevel = mapboxMap.getCameraPosition().zoom;
|
||||
Transform transform = mapboxMap.getTransform();
|
||||
double currentZoomLevel = transform.getCameraPosition().zoom;
|
||||
if (currentZoomLevel < zoomLevel) {
|
||||
mapboxMap.getTransform().setZoom(zoomLevel);
|
||||
setZoom(zoomLevel, mapGestureDetector.getFocalPoint(), transform);
|
||||
}
|
||||
}
|
||||
|
||||
private void setZoom(double zoomLevel, @Nullable PointF focalPoint, @NonNull Transform transform) {
|
||||
if (focalPoint != null) {
|
||||
transform.setZoom(zoomLevel, focalPoint);
|
||||
} else {
|
||||
PointF centerPoint = new PointF(getMeasuredWidth() / 2, getMeasuredHeight() / 2);
|
||||
transform.setZoom(zoomLevel, centerPoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -969,8 +1021,10 @@ public class MapView extends FrameLayout {
|
||||
mapboxMap.onPostMapReady();
|
||||
}
|
||||
});
|
||||
} else if (change == DID_FINISH_RENDERING_FRAME || change == DID_FINISH_RENDERING_FRAME_FULLY_RENDERED) {
|
||||
mapboxMap.onUpdateFullyRendered();
|
||||
} else if (change == REGION_IS_CHANGING || change == REGION_DID_CHANGE || change == DID_FINISH_LOADING_MAP) {
|
||||
mapboxMap.onUpdate();
|
||||
mapboxMap.onUpdateRegionChange();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,11 +16,11 @@ final class MapZoomButtonController extends ZoomButtonsController {
|
||||
|
||||
private UiSettings uiSettings;
|
||||
|
||||
MapZoomButtonController(@NonNull View ownerView, @NonNull UiSettings uiSettings, @NonNull Transform transform) {
|
||||
MapZoomButtonController(@NonNull View ownerView, @NonNull UiSettings uiSettings, @NonNull OnZoomListener listener) {
|
||||
super(ownerView);
|
||||
this.uiSettings = uiSettings;
|
||||
setZoomSpeed(MapboxConstants.ANIMATION_DURATION);
|
||||
setOnZoomListener(new OnZoomListener(uiSettings, transform));
|
||||
setOnZoomListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -29,31 +29,4 @@ final class MapZoomButtonController extends ZoomButtonsController {
|
||||
super.setVisible(visible);
|
||||
}
|
||||
}
|
||||
|
||||
// Zoom controls allow single touch only devices to zoom in and out
|
||||
private static class OnZoomListener implements ZoomButtonsController.OnZoomListener {
|
||||
|
||||
private final UiSettings uiSettings;
|
||||
private final Transform transform;
|
||||
|
||||
OnZoomListener(UiSettings uiSettings, Transform transform) {
|
||||
this.uiSettings = uiSettings;
|
||||
this.transform = transform;
|
||||
}
|
||||
|
||||
// Not used
|
||||
@Override
|
||||
public void onVisibilityChanged(boolean visible) {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
// Called when user pushes a zoom button
|
||||
@Override
|
||||
public void onZoom(boolean zoomIn) {
|
||||
if (!uiSettings.isZoomGesturesEnabled()) {
|
||||
return;
|
||||
}
|
||||
transform.zoom(zoomIn);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,6 +96,9 @@ public final class MapboxMap {
|
||||
setStyleUrl(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the hosting Activity/Fragment onStart() method is called.
|
||||
*/
|
||||
void onStart() {
|
||||
nativeMapView.update();
|
||||
trackingSettings.onStart();
|
||||
@@ -105,10 +108,18 @@ public final class MapboxMap {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the hosting Activity/Fragment onStop() method is called.
|
||||
*/
|
||||
void onStop() {
|
||||
trackingSettings.onStop();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the hosting Activity/Fragment is going to be destroyed and map state needs to be saved.
|
||||
*
|
||||
* @param outState the bundle to save the state to.
|
||||
*/
|
||||
void onSaveInstanceState(Bundle outState) {
|
||||
outState.putParcelable(MapboxConstants.STATE_CAMERA_POSITION, transform.getCameraPosition());
|
||||
outState.putBoolean(MapboxConstants.STATE_DEBUG_ACTIVE, nativeMapView.getDebug());
|
||||
@@ -117,6 +128,11 @@ public final class MapboxMap {
|
||||
uiSettings.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the hosting Activity/Fragment is recreated and map state needs to be restored.
|
||||
*
|
||||
* @param savedInstanceState the bundle containing the saved state
|
||||
*/
|
||||
void onRestoreInstanceState(Bundle savedInstanceState) {
|
||||
final CameraPosition cameraPosition = savedInstanceState.getParcelable(MapboxConstants.STATE_CAMERA_POSITION);
|
||||
if (cameraPosition != null) {
|
||||
@@ -153,16 +169,23 @@ public final class MapboxMap {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the user
|
||||
* Called when the region is changing or has changed.
|
||||
*/
|
||||
void onUpdate() {
|
||||
CameraPosition cameraPosition = transform.invalidateCameraPosition();
|
||||
uiSettings.update(cameraPosition);
|
||||
// FIXME introduce update method with camera position
|
||||
void onUpdateRegionChange() {
|
||||
trackingSettings.update();
|
||||
annotationManager.update();
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when the map frame is fully rendered.
|
||||
*/
|
||||
void onUpdateFullyRendered() {
|
||||
CameraPosition cameraPosition = transform.invalidateCameraPosition();
|
||||
if (cameraPosition != null) {
|
||||
uiSettings.update(cameraPosition);
|
||||
}
|
||||
}
|
||||
|
||||
// Style
|
||||
|
||||
/**
|
||||
@@ -815,10 +838,20 @@ public final class MapboxMap {
|
||||
transform.setBearing(bearing, focalX, focalY, duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the measured height of the Map.
|
||||
*
|
||||
* @return the height of the map
|
||||
*/
|
||||
public float getHeight() {
|
||||
return nativeMapView.getHeight();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the measured width of the Map.
|
||||
*
|
||||
* @return the width of the map
|
||||
*/
|
||||
public float getWidth() {
|
||||
return nativeMapView.getWidth();
|
||||
}
|
||||
@@ -881,35 +914,80 @@ public final class MapboxMap {
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Loads a new map style from the specified URL.
|
||||
* Loads a new map style asynchronous from the specified URL.
|
||||
* </p>
|
||||
* {@code url} can take the following forms:
|
||||
* <ul>
|
||||
* <li>{@code Style.*}: load one of the bundled styles in {@link Style}.</li>
|
||||
* <li>{@code mapbox://styles/<user>/<style>}:
|
||||
* retrieves the style from a <a href="https://www.mapbox.com/account/">Mapbox account.</a>
|
||||
* loads the style from a <a href="https://www.mapbox.com/account/">Mapbox account.</a>
|
||||
* {@code user} is your username. {@code style} is the ID of your custom
|
||||
* style created in <a href="https://www.mapbox.com/studio">Mapbox Studio</a>.</li>
|
||||
* <li>{@code http://...} or {@code https://...}:
|
||||
* retrieves the style over the Internet from any web server.</li>
|
||||
* loads the style over the Internet from any web server.</li>
|
||||
* <li>{@code asset://...}:
|
||||
* reads the style from the APK {@code assets/} directory.
|
||||
* loads the style from the APK {@code assets/} directory.
|
||||
* This is used to load a style bundled with your app.</li>
|
||||
* <li>{@code null}: loads the default {@link Style#MAPBOX_STREETS} style.</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* This method is asynchronous and will return immediately before the style finishes loading.
|
||||
* If you wish to wait for the map to finish loading listen for the {@link MapView#DID_FINISH_LOADING_MAP} event.
|
||||
* This method is asynchronous and will return before the style finishes loading.
|
||||
* If you wish to wait for the map to finish loading, listen for the {@link MapView#DID_FINISH_LOADING_MAP} event
|
||||
* or use the {@link #setStyleUrl(String, OnStyleLoadedListener)} method instead.
|
||||
* </p>
|
||||
* If the style fails to load or an invalid style URL is set, the map view will become blank.
|
||||
* An error message will be logged in the Android logcat and {@link MapView#DID_FAIL_LOADING_MAP} event will be
|
||||
* sent.
|
||||
* emitted.
|
||||
*
|
||||
* @param url The URL of the map style
|
||||
* @see Style
|
||||
*/
|
||||
@UiThread
|
||||
public void setStyleUrl(@NonNull String url) {
|
||||
setStyleUrl(url, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Loads a new map style asynchronous from the specified URL.
|
||||
* </p>
|
||||
* {@code url} can take the following forms:
|
||||
* <ul>
|
||||
* <li>{@code Style.*}: load one of the bundled styles in {@link Style}.</li>
|
||||
* <li>{@code mapbox://styles/<user>/<style>}:
|
||||
* loads the style from a <a href="https://www.mapbox.com/account/">Mapbox account.</a>
|
||||
* {@code user} is your username. {@code style} is the ID of your custom
|
||||
* style created in <a href="https://www.mapbox.com/studio">Mapbox Studio</a>.</li>
|
||||
* <li>{@code http://...} or {@code https://...}:
|
||||
* loads the style over the Internet from any web server.</li>
|
||||
* <li>{@code asset://...}:
|
||||
* loads the style from the APK {@code assets/} directory.
|
||||
* This is used to load a style bundled with your app.</li>
|
||||
* <li>{@code null}: loads the default {@link Style#MAPBOX_STREETS} style.</li>
|
||||
* </ul>
|
||||
* <p>
|
||||
* If the style fails to load or an invalid style URL is set, the map view will become blank.
|
||||
* An error message will be logged in the Android logcat and {@link MapView#DID_FAIL_LOADING_MAP} event will be
|
||||
* emitted.
|
||||
* <p>
|
||||
*
|
||||
* @param url The URL of the map style
|
||||
* @param callback The callback that is invoked when the style has loaded.
|
||||
* @see Style
|
||||
*/
|
||||
@UiThread
|
||||
public void setStyleUrl(@NonNull final String url, @Nullable final OnStyleLoadedListener callback) {
|
||||
if (callback != null) {
|
||||
nativeMapView.addOnMapChangedListener(new MapView.OnMapChangedListener() {
|
||||
@Override
|
||||
public void onMapChanged(@MapView.MapChange int change) {
|
||||
if (change == MapView.DID_FINISH_LOADING_STYLE) {
|
||||
callback.onStyleLoaded(url);
|
||||
nativeMapView.removeOnMapChangedListener(this);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
nativeMapView.setStyleUrl(url);
|
||||
}
|
||||
|
||||
@@ -918,8 +996,9 @@ public final class MapboxMap {
|
||||
* Loads a new map style from the specified bundled style.
|
||||
* </p>
|
||||
* <p>
|
||||
* This method is asynchronous and will return immediately before the style finishes loading.
|
||||
* If you wish to wait for the map to finish loading listen for the {@link MapView#DID_FINISH_LOADING_MAP} event.
|
||||
* This method is asynchronous and will return before the style finishes loading.
|
||||
* If you wish to wait for the map to finish loading, listen for the {@link MapView#DID_FINISH_LOADING_MAP} event
|
||||
* or use the {@link #setStyle(String, OnStyleLoadedListener)} method instead.
|
||||
* </p>
|
||||
* If the style fails to load or an invalid style URL is set, the map view will become blank.
|
||||
* An error message will be logged in the Android logcat and {@link MapView#DID_FAIL_LOADING_MAP} event will be
|
||||
@@ -927,13 +1006,28 @@ public final class MapboxMap {
|
||||
*
|
||||
* @param style The bundled style. Accepts one of the values from {@link Style}.
|
||||
* @see Style
|
||||
* @deprecated use {@link #setStyleUrl(String)} instead with versioned url methods from {@link Style}
|
||||
*/
|
||||
@UiThread
|
||||
public void setStyle(@Style.StyleUrl String style) {
|
||||
setStyleUrl(style);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Loads a new map style from the specified bundled style.
|
||||
* </p>
|
||||
* If the style fails to load or an invalid style URL is set, the map view will become blank.
|
||||
* An error message will be logged in the Android logcat and {@link MapView#DID_FAIL_LOADING_MAP} event will be
|
||||
* sent.
|
||||
*
|
||||
* @param style The bundled style. Accepts one of the values from {@link Style}.
|
||||
* @see Style
|
||||
*/
|
||||
@UiThread
|
||||
public void setStyle(@Style.StyleUrl String style, @Nullable OnStyleLoadedListener callback) {
|
||||
setStyleUrl(style, callback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads a new map style from MapboxMapOptions if available.
|
||||
*
|
||||
@@ -942,20 +1036,17 @@ public final class MapboxMap {
|
||||
private void setStyleUrl(@NonNull MapboxMapOptions options) {
|
||||
String style = options.getStyle();
|
||||
if (!TextUtils.isEmpty(style)) {
|
||||
setStyleUrl(style);
|
||||
setStyleUrl(style, null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Returns the map style currently displayed in the map view.
|
||||
* </p>
|
||||
* If the default style is currently displayed, a URL will be returned instead of null.
|
||||
*
|
||||
* @return The URL of the map style.
|
||||
* @return The URL of the map style
|
||||
*/
|
||||
@UiThread
|
||||
@NonNull
|
||||
@Nullable
|
||||
public String getStyleUrl() {
|
||||
return nativeMapView.getStyleUrl();
|
||||
}
|
||||
@@ -971,8 +1062,8 @@ public final class MapboxMap {
|
||||
* 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.
|
||||
* @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
|
||||
@@ -987,8 +1078,8 @@ public final class MapboxMap {
|
||||
* 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.
|
||||
* @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
|
||||
@@ -1003,8 +1094,8 @@ public final class MapboxMap {
|
||||
* 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.
|
||||
* @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
|
||||
@@ -1012,7 +1103,6 @@ public final class MapboxMap {
|
||||
return annotationManager.addMarker(markerOptions, this, null);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Adds a marker to this map.
|
||||
@@ -1020,9 +1110,9 @@ public final class MapboxMap {
|
||||
* 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.
|
||||
* @param onMarkerViewAddedListener Callback invoked when the View has been added to the map.
|
||||
* @return The {@code Marker} that was added to the map.
|
||||
* @param markerOptions A marker options object that defines how to render the marker
|
||||
* @param onMarkerViewAddedListener Callback invoked when the View has been added to the map
|
||||
* @return The {@code Marker} that was added to the map
|
||||
*/
|
||||
@UiThread
|
||||
@NonNull
|
||||
@@ -1032,7 +1122,14 @@ public final class MapboxMap {
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME javadoc
|
||||
* Adds multiple markersViews to this map.
|
||||
* <p>
|
||||
* 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.
|
||||
* </p>
|
||||
*
|
||||
* @param markerViewOptions A list of markerView options objects that defines how to render the markers
|
||||
* @return A list of the {@code MarkerView}s that were added to the map
|
||||
*/
|
||||
@UiThread
|
||||
@NonNull
|
||||
@@ -1042,7 +1139,10 @@ public final class MapboxMap {
|
||||
}
|
||||
|
||||
/**
|
||||
* FIXME javadoc
|
||||
* Returns markerViews found inside of a rectangle on this map.
|
||||
*
|
||||
* @param rect the rectangular area on the map to query for markerViews
|
||||
* @return A list of the markerViews that were found in the rectangle
|
||||
*/
|
||||
@UiThread
|
||||
@NonNull
|
||||
@@ -1057,8 +1157,8 @@ public final class MapboxMap {
|
||||
* 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.
|
||||
* @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
|
||||
@@ -1072,7 +1172,7 @@ public final class MapboxMap {
|
||||
* Updates a marker on this map. Does nothing if the marker isn't already added.
|
||||
* </p>
|
||||
*
|
||||
* @param updatedMarker An updated marker object.
|
||||
* @param updatedMarker An updated marker object
|
||||
*/
|
||||
@UiThread
|
||||
public void updateMarker(@NonNull Marker updatedMarker) {
|
||||
@@ -1082,8 +1182,8 @@ public final class MapboxMap {
|
||||
/**
|
||||
* 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.
|
||||
* @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
|
||||
@@ -1128,8 +1228,8 @@ public final class MapboxMap {
|
||||
/**
|
||||
* 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.
|
||||
* @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
|
||||
@@ -1137,11 +1237,10 @@ public final class MapboxMap {
|
||||
return annotationManager.addPolygons(polygonOptionsList, this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update a polygon on this map.
|
||||
*
|
||||
* @param polygon An updated polygon object.
|
||||
* @param polygon An updated polygon object
|
||||
*/
|
||||
@UiThread
|
||||
public void updatePolygon(Polygon polygon) {
|
||||
@@ -1152,7 +1251,7 @@ public final class MapboxMap {
|
||||
* <p>
|
||||
* Convenience method for removing a Marker from the map.
|
||||
* </p>
|
||||
* Calls removeAnnotation() internally
|
||||
* Calls removeAnnotation() internally.
|
||||
*
|
||||
* @param marker Marker to remove
|
||||
*/
|
||||
@@ -1165,7 +1264,7 @@ public final class MapboxMap {
|
||||
* <p>
|
||||
* Convenience method for removing a Polyline from the map.
|
||||
* </p>
|
||||
* Calls removeAnnotation() internally
|
||||
* Calls removeAnnotation() internally.
|
||||
*
|
||||
* @param polyline Polyline to remove
|
||||
*/
|
||||
@@ -1178,7 +1277,7 @@ public final class MapboxMap {
|
||||
* <p>
|
||||
* Convenience method for removing a Polygon from the map.
|
||||
* </p>
|
||||
* Calls removeAnnotation() internally
|
||||
* Calls removeAnnotation() internally.
|
||||
*
|
||||
* @param polygon Polygon to remove
|
||||
*/
|
||||
@@ -1558,6 +1657,11 @@ public final class MapboxMap {
|
||||
return annotationManager.getInfoWindowManager().getOnInfoWindowLongClickListener();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an callback to be invoked when an InfoWindow closes.
|
||||
*
|
||||
* @param listener callback invoked when an InfoWindow closes
|
||||
*/
|
||||
public void setOnInfoWindowCloseListener(@Nullable OnInfoWindowCloseListener listener) {
|
||||
annotationManager.getInfoWindowManager().setOnInfoWindowCloseListener(listener);
|
||||
}
|
||||
@@ -1657,7 +1761,6 @@ public final class MapboxMap {
|
||||
* Takes a snapshot of the map.
|
||||
*
|
||||
* @param callback Callback method invoked when the snapshot is taken.
|
||||
* @param bitmap A pre-allocated bitmap.
|
||||
*/
|
||||
@UiThread
|
||||
public void snapshot(@NonNull SnapshotReadyCallback callback) {
|
||||
@@ -2104,6 +2207,16 @@ public final class MapboxMap {
|
||||
void onSnapshotReady(Bitmap snapshot);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface definintion for a callback to be invoked when the style has finished loading.
|
||||
*/
|
||||
public interface OnStyleLoadedListener {
|
||||
/**
|
||||
* Invoked when the style has finished loading.
|
||||
*/
|
||||
void onStyleLoaded(String style);
|
||||
}
|
||||
|
||||
//
|
||||
// Used for instrumentation testing
|
||||
//
|
||||
|
||||
@@ -378,18 +378,11 @@ final class NativeMapView {
|
||||
return nativeGetScale();
|
||||
}
|
||||
|
||||
public void setZoom(double zoom) {
|
||||
public void setZoom(double zoom, PointF focalPoint, long duration) {
|
||||
if (isDestroyedOn("setZoom")) {
|
||||
return;
|
||||
}
|
||||
setZoom(zoom, 0);
|
||||
}
|
||||
|
||||
public void setZoom(double zoom, long duration) {
|
||||
if (isDestroyedOn("setZoom")) {
|
||||
return;
|
||||
}
|
||||
nativeSetZoom(zoom, duration);
|
||||
nativeSetZoom(zoom, focalPoint.x / pixelRatio, focalPoint.y / pixelRatio, duration);
|
||||
}
|
||||
|
||||
public double getZoom() {
|
||||
@@ -1023,7 +1016,7 @@ final class NativeMapView {
|
||||
|
||||
private native double nativeGetScale();
|
||||
|
||||
private native void nativeSetZoom(double zoom, long duration);
|
||||
private native void nativeSetZoom(double zoom, double cx, double cy, long duration);
|
||||
|
||||
private native double nativeGetZoom();
|
||||
|
||||
|
||||
@@ -281,7 +281,7 @@ public final class TrackingSettings {
|
||||
*/
|
||||
void resetTrackingModesIfRequired(CameraPosition cameraPosition) {
|
||||
if (isDismissTrackingModesForCameraPositionChange()) {
|
||||
resetTrackingModesIfRequired(cameraPosition.target != null, cameraPosition.bearing != -1);
|
||||
resetTrackingModesIfRequired(cameraPosition.target != null, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.mapbox.mapboxsdk.maps;
|
||||
|
||||
import android.graphics.PointF;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.annotation.UiThread;
|
||||
@@ -174,23 +175,23 @@ final class Transform implements MapView.OnMapChangedListener {
|
||||
return cameraPosition.zoom;
|
||||
}
|
||||
|
||||
void zoom(boolean zoomIn) {
|
||||
zoom(zoomIn, -1.0f, -1.0f);
|
||||
}
|
||||
|
||||
void zoom(boolean zoomIn, float x, float y) {
|
||||
void zoom(boolean zoomIn, @NonNull PointF focalPoint) {
|
||||
// Cancel any animation
|
||||
cancelTransitions();
|
||||
|
||||
if (zoomIn) {
|
||||
mapView.scaleBy(2.0, x, y, MapboxConstants.ANIMATION_DURATION);
|
||||
} else {
|
||||
mapView.scaleBy(0.5, x, y, MapboxConstants.ANIMATION_DURATION);
|
||||
CameraPosition cameraPosition = invalidateCameraPosition();
|
||||
if (cameraPosition != null) {
|
||||
int newZoom = (int) Math.round(cameraPosition.zoom + (zoomIn ? 1 : -1));
|
||||
setZoom(newZoom, focalPoint, MapboxConstants.ANIMATION_DURATION);
|
||||
}
|
||||
}
|
||||
|
||||
void setZoom(double zoom) {
|
||||
mapView.setZoom(zoom);
|
||||
void setZoom(double zoom, @NonNull PointF focalPoint) {
|
||||
setZoom(zoom, focalPoint, 0);
|
||||
}
|
||||
|
||||
void setZoom(double zoom, @NonNull PointF focalPoint, long duration) {
|
||||
mapView.setZoom(zoom, focalPoint, duration);
|
||||
}
|
||||
|
||||
// Direction
|
||||
|
||||
@@ -257,9 +257,7 @@ public class MyLocationView extends View {
|
||||
|
||||
final PointF pointF = screenLocation;
|
||||
float metersPerPixel = (float) projection.getMetersPerPixelAtLatitude(location.getLatitude());
|
||||
float accuracyPixels = (Float) accuracyAnimator.getAnimatedValue() / metersPerPixel / 2;
|
||||
float maxRadius = getWidth() / 2;
|
||||
accuracyPixels = accuracyPixels <= maxRadius ? accuracyPixels : maxRadius;
|
||||
float accuracyPixels = (Float) accuracyAnimator.getAnimatedValue() / metersPerPixel;
|
||||
|
||||
// reset
|
||||
matrix.reset();
|
||||
@@ -435,10 +433,12 @@ public class MyLocationView extends View {
|
||||
}
|
||||
|
||||
locationEngine.addLocationEngineListener(userLocationListener);
|
||||
locationEngine.activate();
|
||||
} else {
|
||||
// Disable location and user dot
|
||||
location = null;
|
||||
locationEngine.removeLocationEngineListener(userLocationListener);
|
||||
locationEngine.deactivate();
|
||||
}
|
||||
|
||||
locationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY);
|
||||
@@ -573,8 +573,10 @@ public class MyLocationView extends View {
|
||||
public void onConnected() {
|
||||
MyLocationView locationView = userLocationView.get();
|
||||
if (locationView != null) {
|
||||
Location location = LocationSource.getLocationEngine(locationView.getContext()).getLastLocation();
|
||||
LocationEngine locationSource = LocationSource.getLocationEngine(locationView.getContext());
|
||||
Location location = locationSource.getLastLocation();
|
||||
locationView.setLocation(location);
|
||||
locationSource.requestLocationUpdates();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -730,7 +732,7 @@ public class MyLocationView extends View {
|
||||
accuracyAnimator.end();
|
||||
}
|
||||
|
||||
accuracyAnimator = ValueAnimator.ofFloat(accuracy * 10, location.getAccuracy() * 10);
|
||||
accuracyAnimator = ValueAnimator.ofFloat(accuracy, location.getAccuracy());
|
||||
accuracyAnimator.setDuration(750);
|
||||
accuracyAnimator.start();
|
||||
accuracy = location.getAccuracy();
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/**
|
||||
* Contains the Mapbox Maps Android Storage API classes.
|
||||
*/
|
||||
package com.mapbox.mapboxsdk.storage;
|
||||
@@ -3,8 +3,9 @@ package com.mapbox.mapboxsdk.style.sources;
|
||||
import java.util.HashMap;
|
||||
|
||||
/**
|
||||
* Options for the {@link GeoJsonSource}
|
||||
* Builder class for composing GeoJsonSource objects.
|
||||
*
|
||||
* @see GeoJsonSource
|
||||
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-geojson">The online documentation</a>
|
||||
*/
|
||||
public class GeoJsonOptions extends HashMap<String, Object> {
|
||||
|
||||
@@ -15,7 +15,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* A GeoJson source. Exposes a {@link FeatureCollection} from Json.
|
||||
* GeoJson source, allows using FeatureCollections from Json.
|
||||
*
|
||||
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-geojson">the style specification</a>
|
||||
*/
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.mapbox.mapboxsdk.style.sources;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* Raster Source enables the use of raster tiles.
|
||||
* Raster source, allows using raster tiles as source.
|
||||
*
|
||||
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-raster">The style specification</a>
|
||||
*/
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Tile set
|
||||
* Tile set, allows using TileJson specification as source.
|
||||
*
|
||||
* @see <a href="https://github.com/mapbox/tilejson-spec/tree/master/2.1.0">The tileset specification</a>
|
||||
*/
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Vector source enables the use of vector tiles.
|
||||
* Vector source, allows the use of vector tiles.
|
||||
*
|
||||
* @see <a href="https://www.mapbox.com/mapbox-gl-style-spec/#sources-vector">the style specification</a>
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user