【发布时间】:2015-05-07 18:35:05
【问题描述】:
我开发了一个 android 应用程序,它可以每秒获取用户的当前位置。但是在每秒更新位置时,每次更新时它都会放大 2 倍,所以请帮助我设置恒定的缩放级别,在每秒更新后不会缩放,我在 onCreate 中使用了这个监听器
map.setOnMyLocationChangeListener(myLocationChangeListener);
private GoogleMap.OnMyLocationChangeListener myLocationChangeListener = new GoogleMap.OnMyLocationChangeListener() {
@Override
public void onMyLocationChange (Location location) {
LatLng loc = new LatLng (location.getLatitude(), location.getLongitude());
Bitmap bitmapicon = BitmapFactory.decodeResource(context.getResources(),
R.drawable.ic_launcher);
map.addMarker(new MarkerOptions().position(new LatLng(location.getLatitude(), location.getLongitude()))
.title("My Location").icon(BitmapDescriptorFactory.fromBitmap(bitmapicon)));
map.animateCamera(CameraUpdateFactory.newLatLngZoom(loc, 5.0f));
}
};
【问题讨论】:
-
这可能与它有关:CameraUpdateFactory.newLatLngZoom(loc, 5.0f)
-
我已经包含了这段代码 CameraUpdateFactory.newLatLngZoom(loc, 5.0f) 但它不起作用,如果您有任何其他想法,请告诉我
-
那部分是我认为的问题,而不是你应该添加它。因为你里面有 Zoom,试着把它设置为 CameraUpdateFactory.newLatLngZoom(loc, 0.0f)
标签: android