Android 在地图上移动标记
我有一个坐标列表,我想在多段线上移动我的标记。我已经创建了多段线,我也可以移动标记,但它并不平滑。它只是从一个坐标移动到另一个坐标 我使用的代码是我在网上找到的Android 在地图上移动标记,android,google-maps,android-layout,google-maps-markers,Android,Google Maps,Android Layout,Google Maps Markers,我有一个坐标列表,我想在多段线上移动我的标记。我已经创建了多段线,我也可以移动标记,但它并不平滑。它只是从一个坐标移动到另一个坐标 我使用的代码是我在网上找到的 public void setAnimation(GoogleMap myMap, final List<LatLng> directionPoint, final Bitmap bitmap) { Marker marker = myMap.addMarker(new MarkerOptions()
public void setAnimation(GoogleMap myMap, final List<LatLng> directionPoint, final Bitmap bitmap) {
Marker marker = myMap.addMarker(new MarkerOptions()
.icon(BitmapDescriptorFactory.fromBitmap(bitmap))
.position(directionPoint.get(0))
.title(Speed.get(0))
.flat(true));
System.out.println("SIZZEE: " + Speed.size() + ", " + directionPoint.size());
marker.showInfoWindow();
animateMarker(myMap, marker, directionPoint, true);
}
private void animateMarker(final GoogleMap myMap, final Marker marker, final List<LatLng> directionPoint,
final boolean hideMarker) {
final Handler handler = new Handler();
final long start = SystemClock.uptimeMillis();
Projection proj = myMap.getProjection();
final long duration = 30000;
final Interpolator interpolator = new LinearInterpolator();
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()) {
marker.setPosition(directionPoint.get(i));
marker.setTitle(Speed.get(i) + "Km/h");
marker.showInfoWindow();
myMap.moveCamera(CameraUpdateFactory.newLatLngZoom(directionPoint.get(i) , 17.0f));
}
i++;
if (t < 1.0) {
// Post again 16ms later.
handler.postDelayed(this, 500);
} else {
if (hideMarker) {
marker.setVisible(false);
} else {
marker.setVisible(true);
}
}
}
});
}
public void setAnimation(谷歌地图myMap,最终列表方向点,最终位图){
Marker Marker=myMap.addMarker(新MarkerOptions()
.icon(BitmapDescriptorFactory.fromBitmap(位图))
.位置(方向点.get(0))
.title(速度获取(0))
.平坦(真实));
System.out.println(“SIZZEE:+Speed.size()+”,“+directionPoint.size());
marker.showInfoWindow();
animateMarker(myMap、marker、directionPoint、true);
}
私有void animateMarker(最终GoogleMap myMap、最终标记标记、最终列表方向点、,
最终布尔hideMarker){
最终处理程序=新处理程序();
最终长启动=SystemClock.uptimeMillis();
Projection proj=myMap.getProjection();
最终长持续时间=30000;
最终插值器插值器=新的线性插值器();
handler.post(新的Runnable(){
int i=0;
@凌驾
公开募捐{
长时间运行=SystemClock.uptimeMillis()-开始;
float t=interpolator.getInterpolation((float)经过
/持续时间);
if(i
我该怎么做才能使标记移动得非常平稳?你找到解决方案了吗?@gaurang nope,没有!你找到解决办法了吗?@gaurang不,找不到!