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

三世轮回 提交于 2019-12-12 02:52:59

问题


  • 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

回答1:


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

}


来源:https://stackoverflow.com/questions/36007164/set-camera-focus-on-particular-marker-on-google-map-on-listview-item-click

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!