Skip to content
Open
Show file tree
Hide file tree
Changes from 10 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
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ void setEnabled(boolean enabled) {
isEnabled = enabled;
}

private boolean isLocationTracking() {
boolean isLocationTracking() {
return cameraMode == CameraMode.TRACKING
|| cameraMode == CameraMode.TRACKING_COMPASS
|| cameraMode == CameraMode.TRACKING_GPS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,10 @@ private void updateAnimatorListenerHolders() {
locationAnimatorCoordinator.resetAllLayerAnimations();
}

public boolean isLocationTracking() {
return locationCameraController.isLocationTracking();
}

@NonNull
private OnCameraMoveListener onCameraMoveListener = new OnCameraMoveListener() {
@Override
Expand Down Expand Up @@ -1546,7 +1550,7 @@ public void onRenderModeChanged(int currentMode) {
new MapLibreMap.OnDeveloperAnimationListener() {
@Override
public void onDeveloperAnimationStarted() {
if (isComponentInitialized && isEnabled) {
if (isComponentInitialized && isEnabled && !options.concurrentCameraAnimationsEnabled()) {
setCameraMode(CameraMode.NONE);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ public class LocationComponentOptions implements Parcelable {
private float pulseAlpha;
@Nullable
private Interpolator pulseInterpolator;
private Boolean concurrentCameraAnimationsEnabled;

public LocationComponentOptions(
float accuracyAlpha,
Expand Down Expand Up @@ -186,7 +187,8 @@ public LocationComponentOptions(
float pulseSingleDuration,
float pulseMaxRadius,
float pulseAlpha,
@Nullable Interpolator pulseInterpolator) {
@Nullable Interpolator pulseInterpolator,
Boolean concurrentCameraAnimationsEnabled) {
this.accuracyAlpha = accuracyAlpha;
this.accuracyColor = accuracyColor;
this.backgroundDrawableStale = backgroundDrawableStale;
Expand Down Expand Up @@ -231,6 +233,7 @@ public LocationComponentOptions(
this.pulseMaxRadius = pulseMaxRadius;
this.pulseAlpha = pulseAlpha;
this.pulseInterpolator = pulseInterpolator;
this.concurrentCameraAnimationsEnabled = concurrentCameraAnimationsEnabled;
}

/**
Expand Down Expand Up @@ -373,6 +376,10 @@ public static LocationComponentOptions createFromAttributes(@NonNull Context con
builder.pulseAlpha = typedArray.getFloat(
R.styleable.maplibre_LocationComponent_maplibre_pulsingLocationCircleAlpha, CIRCLE_PULSING_ALPHA_DEFAULT);

builder.concurrentCameraAnimationsEnabled = typedArray.getBoolean(
R.styleable.maplibre_LocationComponent_maplibre_concurrentCameraAnimationsEnabled, false
);

typedArray.recycle();

return builder.build();
Expand Down Expand Up @@ -892,6 +899,15 @@ public Interpolator pulseInterpolator() {
return pulseInterpolator;
}

/**
* Enable or disable concurrent camera animations during navigation
*
* @return whether concurrent camera animations are enabled or disabled during navigation
*/
public Boolean concurrentCameraAnimationsEnabled() {
return concurrentCameraAnimationsEnabled;
}

@NonNull
@Override
public String toString() {
Expand Down Expand Up @@ -934,6 +950,7 @@ public String toString() {
+ "pulseSingleDuration=" + pulseSingleDuration
+ "pulseMaxRadius=" + pulseMaxRadius
+ "pulseAlpha=" + pulseAlpha
+ "concurrentCameraAnimationsEnabled=" + concurrentCameraAnimationsEnabled
+ "}";
}

Expand Down Expand Up @@ -1081,6 +1098,10 @@ public boolean equals(Object o) {
return false;
}

if (concurrentCameraAnimationsEnabled != options.concurrentCameraAnimationsEnabled) {
return false;
}

return layerBelow != null ? layerBelow.equals(options.layerBelow) : options.layerBelow == null;
}

Expand Down Expand Up @@ -1130,6 +1151,7 @@ public int hashCode() {
result = 31 * result + (pulseSingleDuration != +0.0f ? Float.floatToIntBits(pulseSingleDuration) : 0);
result = 31 * result + (pulseMaxRadius != +0.0f ? Float.floatToIntBits(pulseMaxRadius) : 0);
result = 31 * result + (pulseAlpha != +0.0f ? Float.floatToIntBits(pulseAlpha) : 0);
result = 31 * result + (concurrentCameraAnimationsEnabled ? 1 : 0);
return result;
}

Expand Down Expand Up @@ -1180,6 +1202,7 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeFloat(this.pulseSingleDuration);
dest.writeFloat(this.pulseMaxRadius);
dest.writeFloat(this.pulseAlpha);
dest.writeByte(this.concurrentCameraAnimationsEnabled ? (byte) 1 : (byte) 0);
}

protected LocationComponentOptions(Parcel in) {
Expand Down Expand Up @@ -1223,6 +1246,7 @@ protected LocationComponentOptions(Parcel in) {
this.pulseSingleDuration = in.readFloat();
this.pulseMaxRadius = in.readFloat();
this.pulseAlpha = in.readFloat();
this.concurrentCameraAnimationsEnabled = in.readByte() != 0;
}

public static final Parcelable.Creator<LocationComponentOptions> CREATOR =
Expand Down Expand Up @@ -1349,6 +1373,7 @@ public LocationComponentOptions build() {
private float pulseAlpha;
@Nullable
private Interpolator pulseInterpolator;
private Boolean concurrentCameraAnimationsEnabled;

Builder() {
}
Expand Down Expand Up @@ -1395,6 +1420,7 @@ private Builder(LocationComponentOptions source) {
this.pulseMaxRadius = source.pulseMaxRadius;
this.pulseAlpha = source.pulseAlpha;
this.pulseInterpolator = source.pulseInterpolator;
this.concurrentCameraAnimationsEnabled = source.concurrentCameraAnimationsEnabled;
}

/**
Expand Down Expand Up @@ -1973,6 +1999,17 @@ public LocationComponentOptions.Builder pulseInterpolator(Interpolator pulseInte
return this;
}

/**
* Enable or disable the concurrent camera animations during navigation feature
*
* @return whether concurrent camera animations are enabled or disabled
*/
public LocationComponentOptions.Builder concurrentCameraAnimationsEnabled(
Boolean concurrentCameraAnimationsEnabled) {
this.concurrentCameraAnimationsEnabled = concurrentCameraAnimationsEnabled;
return this;
}

@Nullable
LocationComponentOptions autoBuild() {
String missing = "";
Expand Down Expand Up @@ -2074,7 +2111,8 @@ LocationComponentOptions autoBuild() {
this.pulseSingleDuration,
this.pulseMaxRadius,
this.pulseAlpha,
this.pulseInterpolator);
this.pulseInterpolator,
this.concurrentCameraAnimationsEnabled);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ boolean onKeyUp(int keyCode, KeyEvent event) {
PointF focalPoint = new PointF(uiSettings.getWidth() / 2, uiSettings.getHeight() / 2);
mapGestureDetector.zoomInAnimated(focalPoint, true);
return true;
case KeyEvent.KEYCODE_DEL:
if (!uiSettings.isZoomGesturesEnabled()) {
return false;
}

// Zoom out
focalPoint = new PointF(uiSettings.getWidth() / 2, uiSettings.getHeight() / 2);
mapGestureDetector.zoomOutAnimated(focalPoint, true);
}

// We are not interested in this key
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,13 @@ CameraPosition invalidateCameraPosition() {
}

void cancelTransitions() {
MapLibreMap map = mapView.getMapLibreMap();
if (map != null && map.getLocationComponent().isLocationComponentActivated()
&& map.getLocationComponent().getLocationComponentOptions().concurrentCameraAnimationsEnabled()
&& map.getLocationComponent().isLocationTracking()) {
return;
}

// notify user about cancel
cameraChangeDispatcher.onCameraMoveCanceled();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,7 @@
<public name="maplibre_pulsingLocationCircleAlpha" format="float" type="attr" />
<public name="maplibre_pulsingLocationCircleInterpolator" format="string" type="attr" />

<!-- Camera Animations -->
<public name="maplibre_concurrentCameraAnimationsEnabled" format="boolean" type="attr" />

</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,8 @@
<attr name="maplibre_pulsingLocationCircleAlpha" format="float" />
<attr name="maplibre_pulsingLocationCircleInterpolator" format="string" />

<!-- Concurrent Camera Animations -->
<attr name="maplibre_concurrentCameraAnimationsEnabled" format="boolean" />

</declare-styleable>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,7 @@
<item name="maplibre_pulsingLocationCircleAlpha">0.4</item>
<item name="maplibre_pulsingLocationCircleInterpolator">decelerate</item>

<!-- Concurrent Camera Animations -->
<item name="maplibre_concurrentCameraAnimationsEnabled">false</item>
</style>
</resources>
6 changes: 6 additions & 0 deletions platform/ios/src/MLNMapView.h
Original file line number Diff line number Diff line change
Expand Up @@ -574,6 +574,12 @@ MLN_EXPORT
*/
@property (nonatomic, readonly, nullable) MLNUserLocation *userLocation;

/**
* A Boolean value indicating whether independent camera animations
* can be applied at the same time or not.
*/
@property (nonatomic, assign) BOOL enableConcurrentCameraAnimation;

/**
The mode used to track the user location. The default value is
``MLNUserTrackingMode/MLNUserTrackingModeNone``.
Expand Down
3 changes: 2 additions & 1 deletion platform/ios/src/MLNMapView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -3966,6 +3966,7 @@ - (void)setZoomLevel:(double)zoomLevel animated:(BOOL)animated
{
MLNLogDebug(@"Setting zoomLevel: %f animated: %@", zoomLevel, MLNStringFromBOOL(animated));
if (zoomLevel == self.zoomLevel) return;

[self cancelTransitions];

self.cameraChangeReasonBitmask |= MLNCameraChangeReasonProgrammatic;
Expand Down Expand Up @@ -4446,7 +4447,7 @@ - (void)_flyToCamera:(MLNMapCamera *)camera edgePadding:(UIEdgeInsets)insets wit
}

- (void)cancelTransitions {
if (!_mbglMap)
if (!_mbglMap || (self.enableConcurrentCameraAnimation && self.userTrackingMode != MLNUserTrackingModeNone && self.userTrackingMode != MLNUserTrackingModeFollow))
{
return;
}
Expand Down
6 changes: 6 additions & 0 deletions render-test/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ document.getElementById('toggle-ignored').addEventListener('click', function (e)
row.classList.toggle('hide');
}
});
document.getElementById('toggle-ignored-failed').addEventListener('click', function (e) {
for (const row of document.querySelectorAll('.test.ignored, .test.failed')) {
row.classList.toggle('hide');
}
});
document.getElementById('toggle-sequence').addEventListener('click', function (e) {
document.getElementById('test-sequence').classList.toggle('hide');
});
Expand All @@ -100,6 +105,7 @@ const char* resultsHeaderButtons = R"HTML(
<button id='toggle-sequence'>Toggle test sequence</button>
<button id='toggle-passed'>Toggle passed tests</button>
<button id='toggle-ignored'>Toggle ignored tests</button>
<button id='toggle-ignored-failed'>Toggle failed ignored testes</button>
</h1>
)HTML";

Expand Down
Loading