Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: MapLibre Android SDK 11.5.0 #455

Merged
merged 7 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ PR Title ([#123](link to my pr))
```

## 10.0.0-alpha.19

feat: MapLibre Android SDK 11.5.0 ([#455](https://github.com/maplibre/maplibre-react-native/pull/455))

## 10.0.0-alpha.18

fix: make MarkerView props with defaults optional ([#460](https://github.com/maplibre/maplibre-react-native/pull/460))
Expand Down
8 changes: 4 additions & 4 deletions android/rctmln/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies {
implementation("com.facebook.react:react-android")

// MapLibre SDK
implementation "org.maplibre.gl:android-sdk:11.0.1"
implementation "org.maplibre.gl:android-sdk:11.5.0"
implementation "org.maplibre.gl:android-sdk-turf:6.0.1"

// Dependencies
Expand All @@ -45,9 +45,9 @@ dependencies {


// MapLibre plugins
implementation ("org.maplibre.gl:android-plugin-localization-v9:3.0.0")
implementation ("org.maplibre.gl:android-plugin-annotation-v9:3.0.0")
implementation ("org.maplibre.gl:android-plugin-markerview-v9:3.0.0")
implementation ("org.maplibre.gl:android-plugin-localization-v9:3.0.1")
implementation ("org.maplibre.gl:android-plugin-annotation-v9:3.0.1")
implementation ("org.maplibre.gl:android-plugin-markerview-v9:3.0.1")
}

allprojects {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import com.facebook.react.bridge.WritableMap;
import com.facebook.react.bridge.WritableNativeArray;
import com.facebook.react.bridge.WritableNativeMap;
import com.mapbox.android.gestures.MoveGestureDetector;
import org.maplibre.android.gestures.MoveGestureDetector;
import org.maplibre.geojson.Feature;
import org.maplibre.geojson.FeatureCollection;
import org.maplibre.android.camera.CameraPosition;
Expand Down Expand Up @@ -229,7 +229,7 @@ public void addFeature(View childView, int childPosition) {
feature = (AbstractMapFeature) childView;
} else if (childView instanceof RCTMLNNativeUserLocation) {
feature = (AbstractMapFeature) childView;
} else if (childView instanceof RCTMLNPointAnnotation) {
} else if (childView instanceof RCTMLNPointAnnotation) {
RCTMLNPointAnnotation annotation = (RCTMLNPointAnnotation) childView;
mPointAnnotations.put(annotation.getID(), annotation);
feature = (AbstractMapFeature) childView;
Expand Down Expand Up @@ -350,7 +350,8 @@ public void moveCamera(CameraUpdate cameraUpdate) {
mMap.moveCamera(cameraUpdate);
}

public void easeCamera(CameraUpdate cameraUpdate, int duration, boolean easingInterpolator, MapLibreMap.CancelableCallback callback) {
public void easeCamera(CameraUpdate cameraUpdate, int duration, boolean easingInterpolator,
MapLibreMap.CancelableCallback callback) {
mMap.easeCamera(cameraUpdate, duration, easingInterpolator, callback);
}

Expand Down Expand Up @@ -435,7 +436,6 @@ public boolean isJSONValid(String test) {
return true;
}


@Override
public void onMapReady(final MapLibreMap mapboxMap) {
mMap = mapboxMap;
Expand All @@ -446,7 +446,6 @@ public void onMapReady(final MapLibreMap mapboxMap) {
mMap.setStyle(new Style.Builder().fromUri(mStyleURL));
}


reflow();

mMap.getStyle(new Style.OnStyleLoaded() {
Expand Down Expand Up @@ -501,7 +500,8 @@ public void onMove(MoveGestureDetector detector) {
}

@Override
public void onMoveEnd(MoveGestureDetector detector) {}
public void onMoveEnd(MoveGestureDetector detector) {
}
});
}

Expand Down Expand Up @@ -572,15 +572,15 @@ public void addQueuedFeatures() {
}

private void setupLocalization(Style style) {
mLocalizationPlugin = new LocalizationPlugin(RCTMLNMapView.this, mMap, style);
if (mLocalizeLabels) {
try {
mLocalizationPlugin.matchMapLanguageWithDeviceDefault();
} catch (Exception e) {
final String localeString = Locale.getDefault().toString();
Logger.w(LOG_TAG, String.format("Could not find matching locale for %s", localeString));
}
}
mLocalizationPlugin = new LocalizationPlugin(RCTMLNMapView.this, mMap, style);
if (mLocalizeLabels) {
try {
mLocalizationPlugin.matchMapLanguageWithDeviceDefault();
} catch (Exception e) {
final String localeString = Locale.getDefault().toString();
Logger.w(LOG_TAG, String.format("Could not find matching locale for %s", localeString));
}
}
}

@Override
Expand Down Expand Up @@ -645,8 +645,7 @@ public boolean onMapClick(@NonNull LatLng point) {
source.onPress(new RCTSource.OnPressEvent(
hits.get(source.getID()),
point,
screenPoint
));
screenPoint));
return true;
}
}
Expand Down Expand Up @@ -870,11 +869,11 @@ public void setReactLogoPosition(ReadableMap position) {
mLogoGravity |= Gravity.BOTTOM;
}
float density = getDisplayDensity();
mLogoMargins = new int[]{
position.hasKey("left") ? (int) density * position.getInt("left") : 0,
position.hasKey("top") ? (int) density * position.getInt("top") : 0,
position.hasKey("right") ? (int) density * position.getInt("right") : 0,
position.hasKey("bottom") ? (int) density * position.getInt("bottom") : 0
mLogoMargins = new int[] {
position.hasKey("left") ? (int) density * position.getInt("left") : 0,
position.hasKey("top") ? (int) density * position.getInt("top") : 0,
position.hasKey("right") ? (int) density * position.getInt("right") : 0,
position.hasKey("bottom") ? (int) density * position.getInt("bottom") : 0
};
updateUISettings();
}
Expand Down Expand Up @@ -924,11 +923,11 @@ public void setReactAttributionPosition(ReadableMap position) {
mAttributionGravity |= Gravity.BOTTOM;
}
float density = getDisplayDensity();
mAttributionMargin = new int[]{
position.hasKey("left") ? Math.round(density * position.getInt("left")) : 0,
position.hasKey("top") ? Math.round(density * position.getInt("top")) : 0,
position.hasKey("right") ? Math.round(density * position.getInt("right")) : 0,
position.hasKey("bottom") ? Math.round(density * position.getInt("bottom")) : 0
mAttributionMargin = new int[] {
position.hasKey("left") ? Math.round(density * position.getInt("left")) : 0,
position.hasKey("top") ? Math.round(density * position.getInt("top")) : 0,
position.hasKey("right") ? Math.round(density * position.getInt("right")) : 0,
position.hasKey("bottom") ? Math.round(density * position.getInt("bottom")) : 0
};
updateUISettings();
}
Expand Down Expand Up @@ -1048,7 +1047,8 @@ public void showAttribution() {
manager.onClick(this);
}

public void setSourceVisibility(final boolean visible, @NonNull final String sourceId, @Nullable final String sourceLayerId) {
public void setSourceVisibility(final boolean visible, @NonNull final String sourceId,
@Nullable final String sourceLayerId) {
if (mMap == null) {
return;
}
Expand Down Expand Up @@ -1121,15 +1121,12 @@ private void updateUISettings() {
(uiSettings.getAttributionMarginLeft() != mAttributionMargin[0] ||
uiSettings.getAttributionMarginTop() != mAttributionMargin[1] ||
uiSettings.getAttributionMarginRight() != mAttributionMargin[2] ||
uiSettings.getAttributionMarginBottom() != mAttributionMargin[3]
)
) {
uiSettings.getAttributionMarginBottom() != mAttributionMargin[3])) {
uiSettings.setAttributionMargins(
mAttributionMargin[0],
mAttributionMargin[1],
mAttributionMargin[2],
mAttributionMargin[3]
);
mAttributionMargin[0],
mAttributionMargin[1],
mAttributionMargin[2],
mAttributionMargin[3]);
}

if (mTintColor != null) {
Expand All @@ -1145,18 +1142,15 @@ private void updateUISettings() {
}

if (mLogoMargins != null &&
(uiSettings.getLogoMarginLeft() != mLogoMargins[0] ||
uiSettings.getLogoMarginTop() != mLogoMargins[1] ||
uiSettings.getLogoMarginRight() != mLogoMargins[2] ||
uiSettings.getLogoMarginBottom() != mLogoMargins[3]
)
) {
(uiSettings.getLogoMarginLeft() != mLogoMargins[0] ||
uiSettings.getLogoMarginTop() != mLogoMargins[1] ||
uiSettings.getLogoMarginRight() != mLogoMargins[2] ||
uiSettings.getLogoMarginBottom() != mLogoMargins[3])) {
uiSettings.setLogoMargins(
mLogoMargins[0],
mLogoMargins[1],
mLogoMargins[2],
mLogoMargins[3]
);
mLogoMargins[0],
mLogoMargins[1],
mLogoMargins[2],
mLogoMargins[3]);
}

if (mCompassEnabled != null && uiSettings.isCompassEnabled() != mCompassEnabled) {
Expand Down Expand Up @@ -1220,7 +1214,7 @@ private void updatePreferredFramesPerSecond() {

public double[] getContentInset() {
if (mInsets == null) {
double[] result = {0,0,0,0};
double[] result = { 0, 0, 0, 0 };

return result;
}
Expand All @@ -1245,7 +1239,8 @@ public double[] getContentInset() {

final DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();

double[] result = {left * metrics.scaledDensity, top * metrics.scaledDensity, right * metrics.scaledDensity, bottom * metrics.scaledDensity};
double[] result = { left * metrics.scaledDensity, top * metrics.scaledDensity, right * metrics.scaledDensity,
bottom * metrics.scaledDensity };
return result;
}

Expand Down Expand Up @@ -1288,7 +1283,7 @@ public void onHostDestroy() {

private WritableMap makeRegionPayload(Boolean isAnimated) {
CameraPosition position = mMap.getCameraPosition();
if(position == null || position.target == null) {
if (position == null || position.target == null) {
return new WritableNativeMap();
}
LatLng latLng = new LatLng(position.target.getLatitude(), position.target.getLongitude());
Expand All @@ -1305,8 +1300,9 @@ private WritableMap makeRegionPayload(Boolean isAnimated) {
try {
VisibleRegion visibleRegion = mMap.getProjection().getVisibleRegion();
properties.putArray("visibleBounds", GeoJSONUtils.fromLatLngBounds(visibleRegion.latLngBounds));
} catch(Exception ex) {
Logger.e(LOG_TAG, String.format("An error occurred while attempting to make the region: %s", ex.getMessage()));
} catch (Exception ex) {
Logger.e(LOG_TAG,
String.format("An error occurred while attempting to make the region: %s", ex.getMessage()));
}

return GeoJSONUtils.toPointFeature(latLng, properties);
Expand All @@ -1316,7 +1312,7 @@ public void sendRegionChangeEvent(boolean isAnimated) {
IEvent event = new MapChangeEvent(this, EventTypes.REGION_DID_CHANGE,
makeRegionPayload(new Boolean(isAnimated)));

mManager.handleEvent(event);
mManager.handleEvent(event);
mCameraChangeTracker.setReason(CameraChangeTracker.EMPTY);
}

Expand Down Expand Up @@ -1471,25 +1467,27 @@ private WritableMap makeLocationChangePayload(Location location) {
}

/**
* Adds the marker image to the map for use as a SymbolLayer icon
*/
* Adds the marker image to the map for use as a SymbolLayer icon
*/
private void setUpImage(@NonNull Style loadedStyle) {
loadedStyle.addImage("MARKER_IMAGE_ID", BitmapFactory.decodeResource(
this.getResources(), R.drawable.red_marker)
);
this.getResources(), R.drawable.red_marker));
}

/**
* PointAnnotations are rendered to a canvas, but react native Image component is
* implemented on top of Fresco, and fresco will not load images when their view is
* not attached to the window. So we'll have an offscreen view where we add those views
* PointAnnotations are rendered to a canvas, but react native Image component
* is
* implemented on top of Fresco, and fresco will not load images when their view
* is
* not attached to the window. So we'll have an offscreen view where we add
* those views
* so they can rendered full to canvas.
*/
public ViewGroup offscreenAnnotationViewContainer() {
if (mOffscreenAnnotationViewContainer == null) {
mOffscreenAnnotationViewContainer = new FrameLayout(getContext());
FrameLayout.LayoutParams flParams = new FrameLayout.LayoutParams(0,0);
flParams.setMargins(-10000, -10000, -10000,-10000);
FrameLayout.LayoutParams flParams = new FrameLayout.LayoutParams(0, 0);
flParams.setMargins(-10000, -10000, -10000, -10000);
mOffscreenAnnotationViewContainer.setLayoutParams(flParams);
addView(mOffscreenAnnotationViewContainer);
}
Expand Down Expand Up @@ -1518,10 +1516,12 @@ public LocationComponentManager getLocationComponentManager() {
}

public void setTintColor(@Nullable Integer tintColor) {
if (mTintColor == tintColor) return;
if (mTintColor == tintColor)
return;
mTintColor = tintColor;
updateUISettings();
if (mLocationComponentManager == null) return;
if (mLocationComponentManager == null)
return;
mLocationComponentManager.update(getMapboxMap().getStyle());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,9 @@ public void onAllImagesLoaded() {
case "fillExtrusionBaseTransition":
RCTMLNStyleFactory.setFillExtrusionBaseTransition(layer, styleValue);
break;
case "fillExtrusionVerticalGradient":
RCTMLNStyleFactory.setFillExtrusionVerticalGradient(layer, styleValue);
break;
}
}
}
Expand Down Expand Up @@ -1207,7 +1210,7 @@ public static void setIconPadding(SymbolLayer layer, RCTMLNStyleValue styleValue
if (styleValue.isExpression()) {
layer.setProperties(PropertyFactory.iconPadding(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.iconPadding(styleValue.getFloat(VALUE_KEY)));
layer.setProperties(PropertyFactory.iconPadding(styleValue.getFloatArray(VALUE_KEY)));
}
}

Expand Down Expand Up @@ -1975,6 +1978,14 @@ public static void setFillExtrusionBaseTransition(FillExtrusionLayer layer, RCTM
}
}

public static void setFillExtrusionVerticalGradient(FillExtrusionLayer layer, RCTMLNStyleValue styleValue) {
if (styleValue.isExpression()) {
layer.setProperties(PropertyFactory.fillExtrusionVerticalGradient(styleValue.getExpression()));
} else {
layer.setProperties(PropertyFactory.fillExtrusionVerticalGradient(styleValue.getBoolean(VALUE_KEY)));
}
}

public static void setVisibility(RasterLayer layer, RCTMLNStyleValue styleValue) {
layer.setProperties(PropertyFactory.visibility(styleValue.getString(VALUE_KEY)));
}
Expand Down
19 changes: 19 additions & 0 deletions docs/FillExtrusionLayer.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
* <a href="#name-5">fillExtrusionPattern</a><br/>
* <a href="#name-6">fillExtrusionHeight</a><br/>
* <a href="#name-7">fillExtrusionBase</a><br/>
* <a href="#name-8">fillExtrusionVerticalGradient</a><br/>

___

Expand Down Expand Up @@ -317,3 +318,21 @@ The transition affecting any changes to this layer’s fillExtrusionBase propery
`{duration: 300, delay: 0}`


___

#### Name
`fillExtrusionVerticalGradient`

#### Description
Whether to apply a vertical gradient to the sides of a fillExtrusion layer. If true, sides will be shaded slightly darker farther down.

#### Type
`boolean`
#### Default Value
`true`


#### Expression

Parameters: `zoom`

2 changes: 1 addition & 1 deletion docs/RasterLayer.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ ___
`rasterFadeDuration`

#### Description
Fade duration when a new tile is added.
Fade duration when a new tile is added, or when a video is started or its coordinates are updated.

#### Type
`number`
Expand Down
Loading