问题
When I plot my polyline on Map from point A -> B, I have a requirement to draw the polyline with animation. As if from A-> B the polyline keeps on drawing.
I have used below link for reference:
https://github.com/amalChandran/google-maps-route-animation
Using the solution I am able to animate the polyline, but the polyline itself is not proper. It doesn't go through road. Original APK of the solution also has the same bug.
Can someone pls help me with a suitable solution
回答1:
You can try with this reference also https://github.com/mohak1712/UberUX?utm_source=android-arsenal.com&utm_medium=referral&utm_campaign=6129
ValueAnimator - For animating overlays and polylines
ValueAnimator tAnimator = ValueAnimator.ofFloat(0, 1);
tAnimator.setRepeatCount(ValueAnimator.INFINITE);
tAnimator.setRepeatMode(ValueAnimator.RESTART);
tAnimator.setInterpolator(new LinearInterpolator());
tAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
public void onAnimationUpdate(ValueAnimator valueAnimator) {
// animate here
}
});
PolyLines - For drawing lines on map
PolylineOptions greyOptions = new PolylineOptions();
greyOptions.width(10);
greyOptions.color(Color.GRAY);
greyOptions.startCap(new SquareCap());
greyOptions.endCap(new SquareCap());
greyOptions.jointType(ROUND);
greyPolyLine = mMap.addPolyline(greyOptions);
回答2:
You can also draw routes without polylines. Using google maps projection APIs you can draw it over an overlay layer. Check the repo for an example.
来源:https://stackoverflow.com/questions/43292753/android-map-how-to-animate-polyline-on-map