마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

v2 에서 제 위치를 중심으로 움직이게 어떻게하나요?

0 추천

제목 그대로인데요~

제 위치를 게속 받아오며 중앙에 표시하면서 제가 움직일때마다 제 위치는 중앙에 고정되고 맵이 움직이게 하고 싶습니다

v1 같은 경우에는 mapoverlay 클래스를 썻었는데

 

v2에는 이를 어떻게 구현해야할지 모르겠군요..

 

public void GetLocations() {
Log.d("location", "========================GetLocations===========================");
// 텍스트뷰를 찾음
TextView latText = (TextView) findViewById(R.id.tvLatitude);
TextView lngText = (TextView) findViewById(R.id.tvLongitude);
TextView speedText = (TextView) findViewById(R.id.tvSpeed);
TextView jusoText = (TextView) findViewById(R.id.tvAddress);
StringBuffer juso = new StringBuffer();
 
 
if (myLocation != null) {
Log.d("location", "========================GetLocations!!!===========================");
latPoint = myLocation.getLatitude();
lngPoint = myLocation.getLongitude();
speed = (float) (myLocation.getSpeed() * 3.6);
 
// dou_lat = myLocation.getLatitude();
// dou_lng = myLocation.getLongitude();
 
Toast.makeText(blackbox.this, "위도  : " + dou_lat +  " 경도: "  + dou_lng ,  Toast.LENGTH_SHORT).show();
LatLng latlng = new LatLng(latPoint, lngPoint);
CameraPosition cp = new CameraPosition.Builder().target((latlng)).zoom(15).build();
map.animateCamera(CameraUpdateFactory.newCameraPosition(cp)); // 지정위치로 이동
 
 
try {
// 위도,경도를 이용하여 현재 위치의 주소를 가져온다.
List<Address> addresses;
addresses = geoCoder.getFromLocation(latPoint, lngPoint, 1);
for (Address addr : addresses) {
int index = addr.getMaxAddressLineIndex();
for (int i = 0; i <= index; i++) {
juso.append(addr.getAddressLine(i));
juso.append(" ");
Log.d("location", "button pressed");
}
juso.append("\n");
}
} catch (IOException e) {
e.printStackTrace();
}
 
}
latText.setText(String.valueOf(latPoint));
lngText.setText(String.valueOf(lngPoint));
speedText.setText(String.valueOf(speed));
jusoText.setText(String.valueOf(juso));
}
 
이런식으로 하려해도 구현이 되지 않아(cp 값 NullpointException) 답답한 맘에 질문드려봅니다!
qwedfghj (120 포인트) 님이 2013년 6월 15일 질문

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...