자습서를 통해 작업 중이며 내 앱은 기본적으로 하나의 세부 정보 만 제외하고 작동합니다. 지도를 위성보기로 표시하고 특정 장소로 확대하는 등의 작업을 시연하는 옵션 메뉴가 있습니다.Android 용 Google지도 setMyLocationEnabled (true)
이 자습서에는 확대/축소를 위해 표시된 순서대로 효과적으로 사용해야하는 아래의 두 가지 메뉴 옵션이 있습니다 내가 현재있는 곳으로가는지도. 두 번째 메뉴 항목 (동일한 현재 기능 표시)에 동일한 기능을 추가하여 첫 번째 항목을 중복 (getcurrentlocation)하고 싶었지만 이로 인해 응용 프로그램이 중단되었습니다.
아무에게도 왜 아이디어를 어떻게 극복 할 수 있습니까? 감사합니다. 당신의 GoogleMap
부하가 null이됩니다 Location
이물이 약간의 시간이 소요 때 처음
코드는 처음
case R.id.menu_getcurrentlocation:
// ---get your current location and display a blue dot---
map.setMyLocationEnabled(true);
break;
case R.id.menu_showcurrentlocation:
// Adding the next line breaks the app.
// map.setMyLocationEnabled(true);
Location myLocation = map.getMyLocation();
LatLng myLatLng = new LatLng(myLocation.getLatitude(),myLocation.getLongitude());
CameraPosition myPosition = new CameraPosition.Builder().target(myLatLng).zoom(17).bearing(90).tilt(30).build();
map.animateCamera(CameraUpdateFactory.newCameraPosition(myPosition));
break;
귀하의 logcat을 보여주십시오. – Piyush
그래, 내 LogCat을 내 게시물에 추가하는 데 어려움을 겪었으나 작동하는 해결 방법이 있지만 내 Q를 해결하지 못하는 이유는 무엇입니까? map.setMyLocationEnabled (true); 메뉴 옵션 내에서 작동하지 않습니다. 제 해결 방법은 map.setMyLocationEnabled (true); getSupportFragmentManager에 대한 호출을 한 직후입니다. –
메뉴 클릭 이벤트가 작동하지 않는다는 의미입니까? null 포인터 예외가 발생합니까? – Piyush