缩放地图 获取用户选择的位置并将其传递给 activity

Zoom map Get location chosen by User and pass it to activity

我有这段代码,它允许用户 select 一个位置 (mechanic_location) 并将其传递给另一个 activity(mechanic_login)。问题是,它不会缩放。帮助我启用它以缩放到用户所在的当前位置,但让用户能够选择与 he/she 所在位置不同的另一个位置。选择位置后,单击按钮发送纬度和视图的经度 (mechanic_login)。这是我的代码

public class mechanic_location extends FragmentActivity implements OnMapReadyCallback {

    private GoogleMap mMap;
    Button mSendLocationBtn;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mechanic_location);
        // Obtain the SupportMapFragment and get notified when the map is ready to be used.
        SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
                .findFragmentById(R.id.map);
        mapFragment.getMapAsync(this);


    }
    @Override
    public void onMapReady(GoogleMap googleMap) {
        mMap = googleMap;
        mMap.setOnMapClickListener(new GoogleMap.OnMapClickListener() {
            @Override
            public void onMapClick(LatLng latLng) {

                Intent returnIntent = new Intent();
                returnIntent.putExtra("picked_point",latLng);
                setResult(Activity.RESULT_OK,returnIntent);
                finish();
            }
        });
      }
    }

您可以使用 moveCamera() 方法并定义缩放级别

float zoomLevel = 16.0f; //This goes up to 21
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, zoomLevel));

关于google地图的更多使用信息,可以查看here