2016-11-22 3 views
1

마커로 표시된 위치로 Google지도를 확대하고 그 후에 마커를 오른쪽으로 픽셀로 스크롤 현재 위의 두 가지 작업을 결합합니다. 이 : 당신이 볼 수 있듯이확대/축소 위치로 매핑하여 오른쪽으로 이동

LatLng point = new LatLng(lat,lon); 

MarkerOptions endMarker = new MarkerOptions().position(point); 

googleMap.addMarker(endMarker); 

googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(point, 15f)); 

int screenWidth = getScreenWidth(); 

int margin = (int) getResources().getDimension(R.dimen.double_standard_margin_padding); 

new Handler().postDelayed(() -> googleMap.animateCamera(CameraUpdateFactory.scrollBy(-(screenWidth - margin) * 3/8, 0), new GoogleMap.CancelableCallback() { 
        @Override 
        public void onFinish() { 

        } 

        @Override 
        public void onCancel() { 

        } 
       }), 1000); 

, 나는 그것을 할 수있는이 방법 추가 한 :

googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(point, 15f)); 

googleMap.animateCamera(CameraUpdateFactory.scrollBy(-(screenWidth - margin) * 3/8, 0) 

을 그리고 나는 우리가 모르기 때문에지도를 이동하는 작업을 지연해야 할 때지도 확대되었습니다

지도가 (onCancel()) 이동할 수 없으므로 예상 UI를받을 수없는 경우가 있습니다.

누군가가 한 방향으로 만 보관하는 방법을 알고 있습니까?

답변

1

나는 여러 번 동일한 문제에 직면했으며 주어진 지연 (필요한 경우)을 사용하여 CameraUpdates의 체인을 실행하고 카메라를 이동하거나 애니메이션으로 지정할 수 있도록했습니다 (my project on GitHub 참조). 나는 그것이 귀하의 경우에 유용 할 수 있다고 생각합니다 :

CameraUpdateAnimator animator = new CameraUpdateAnimator(mMap, this); // Parameters: a GoogleMap instance and an OnCameraIdleListener to return the control to (can be null) 
animator.add(CameraUpdateFactory.newLatLngZoom(point, 15f), false, 0); // Move the camera without delay 
animator.add(CameraUpdateFactory.scrollBy(-(screenWidth - margin) * 3/8, 0), true, 1000); // Animate the camera with a 1000 milliseconds delay 
animator.execute();