// 상단에 내위치랑 거리 표현
if(ismypoint){
ArrayList<LatLng> ar_lng=new ArrayList<LatLng>();
ar_lng.add(new LatLng(myla, myln));
ar_lng.add(buildlng);
PolylineOptions po=new PolylineOptions();
po.color(Color.RED);
po.width(5);
po.addAll(ar_lng);
mapFragment.getMap().addPolyline(po);
ar_lng.clear();
Log.e("거리", distance(myla, myln, buildla, buildln, 'k')+"");
if(distance(myla, myln, buildla, buildln, 'k')<10){
if(!isalert){
isalert=true;
LayoutInflater gg=(LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View ac=gg.inflate(R.layout.layout_pop, null);
ImageView img1=(ImageView) ac.findViewById(R.id.img1);
TextView tx1=(TextView) ac.findViewById(R.id.alert_tx1);
tx1.setText("걸린시간 : "+chm.getText());
chm.stop();
img1.setImageResource(R.drawable.a11+imgnum);
//layout_pop에 이미지 붙이기
new AlertDialog.Builder(MainActivity.this).setTitle("도착 : "+arr_build[imgnum]).setPositiveButton("닫기", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface arg0, int arg1) {
// TODO Auto-generated method stub
arg0.dismiss();
isalert=false;
}
}).setView(ac).show();
//알림창
}
}
}
//처음에 카메라 무브 1번하기 위해서
if(!ismypoint){
mapFragment.getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(mylatlng, 15f));
//카메라 무브 한번 한다.
}
//작업 내위치 한번 찍어준다.
}
/**
* Callback called when connected to GCore. Implementation of {@link ConnectionCallbacks}.
*/
@Override
public void onConnected(Bundle connectionHint) {
LocationServices.FusedLocationApi.requestLocationUpdates(
mGoogleApiClient,
REQUEST,
this); // LocationListener
}
/**
* Callback called when disconnected from GCore. Implementation of {@link ConnectionCallbacks}.
*/
@Override
public void onConnectionSuspended(int cause) {
// Do nothing
}
/**
* Implementation of {@link OnConnectionFailedListener}.
*/
@Override
public void onConnectionFailed(ConnectionResult result) {
// Do nothing
}
@Override
public boolean onMyLocationButtonClick() {
Toast.makeText(this, "MyLocation button clicked", Toast.LENGTH_SHORT).show();
// Return false so that we don't consume the event and the default behavior still occurs
// (the camera animates to the user's current position).
return false;
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
@Override
protected void onActivityResult(int arg0, int arg1, Intent arg2) {
// TODO Auto-generated method stub
super.onActivityResult(arg0, arg1, arg2);
//내 목적지를 누르고 선택한 부분을 받아오는부분
if(arg0==1){
int g=arg2.getIntExtra("num", 0);
imgnum=g;
map.clear();
LatLng ll= getbuilwhere(g);
buildla=ll.latitude;
buildln=ll.longitude;
ismypoint=true;
저희가 네비게이션을 만들어 보고 있습니다.
저희가 apk로 실행을 해본결과 정상적으로 작동은 됩니다.
다만 문제가 현위치에서 목적지까지 빨간줄이 표시가 되는데
이것을 길따라서 빨간줄 표시가 가능할가여??
http://blog.naver.com/ghkdii 여기로 들어가시면 이미지가 있습니다.