android - google map getting current position and draw path -


how current position in android , draw path or line between current position , location touched.

to know current location require latitude , longitude of current 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);     } 

after use marker

https://developers.google.com/maps/documentation/android/marker.

you require latitude , longitude of destination.

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

use polylines draw path location destination

answer : draw path between 2 points using google maps android api v2. link has explanation on topic.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -