gpt4 book ai didi

android - android 中的谷歌地图 v2 中的多色折线

转载 作者:搜寻专家 更新时间:2023-11-01 09:39:17 24 4
gpt4 key购买 nike

我搜索了很多我没有找到任何合适的解决方案。帮助和链接不胜感激:-) multicolored polyine

最佳答案

也许太晚了!!!但我解决了这个问题,想把它给一些人。也许有用。对于细节,我通过 map 中每 5 个 Latlng 的新 polylineOption 解决它

 private static void animateMarker(final GoogleMap map, final Marker marker, final List<LatLng> directionPoint,
final boolean hideMarker, final List<Float> degree, final List<Integer> colors) {
final Handler handler = new Handler();
final long start = SystemClock.uptimeMillis();
final long duration = 300000;
final PolylineOptions[] polylineOptions = {new PolylineOptions()};
final Interpolator interpolator = new LinearInterpolator();
if (map != null) {
handler.post(new Runnable() {
int i = 0;

@Override
public void run() {
long elapsed = SystemClock.uptimeMillis() - start;
float t = interpolator.getInterpolation((float) elapsed / duration);

if (i < directionPoint.size() - 1) {

final LatLng currentPosition = new LatLng(
directionPoint.get(i).latitude * (1 - t) + directionPoint.get(i + 1).latitude * t,
directionPoint.get(i).longitude * (1 - t) + directionPoint.get(i + 1).longitude * t);

marker.setRotation(degree.get(i));
marker.setPosition(currentPosition);
polylineOptions[0].add(directionPoint.get(i)).color(colors.get(i));
map.addPolyline(polylineOptions[0]);
if (i % 5 != 0) {
polylineOptions[0] = new PolylineOptions();
polylineOptions[0].add(directionPoint.get(i)).color(colors.get(i));
map.addPolyline(polylineOptions[0]);
}
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLng(currentPosition);
map.animateCamera(cameraUpdate);
i++;

}
if (t < 1.0) {
// Post again 100ms later.
handler.postDelayed(this, 100);
} else {
if (hideMarker) {
marker.setVisible(false);
} else {
marker.setVisible(true);
}
}
}
});

}
}

enter image description here

enter image description here

好的,这是我的截图,颜色会随着车速的变化而变化

关于android - android 中的谷歌地图 v2 中的多色折线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40880472/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com