我总是在Android上使用谷歌地图库挣扎。我缩放到位置的代码非常简单:
Location location = locationManager.getLastKnownLocation(locationManager.getBestProvider(criteria, false));
if (location != null)
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 14));
出于某种原因,该位置通常为空,因此它不会缩放它,但我可以看到"蓝点"在地图上。
答案 0 :(得分:0)
"蓝点"在地图上
是MyLocation
标记。您可以通过setMyLocationEnabled()
调用隐藏它:
Location location = locationManager.getLastKnownLocation(locationManager.getBestProvider(criteria, false));
if (location != null) {
// show "blue spot"
googleMap.setMyLocationEnabled(true);
googleMap.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(location.getLatitude(), location.getLongitude()), 14));
} else {
// hide "blue spot"
googleMap.setMyLocationEnabled(false);
}
并且不要忘记许可检查。