2013-04-01 5 views

답변

1

현재 위치를 알고 싶으면 현재 loacation의 위도와 경도를 알아야합니다.

public void getLatiLongi() 
{ 
    LocationManager lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE); 
     Location location = lm.getLastKnownLocation(LocationManager.GPS_PROVIDER); 
     if (location != null) { 
       flati = location.getLatitude(); 
       flongi = location.getLongitude(); 
       System.out.println("Hello....................+lati+longi"); 
      } 
    } 

    @Override 
    protected void onStart() { 
     super.onStart(); 

     LocationManager locationManager = 
       (LocationManager) getSystemService(Context.LOCATION_SERVICE); 
     final boolean gpsEnabled = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); 

     if (!gpsEnabled) { 
      gpsAlert(); 

     } 
    } 

    public void gpsAlert(){ 
     AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); 

      alertDialogBuilder.setTitle("Enable GPS"); 
      alertDialogBuilder 
       .setMessage("Yes")  
       .setCancelable(false) 
       .setPositiveButton("Yes",new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog,int id) { 

         enableLocationSettings(); 
         dialog.cancel(); 
        } 
        }) 
       .setNegativeButton("No",new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog,int id) {   
         dialog.cancel(); 
        } 
       }); 
       AlertDialog alertDialog = alertDialogBuilder.create(); 
       alertDialog.show(); 
    } 
    private void enableLocationSettings() { 
     Intent settingsIntent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS); 
     startActivity(settingsIntent); 
    } 

그 후 마커

https://developers.google.com/maps/documentation/android/marker를 사용합니다.

목적지의 위도와 경도가 필요합니다.

https://developers.google.com/maps/documentation/android/shapes#polylines.

사용 폴리 라인은 대상

Answer : Draw path between two points using Google Maps Android API v2에 위치에서 경로를 그립니다. 이 링크는 주제에 대한 좋은 설명이됩니다.

+0

thx 나는 그것을 시험해 볼 것이다. –

관련 문제