0

Google지도에서 서로 가까이있을 때 마커를 표시 할 수 있지만 거리가 멀어지면 & 경도 만 볼 수 있습니다.자동 확대/축소지도 두 개의 다른 좌표를 기반으로 한보기

는 여기에 내가 단지 거리에 따라 줌 레벨을 조정함으로써 달성 될 수있다지도에서 두 좌표를 표시해야 내 코드

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)); 
} 

입니다. 위의 코드를 시도했지만 나를 위해 작동하지 않습니다. 나는 단순히 추가하여 그것을 해결

답변

1

,

LatLngBounds.Builder builder = new LatLngBounds.Builder(); 
    builder.include(google_api_lat_lon); 
    builder.include(current_lat_lon); 
    LatLngBounds bounds = builder.build(); 
    mMap.animateCamera(CameraUpdateFactory.newLatLngBounds(bounds, 10)); 
관련 문제