Skip to content
This repository was archived by the owner on Oct 7, 2024. It is now read-only.

Commit fd576d2

Browse files
author
Langston Smith
authored
Making needed iconTranslate -> iconOffset refactoring changes (#1084)
1 parent fba1aee commit fd576d2

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/dds/ImageClusteringActivity.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
import static com.mapbox.mapboxsdk.style.expressions.Expression.toNumber;
3535
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
3636
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconSize;
37-
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTranslate;
3837
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textAllowOverlap;
3938
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textColor;
4039
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textField;
4140
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textIgnorePlacement;
41+
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textOffset;
4242
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.textSize;
4343

4444
/**
@@ -119,8 +119,7 @@ private void addClusteredGeoJsonSource(@NonNull Style loadedMapStyle) {
119119
SymbolLayer symbolLayer = new SymbolLayer("cluster-" + i, "earthquakes");
120120

121121
symbolLayer.setProperties(
122-
iconImage("quake-triangle-icon-id"),
123-
iconTranslate(new Float[] {0f, -9f})
122+
iconImage("quake-triangle-icon-id")
124123
);
125124
Expression pointCount = toNumber(get("point_count"));
126125

@@ -143,6 +142,9 @@ private void addClusteredGeoJsonSource(@NonNull Style loadedMapStyle) {
143142
textSize(12f),
144143
textColor(Color.BLACK),
145144
textIgnorePlacement(true),
145+
// The .5f offset moves the data numbers down a little bit so that they're
146+
// in the middle of the triangle cluster image
147+
textOffset(new Float[] {0f, .5f}),
146148
textAllowOverlap(true)
147149
));
148150
}

MapboxAndroidDemo/src/main/java/com/mapbox/mapboxandroiddemo/examples/labs/ValueAnimatorIconAnimationActivity.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconIgnorePlacement;
3030
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
3131
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconOffset;
32-
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconTranslate;
3332

3433
/**
3534
* Combine SymbolLayer icons with the Android system's ValueAnimator and interpolator
@@ -140,7 +139,7 @@ private void initAnimation(TimeInterpolator desiredTimeInterpolator) {
140139
if (animator != null) {
141140
animator.cancel();
142141
}
143-
animator = ValueAnimator.ofFloat(STARTING_DROP_HEIGHT, 0);
142+
animator = ValueAnimator.ofFloat(STARTING_DROP_HEIGHT, -17);
144143
animator.setDuration(DROP_SPEED_MILLISECONDS);
145144
animator.setInterpolator(desiredTimeInterpolator);
146145
animator.setStartDelay(1000);
@@ -152,7 +151,7 @@ public void onAnimationUpdate(ValueAnimator valueAnimator) {
152151
initSymbolLayer();
153152
animationHasStarted = true;
154153
}
155-
pinSymbolLayer.setProperties(iconTranslate(new Float[] {0f, (Float) valueAnimator.getAnimatedValue()}));
154+
pinSymbolLayer.setProperties(iconOffset(new Float[] {0f, (Float) valueAnimator.getAnimatedValue()}));
156155
}
157156
});
158157
}

0 commit comments

Comments
 (0)