Display a path in my maps android app -
i tried develop android app maps. i'm beginner in android app development, doesn't know how generate path between current position , destination. can able view current location code shown below.
package com.example.myapp; import com.google.android.gms.maps.cameraupdatefactory; import com.google.android.gms.maps.googlemap; import com.google.android.gms.maps.mapfragment; import com.google.android.gms.maps.onmapreadycallback; import com.google.android.gms.maps.model.latlng; import android.app.activity; import android.os.bundle; import android.view.menu; import android.view.menuitem; public class grandinmaps extends activity implements onmapreadycallback{ @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_grandinmaps); mapfragment mapfragment = (mapfragment) getfragmentmanager() .findfragmentbyid(r.id.map); mapfragment.getmapasync(this); } @override public void onmapready(googlemap map) { // todo auto-generated method stub map.setmylocationenabled(true); map.movecamera(cameraupdatefactory.newlatlngzoom( new latlng(12.971907, 80.220462), 18)); } }
and doesn't know code generate path destination. help...!!! please:-)
for drawing route can use code:
call printing location route:
gmapv2direction route; document document; latlng toposition = new latlng(routedata.get(i).latitude, routedata.get(i).longitude); new getroutetask() { @override protected void onpostexecute(string s) { super.onpostexecute(s); } }.execute((latlng) toposition); private class getroutetask extends asynctask<latlng, void, string> { string response = ""; @override protected string doinbackground(latlng... params) { document = route.getdocument(fromposition, params[0], gmapv2direction.mode_walking);//fromposition latlng object.can current location. response = "success"; return response; } @override protected void onpostexecute(string s) { // directionmap.clear(); if (response.equalsignorecase("success")) { log.v("map", "got here"); arraylist<latlng> directionpoint = route.getdirection(document); polylineoptions rectline = new polylineoptions().width(10).color( color.red); (int = 0; < directionpoint.size(); i++) { rectline.add(directionpoint.get(i)); } // adding route on map map.addpolyline(rectline); } } }
Comments
Post a Comment