Merge master into release-ios-v3.5.0-android-v5.0.0
This commit is contained in:
@@ -43,7 +43,7 @@ public final class Mapbox {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
private Mapbox(@NonNull Context context, @NonNull String accessToken) {
|
||||
Mapbox(@NonNull Context context, @NonNull String accessToken) {
|
||||
this.context = context;
|
||||
this.accessToken = accessToken;
|
||||
}
|
||||
|
||||
@@ -636,6 +636,7 @@ public class MarkerViewManager implements MapView.OnMapChangedListener {
|
||||
viewHolder = (ViewHolder) convertView.getTag();
|
||||
}
|
||||
viewHolder.imageView.setImageBitmap(marker.getIcon().getBitmap());
|
||||
viewHolder.imageView.setContentDescription(marker.getTitle());
|
||||
return convertView;
|
||||
}
|
||||
|
||||
|
||||
@@ -118,6 +118,9 @@ public class MapView extends FrameLayout {
|
||||
ImageView attrView = (ImageView) view.findViewById(R.id.attributionView);
|
||||
initalizeDrawingSurface(context, options);
|
||||
|
||||
// add accessibility support
|
||||
setContentDescription(context.getString(R.string.mapbox_mapActionDescription));
|
||||
|
||||
// create native Map object
|
||||
nativeMapView = new NativeMapView(this);
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.mapbox.mapboxsdk.constants.MyLocationTracking;
|
||||
import com.mapbox.mapboxsdk.constants.Style;
|
||||
import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.maps.widgets.MyLocationViewSettings;
|
||||
import com.mapbox.mapboxsdk.style.layers.Filter;
|
||||
import com.mapbox.mapboxsdk.style.layers.Layer;
|
||||
import com.mapbox.mapboxsdk.style.sources.Source;
|
||||
import com.mapbox.services.commons.geojson.Feature;
|
||||
@@ -1674,7 +1675,23 @@ public final class MapboxMap {
|
||||
@NonNull
|
||||
public List<Feature> queryRenderedFeatures(@NonNull PointF coordinates, @Nullable String...
|
||||
layerIds) {
|
||||
return nativeMapView.queryRenderedFeatures(coordinates, layerIds);
|
||||
return nativeMapView.queryRenderedFeatures(coordinates, layerIds, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries the map for rendered features
|
||||
*
|
||||
* @param coordinates the point to query
|
||||
* @param filter filters the returned features
|
||||
* @param layerIds optionally - only query these layers
|
||||
* @return the list of feature
|
||||
*/
|
||||
@UiThread
|
||||
@NonNull
|
||||
public List<Feature> queryRenderedFeatures(@NonNull PointF coordinates,
|
||||
@Nullable Filter.Statement filter,
|
||||
@Nullable String... layerIds) {
|
||||
return nativeMapView.queryRenderedFeatures(coordinates, layerIds, filter);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1686,9 +1703,25 @@ public final class MapboxMap {
|
||||
*/
|
||||
@UiThread
|
||||
@NonNull
|
||||
public List<Feature> queryRenderedFeatures(@NonNull RectF coordinates, @Nullable String...
|
||||
layerIds) {
|
||||
return nativeMapView.queryRenderedFeatures(coordinates, layerIds);
|
||||
public List<Feature> queryRenderedFeatures(@NonNull RectF coordinates,
|
||||
@Nullable String... layerIds) {
|
||||
return nativeMapView.queryRenderedFeatures(coordinates, layerIds, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Queries the map for rendered features
|
||||
*
|
||||
* @param coordinates the box to query
|
||||
* @param filter filters the returned features
|
||||
* @param layerIds optionally - only query these layers
|
||||
* @return the list of feature
|
||||
*/
|
||||
@UiThread
|
||||
@NonNull
|
||||
public List<Feature> queryRenderedFeatures(@NonNull RectF coordinates,
|
||||
@Nullable Filter.Statement filter,
|
||||
@Nullable String... layerIds) {
|
||||
return nativeMapView.queryRenderedFeatures(coordinates, layerIds, filter);
|
||||
}
|
||||
|
||||
//
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.mapbox.mapboxsdk.geometry.LatLng;
|
||||
import com.mapbox.mapboxsdk.geometry.ProjectedMeters;
|
||||
import com.mapbox.mapboxsdk.storage.FileSource;
|
||||
import com.mapbox.mapboxsdk.style.layers.CannotAddLayerException;
|
||||
import com.mapbox.mapboxsdk.style.layers.Filter;
|
||||
import com.mapbox.mapboxsdk.style.layers.Layer;
|
||||
import com.mapbox.mapboxsdk.style.sources.CannotAddSourceException;
|
||||
import com.mapbox.mapboxsdk.style.sources.Source;
|
||||
@@ -881,27 +882,31 @@ final class NativeMapView {
|
||||
// Feature querying
|
||||
|
||||
@NonNull
|
||||
public List<Feature> queryRenderedFeatures(PointF coordinates, String... layerIds) {
|
||||
public List<Feature> queryRenderedFeatures(@NonNull PointF coordinates,
|
||||
@Nullable String[] layerIds,
|
||||
@Nullable Filter.Statement filter) {
|
||||
if (isDestroyedOn("queryRenderedFeatures")) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
Feature[] features = nativeQueryRenderedFeaturesForPoint(coordinates.x / pixelRatio,
|
||||
coordinates.y / pixelRatio, layerIds);
|
||||
coordinates.y / pixelRatio, layerIds, filter != null ? filter.toArray() : null);
|
||||
return features != null ? Arrays.asList(features) : new ArrayList<Feature>();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public List<Feature> queryRenderedFeatures(RectF coordinates, String... layerIds) {
|
||||
public List<Feature> queryRenderedFeatures(@NonNull RectF coordinates,
|
||||
@Nullable String[] layerIds,
|
||||
@Nullable Filter.Statement filter) {
|
||||
if (isDestroyedOn("queryRenderedFeatures")) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
Feature[] features = nativeQueryRenderedFeaturesForBox(
|
||||
|
||||
coordinates.left / pixelRatio,
|
||||
coordinates.top / pixelRatio,
|
||||
coordinates.right / pixelRatio,
|
||||
coordinates.bottom / pixelRatio,
|
||||
layerIds);
|
||||
layerIds,
|
||||
filter != null ? filter.toArray() : null);
|
||||
return features != null ? Arrays.asList(features) : new ArrayList<Feature>();
|
||||
}
|
||||
|
||||
@@ -1139,12 +1144,14 @@ final class NativeMapView {
|
||||
|
||||
private native void nativeTakeSnapshot();
|
||||
|
||||
private native Feature[] nativeQueryRenderedFeaturesForPoint(float x, float y, String[]
|
||||
layerIds);
|
||||
private native Feature[] nativeQueryRenderedFeaturesForPoint(float x, float y,
|
||||
String[] layerIds,
|
||||
Object[] filter);
|
||||
|
||||
private native Feature[] nativeQueryRenderedFeaturesForBox(float left, float top,
|
||||
float right, float bottom,
|
||||
String[] layerIds);
|
||||
String[] layerIds,
|
||||
Object[] filter);
|
||||
|
||||
int getWidth() {
|
||||
if (isDestroyedOn("")) {
|
||||
|
||||
@@ -56,7 +56,6 @@ public final class CompassView extends AppCompatImageView implements Runnable, F
|
||||
|
||||
private void initialize(Context context) {
|
||||
setImageDrawable(ContextCompat.getDrawable(getContext(), R.drawable.mapbox_compass_icon));
|
||||
setContentDescription(getResources().getString(R.string.mapbox_compassContentDescription));
|
||||
setEnabled(false);
|
||||
|
||||
// Layout params
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.mapbox.mapboxsdk.style.functions.stops.ExponentialStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.IntervalStops;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stop;
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.PropertyValue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -27,7 +28,7 @@ import java.util.Map;
|
||||
public class CompositeFunction<Z extends Number, I, O> extends Function<Stop.CompositeValue<Z, I>, O> {
|
||||
|
||||
private final String property;
|
||||
private O defaultValue;
|
||||
private PropertyValue<O> defaultValue;
|
||||
|
||||
CompositeFunction(@NonNull String property,
|
||||
@NonNull CategoricalStops<Stop.CompositeValue<Z, I>, O> stops) {
|
||||
@@ -51,7 +52,7 @@ public class CompositeFunction<Z extends Number, I, O> extends Function<Stop.Com
|
||||
private CompositeFunction(@Nullable O defaultValue, @NonNull String property,
|
||||
@NonNull Stops<Stop.CompositeValue<Z, I>, O> stops) {
|
||||
super(stops);
|
||||
this.defaultValue = defaultValue;
|
||||
this.defaultValue = new PropertyValue<>(property, defaultValue);
|
||||
this.property = property;
|
||||
}
|
||||
|
||||
@@ -61,7 +62,7 @@ public class CompositeFunction<Z extends Number, I, O> extends Function<Stop.Com
|
||||
* @param defaultValue the default value to use when no other applies
|
||||
* @return this (for chaining)
|
||||
*/
|
||||
public CompositeFunction<Z, I, O> withDefaultValue(O defaultValue) {
|
||||
public CompositeFunction<Z, I, O> withDefaultValue(PropertyValue<O> defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
return this;
|
||||
}
|
||||
@@ -70,7 +71,7 @@ public class CompositeFunction<Z extends Number, I, O> extends Function<Stop.Com
|
||||
* @return the defaultValue
|
||||
*/
|
||||
@Nullable
|
||||
public O getDefaultValue() {
|
||||
public PropertyValue<O> getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@@ -91,7 +92,7 @@ public class CompositeFunction<Z extends Number, I, O> extends Function<Stop.Com
|
||||
Map<String, Object> valueObject = super.toValueObject();
|
||||
valueObject.put(PROPERTY_KEY, property);
|
||||
if (defaultValue != null) {
|
||||
valueObject.put(DEFAULT_VALUE_KEY, defaultValue);
|
||||
valueObject.put(DEFAULT_VALUE_KEY, defaultValue.value);
|
||||
}
|
||||
return valueObject;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.mapbox.mapboxsdk.style.functions.stops.Stops;
|
||||
import com.mapbox.mapboxsdk.style.layers.PropertyValue;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -25,7 +26,7 @@ import java.util.Map;
|
||||
public class SourceFunction<I, O> extends Function<I, O> {
|
||||
|
||||
private final String property;
|
||||
private O defaultValue;
|
||||
private PropertyValue<O> defaultValue;
|
||||
|
||||
SourceFunction(@NonNull String property, @NonNull Stops<I, O> stops) {
|
||||
this(null, property, stops);
|
||||
@@ -37,7 +38,7 @@ public class SourceFunction<I, O> extends Function<I, O> {
|
||||
private SourceFunction(@Nullable O defaultValue, @NonNull String property, @NonNull Stops<I, O> stops) {
|
||||
super(stops);
|
||||
this.property = property;
|
||||
this.defaultValue = defaultValue;
|
||||
this.defaultValue = defaultValue != null ? new PropertyValue<>(property, defaultValue) : null;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +57,7 @@ public class SourceFunction<I, O> extends Function<I, O> {
|
||||
* @param defaultValue the default value to use when no other applies
|
||||
* @return this (for chaining)
|
||||
*/
|
||||
public SourceFunction<I, O> withDefaultValue(O defaultValue) {
|
||||
public SourceFunction<I, O> withDefaultValue(PropertyValue<O> defaultValue) {
|
||||
this.defaultValue = defaultValue;
|
||||
return this;
|
||||
}
|
||||
@@ -65,7 +66,7 @@ public class SourceFunction<I, O> extends Function<I, O> {
|
||||
* @return the defaultValue
|
||||
*/
|
||||
@Nullable
|
||||
public O getDefaultValue() {
|
||||
public PropertyValue<O> getDefaultValue() {
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
@@ -77,7 +78,7 @@ public class SourceFunction<I, O> extends Function<I, O> {
|
||||
Map<String, Object> valueObject = super.toValueObject();
|
||||
valueObject.put(PROPERTY_KEY, property);
|
||||
if (defaultValue != null) {
|
||||
valueObject.put(DEFAULT_VALUE_KEY, defaultValue);
|
||||
valueObject.put(DEFAULT_VALUE_KEY, defaultValue.value);
|
||||
}
|
||||
return valueObject;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import com.mapbox.mapboxsdk.exceptions.ConversionException;
|
||||
import com.mapbox.mapboxsdk.style.functions.Function;
|
||||
import com.mapbox.mapboxsdk.utils.ColorUtils;
|
||||
|
||||
import timber.log.Timber;
|
||||
|
||||
@@ -15,7 +18,14 @@ public class PropertyValue<T> {
|
||||
public final String name;
|
||||
public final T value;
|
||||
|
||||
/* package */ PropertyValue(@NonNull String name, T value) {
|
||||
/**
|
||||
* Not part of the public API.
|
||||
*
|
||||
* @param name the property name
|
||||
* @param value the property value
|
||||
* @see PropertyFactory for construction of {@link PropertyValue}s
|
||||
*/
|
||||
public PropertyValue(@NonNull String name, T value) {
|
||||
this.name = name;
|
||||
this.value = value;
|
||||
}
|
||||
@@ -54,6 +64,22 @@ public class PropertyValue<T> {
|
||||
}
|
||||
}
|
||||
|
||||
@ColorInt
|
||||
@Nullable
|
||||
public Integer getColorInt() {
|
||||
if (!isValue() || !(value instanceof String)) {
|
||||
Timber.e("%s is not a String value and can not be converted to a color it", name);
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
return ColorUtils.rgbaToColor((String) value);
|
||||
} catch (ConversionException ex) {
|
||||
Timber.e("%s could not be converted to a Color int: %s", name, ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s: %s", name, value);
|
||||
|
||||
Reference in New Issue
Block a user