简体   繁体   中英

Set Camera focus on particular marker on google map on listview item click

  • What i want :
    • I want to set focus on marker that is already placed in google map.
    • When i click on list view item , focus of camera should be transfer to that poistion marker on map

Try this,

GoogleMap map = ((MapFragment)     getFragmentManager().findFragmentById(R.id.map)).getMap();

//Pass the latitude and Longitude to method

setMap(Dlat, Dlng);

private void setMap(double dlat, double dlng) {

    LatLng location = new LatLng(dlat, dlng);
    CameraPosition INIT = new CameraPosition.Builder().target(location).zoom(15.5F).bearing(300F) // orientation
            .tilt(50F) // viewing angle
            .build();

    // use map to move camera into position
    map.moveCamera(CameraUpdateFactory.newCameraPosition(INIT));

    // create initial marker
    markerOptions = new MarkerOptions().position(location);
    map.addMarker(markerOptions);

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM