0
我可以在谷歌地圖上顯示標記時,他們彼此接近,但當距離很遠時,我只能看到一個緯度。基於兩種不同座標的自動縮放mapView
這裏是我的代碼
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
LatLng google_api_lat_lon = new LatLng(lat, lon);
float zoomLevel = 16.0f;
Marker markerAPILocation = mMap.addMarker(new MarkerOptions().position(google_api_lat_lon).title(title).icon(BitmapDescriptorFactory.fromResource(R.drawable.saved_locaitons)));
markerAPILocation.showInfoWindow();
mMap.setMyLocationEnabled(true);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(google_api_lat_lon, zoomLevel));
if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return;
}
// mMap.setMyLocationEnabled(true);
mMap.getUiSettings().setMapToolbarEnabled(false);
mMap.getUiSettings().setZoomControlsEnabled(true);
mMap.getUiSettings().setScrollGesturesEnabled(false);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(google_api_lat_lon, zoomLevel));
}
我需要顯示在映射表座標,只能通過調整基礎上的距離縮放級別來實現。我試過上面的代碼,但它不適合我。