Home > Software design >  How to zoom into a location in google map in kotlin?
How to zoom into a location in google map in kotlin?

Time:09-28

This's on map ready function. I want to zoom into that location. but using this only can get marker not zoom.

override fun onMapReady(googleMap: GoogleMap?) {
        mMap = googleMap!!

        val sydney = LatLng(-34.0, 151.0)
        mMap.addMarker(MarkerOptions().position(sydney).title("Sydney"))
        mMap.moveCamera(CameraUpdateFactory.newLatLng(sydney))
    }

CodePudding user response:

Try this to zoom onto the user location

> private void showArea(LatLng latLng) {
>     CameraPosition cameraPosition = new CameraPosition.Builder().target(latLng).zoom(AppConstant.MAP_DEFAULT_ZOOM).build();
>     mGoogleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
> }
  • Related