google maps - how to create markers at different point between source and destination in android? -


{    "routes" : [       {          "bounds" : {             "northeast" : {                "lat" : 12.8481608,                "lng" : 77.632796             },             "southwest" : {                "lat" : 12.7033123,                "lng" : 77.5885469             }          },          "copyrights" : "map data ©2015 google",          "legs" : [             {                "distance" : {                   "text" : "20.0 km",                   "value" : 19950                },                "duration" : {                   "text" : "40 mins",                   "value" : 2383                },                "end_address" : "unnamed road, billiganakuppe, karnataka 562112, india",                "end_location" : {                   "lat" : 12.7033123,                   "lng" : 77.5885469                },                "start_address" : "unnamed road, bettadasanapura, bengaluru, karnataka 560100, india",                "start_location" : {                   "lat" : 12.8481608,                   "lng" : 77.63232409999999                },                "steps" : [                   {                      "distance" : {                         "text" : "0.4 km",                         "value" : 440                      },                      "duration" : {                         "text" : "2 mins",                         "value" : 128                      },                      "end_location" : {                         "lat" : 12.844518,                         "lng" : 77.6323664                      },                      "html_instructions" : "head \u003cb\u003ewest\u003c/b\u003e",                      "polyline" : {                         "points" : "_llma_qyxm@`@@l@lbbb@h?n?radap?xclcx@e|@ez@gz@ez@ejeu~@gb@c"                      },                      "start_location" : {                         "lat" : 12.8481608,                         "lng" : 77.63232409999999                      },                      "travel_mode" : "driving"                   },                   {                      "distance" : {                         "text" : "30 m",                         "value" : 30                      },                      "duration" : {                         "text" : "1 min",                         "value" : 11                      },                      "end_location" : {                         "lat" : 12.8443413,                         "lng" : 77.6325708                      },                      "html_instructions" : "turn \u003cb\u003eleft\u003c/b\u003e",                      "maneuver" : "turn-left",                      "polyline" : {                         "points" : "gukmaiqyxmderwhi"                      },                      "start_location" : {                         "lat" : 12.844518,                         "lng" : 77.6323664                      },                      "travel_mode" : "driving"                   },                   {                      "distance" : {                         "text" : "0.2 km",                         "value" : 179                      },                      "duration" : {                         "text" : "1 min",                         "value" : 48                      },                      "end_location" : {                         "lat" : 12.8428057,                         "lng" : 77.6328027                      },                      "html_instructions" : "slight \u003cb\u003eright\u003c/b\u003e",                      "maneuver" : "turn-slight-right",                      "polyline" : {                         "points" : "ctkmaqryxmfedchchajal@|@bpaazcn?ha`@els"                      },                      "start_location" : {                         "lat" : 12.8443413,                         "lng" : 77.6325708                      },                      "travel_mode" : "driving"                   },                   {                      "distance" : {                         "text" : "0.1 km",                         "value" : 132                      },                      "duration" : {                         "text" : "1 min",                         "value" : 57                      },                      "end_location" : {                         "lat" : 12.8416291,                         "lng" : 77.63266949999999                      },                      "html_instructions" : "turn \u003cb\u003eright\u003c/b\u003e",                      "maneuver" : "turn-right",                      "polyline" : {                         "points" : "qjkma_tyxm@?dbd?|@bbbfp?d@h?f@f@hb"                      },                      "start_location" : {                         "lat" : 12.8428057,                         "lng" : 77.6328027                      },                      "travel_mode" : "driving"                   },                   {                      "distance" : {                         "text" : "0.1 km",                         "value" : 114                      },                      "duration" : {                         "text" : "1 min",                         "value" : 32                      },                      "end_location" : {                         "lat" : 12.8415124,                         "lng" : 77.63163910000002                      },                      "html_instructions" : "turn \u003cb\u003eright\u003c/b\u003e",                      "maneuver" : "turn-right",                      "polyline" : {                         "points" : "eckmaesyxmbh@d@f?f?h?haz?r?b?h?f@l@d@l@hbv@f@b@b"                      },                      "start_location" : {                         "lat" : 12.8416291,                         "lng" : 77.63266949999999                      },                      "travel_mode" : "driving"                   },                   {                      "distance" : {                         "text" : "1.0 km",                         "value" : 1008                      },                      "duration" : {                         "text" : "3 mins",                         "value" : 154                      },                      "end_location" : {                         "lat" : 12.8361958,                         "lng" : 77.62500639999999                      },                      "html_instructions" : "turn \u003cb\u003eleft\u003c/b\u003e",                      "maneuver" : "turn-left",                      "polyline" : {                         "points" : "mbkmawlyxm?@b@@@b@d@t@bha@p?h@@j@vbjbfdffjtjf@lj@nb@hrhajclczf@pfn@?v@tbphxn^r\\pvlljfzld@ll@pb@nxrb@b@vb@vd@`@|@p@zavf@dhjvvl@"                      },                      "start_location" : {                         "lat" : 12.8415124,                         "lng" : 77.63163910000002                      },                      "travel_mode" : "driving"                   },                   {                      "distance" : {                         "text" : "5.5 km",                         "value" : 5453                      },                      "duration" : {                         "text" : "10 mins",                         "value" : 626                      },                      "end_location" : {                         "lat" : 12.7963583,                         "lng" : 77.61599439999999                      },                      "html_instructions" : "turn \u003cb\u003eleft\u003c/b\u003e onto \u003cb\u003ebegur - koppa rd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003epass st mary's orthodox church, begur (on right in 2.3 km)\u003c/div\u003e",                      "maneuver" : "turn-left",                      "polyline" : {                         "points" : "gajmaicxxm`@epan?vap@xdd@f~@nb@bd@ap@kncc@vcc@h@cx?\\@rbpbzfh@l~ab@z@tt@rna`@jbz@tdbbn@tjcdaldf@jp@nb@hp@r@hhbjtcbxbfhbj`bjjer~fxj@af@crchctklkhmjqxy@rbsg\\cab@cazo@l@y@tyd@e@damax@y@baiat@u@t@y@xy^wnglej?j@\\bpbf@j~@rjbt|an`afdaff@?te?ba?x@rb\\djbv@f`bbdcbzd@|bf`advaljaj|@lf@dzfh@pall@~@jh@htathal~blp@@`ahbaldbxn@ltdndjbjfjfljr@t@`@f@zn@f@|@b@p@\\^llxtfax@n@j@j@d@\\zjzzfavfadlbazd`@vanazdn`@hrzr@\\x@\\v@lavcnxhpfpn\\tbxexadd"                      },                      "start_location" : {                         "lat" : 12.8361958,                         "lng" : 77.62500639999999                      },                      "travel_mode" : "driving"                   },                   {                      "distance" : {                         "text" : "3.1 km",                         "value" : 3109                      },                      "duration" : {                         "text" : "7 mins",                         "value" : 395                      },                      "end_location" : {                         "lat" : 12.7713362,                         "lng" : 77.61348219999999                      },                      "html_instructions" : "continue onto \u003cb\u003ekoppa gate nisarga rd\u003c/b\u003e\u003cdiv style=\"font-size:0.9em\"\u003epass anjaneiya ( hanuman ) temple nandanavana (on right in 3.0 km)\u003c/div\u003e",                      "polyline" : {                         "points" : "ghbma}jvxmdjbddfxnvfx@xp@t|@\\r@`@h@zpat@|brahcrahd|ajclarhrfpbtbbablcffb@`@azgliro^c@z@u@d@_@d@ypibc[tehbc@t@mvczep@aj?d?d?f?@@b?f@d?bblf`@r|@zd@b@@@b@bbbbbjbtbjdldhbddfffttvtfdfbvfthj@jbrbtb^dz@zdzb@@n@@z@d^b~ch@dgv@x@nz@pv@ntdf?d?d?fad?bcfafelihwluhghgjadaf@rannd^xgt@jdwfpwdihifedclalal?t?v@n@rbtdlbjdxlzrnhb?b@lbl@d?b?d?bah@kn@oj@ivaux@o"                      },                      "start_location" : {                         "lat" : 12.7963583,                         "lng" : 77.61599439999999                      },                      "travel_mode" : "driving"                   },                   {                      "distance" : {                         "text" : "0.7 km",                         "value" : 675                      },                      "duration" : {                         "text" : "1 min",                         "value" : 74                      },                      "end_location" : {                         "lat" : 12.769209,                         "lng" : 77.6181972                      },                      "html_instructions" : "turn \u003cb\u003eleft\u003c/b\u003e",                      "maneuver" : "turn-left",                      "polyline" : {                         "points" : "{k}lag{uxme@yacikueoesck?g?e?k?obubu@gda@lebbu^}bbk@ifufmdgdglkhgjijedcdcfcfchchancjarair@gtclcfadcdabcbcbera@`@aahubibi@g?eeu@"                      },                      "start_location" : {                         "lat" : 12.7713362,                         "lng" : 77.61348219999999                      },                      "travel_mode" : "driving"                   },                   {                      "distance" : {                         "text" : "48 m",                         "value" : 48                      },                      "duration" : {                         "text" : "1 min",                         "value" : 6                      },                      "end_location" : {                         "lat" : 12.7690771,                         "lng" : 77.6186106                      },                      "html_instructions" : "slight \u003cb\u003eright\u003c/b\u003e",                      "maneuver" : "turn-slight-right",                      "polyline" : {                         "points" : "q~|lawxvxmba@c@c@c@c@ebg?ebob["                      },                      "start_location" : {                         "lat" : 12.769209,                         "lng" : 77.6181972                      },                      "travel_mode" : "driving"                   },                   {                      "distance" : {                         "text" : "8.8 km",                         "value" : 8762                      },                      "duration" : {                         "text" : "14 mins",                         "value" : 852                      },                      "end_location" : {                         "lat" : 12.7033123,                         "lng" : 77.5885469                      },                      "html_instructions" : "turn \u003cb\u003eright\u003c/b\u003e",                      "maneuver" : "turn-right",                      "polyline" : {                         "points" : "w}|lai{vxmdcda@?bad?b?h?h?rdnpetv@bbjv@tbt~@lx@ljbhddbfdfdtzzxzpd@nh@ndatjavv@nhal`bhlbj@hbfdvlxntnnhfbjbj@d@dz@j@ah@ef?d@d?d@d@lfn@\\plddffdddhbf@f@j?laz?l?j@d?d@b?@@dfjhpfllldfzt^vb@lj`@`@la|ap^ptlphjfhxnlhfdhbrhtbn@bab@nbz@hbz@p@\\^pnd^jf@jn@jxdxgfazaphdd@bd@bbl@p@j?h@r?p@ad@@d@dbfjlnjtlp@zxt~@fanl^txfv?h@@|abbbbbaf~brdafz@bt@dt@bv@pdphjhzxjnrxbd@@@b?@?@?b?@?bad?bglinalah@h@@@d@bbdlvdjbhdjdfbfnlbbtahax@fhddbf@fbj@jb\\@h@b@b?b@@@b@@@@dbd@zlax@j@^ddbbdf@b@dbd@fdjn^fjfjfjhhhfpjjd\\jndnbtbj@l@b@@p@@^@b@dl@l@pfxjtjplphrftfb@d@hbh@f@f?^?v@a\\?^@vbrdl@hlbn@p@h?\\?l?jerg\\k\\ktba@nejal?p@l@f@fbj@phphja^d@p^pxtvpz`@tt\\\\zt^rv@^pfr@zrfj@jv@j~@n\\lthbb@@@@@b?@?@@faf?lclev?x?nbnh\\lznnhhb@h@\\^vplfbral@plzvhfjhz@r@nadavvhdf@rn@t`azp@phazvfdbb@hct@b@jx@`@?^bz@tfvjf@vb@ppa`@x@pbafn@bj@f@h`@frfpdjfhfdflrtxprxrlfldpbl@v@h@?x@p@h@h^hxb\\bd@dd@@va`a?h?fajahcjcfcbcfefizk@n[f@eav{@huhqhmjkdcfcl?t@ldpfndfdhdjjfhbfbf@h?l@n?l@pbndhffjdlbpbb@lrlpjrrnrvtz\\nf`ejnhnfpjrnrpl|dlbd@h@zvrl?@zvx@havxjjhdjfnj\\dx@\\bdabf@v@xbj@h`@hl@pj@jh@jl@ftalh@dh@@r?`@?zajaa`@?`@@v@z@bjadh@@z@dt@f@brbrdnblflfjfj@d@z@n@x@v@l@p@xxrxtvrzx`@ltptj@l@jhfbvb|@n@z|@j@xrv@d@hddbphjdhbjbndvdh@dp@hpbtdz@rp@hhapf@d@b@zjr@z`a\\zah@nd"                      },                      "start_location" : {                         "lat" : 12.7690771,                         "lng" : 77.6186106                      },                      "travel_mode" : "driving"                   }                ],                "via_waypoint" : []             }          ],          "overview_polyline" : {             "points" : "_llma_qyxmbn@dpl@b@a~@irdsbki@b@cx]pongtcjad|bej@gnsldnh@bpddn@b@a|@dh@hl@dfdbz@dpcdb@fnlv|@lj@nb@ra~clczf@pffadf@xx@d@t@xt`azpa`@|@v@n@haraxc`avbzaij@fdbvb@bd@a`eo@vcc@h@cv@@d@fdatzcx@dct@`h~czdzat@ptaxdajhbjtcbbfrlh^~fxj@az@g^ovyd@kapcwi~@sbbasahfwfjbobx@q@\\mv@n@ffb^hed@fcnzi@tbtfffzd@|bfxcrhcxbk~@hgx@pdndcvzdr@p@^ta|abalbb@p@\\^f@b@vbdbha`af@bb\\tadbrg~a|e`bxdnbtedfhlhlxnvfjbn@pb~@zbpa|brahcrathjdf@pf@fpejhc?h@qr@s@`buav@c@xca@~cq@r@ihaatbx@^ha`@fdfnf`@jvf@j@^z^j`arlgf@ndl~ch@dgv@x@npcf@xa`@uvm@ropczaphmta|dognslizcb@?f@bh@hxht@`@d@n\\@hcg@pce@i@cbqe@i_@?i@nuap{bb@ich_@luh@e@^qj@mhdw`@k^o@r@kb@maw@fohc@b[dcfavaflf@zbltdb@dapnhnjp@t@`a`@nbd@bcf@hal`bhxdphvav@rfp@ffa?p@evd|@d@vrv^brah@@d@jvp^rtlaz@nb~bb@t@v\\`@xtn\\ltbn@bab@xevbpan@n@pjkdbdbvhfdpb\\@\\avabjntd@xp@zxtnata^txf`a@`efbez`cjjbhh@f\\rf@h@zd@?hizk\\?rhprb@hthnrbbbpabahldrdh@dtdfzbzap@d@hjhvd@baptzrhazrahpabp@f^hn@vb@vh@n\\hfb?|@@j@h|apf@?xep@srcm@zg^@h@hb@rpbp@x@f@vpz`@r@r@z@h@|bba~@rvbzx@\\bf?^id@?h@ll@\\j@va`axpdbz@lb|afb|ap@xpbp@zbl@jhlbz@@z@dl@rjah@pa`@x@prbjhbz\\lnnb@l@j@f@zl^dlbd`czjafxaapate^qb@u@v@ab`@qar_@potcb@f`@lpjrtfn@v@\\d`@lpxht@pd@xvazanf`ejnp`@zf@nezbd@h@zvrnzvx@hab@d@tlnj\\dv@dladp@dlarxa\\var~br|@@jdc`elbdlf@h\\jxnfbtafbhbl@r@h@r@f@v@|@barlfdxava~@xax@p@rdcxpaxzbzl@ptbx@jbn@"          },          "summary" : "koppa gate nisarga rd",          "warnings" : [],          "waypoint_order" : []       }    ],    "status" : "ok" } 

i getting above result message on calling google maps url...i able draw route map between source , destination.

how can ad markers @ different points between source , destination.

i have tried code

   jroutes = jobject.getjsonarray("routes");                      log.d("in try",jroutes+"");                     log.d("in try",routes +"");                     /** traversing routes */                     for(int i=0;i<jroutes.length();i++){                         jlegs = ( (jsonobject)jroutes.get(i)).getjsonarray("legs");                         log.d("jlegs",jlegs+""+"\n" +"");                         list path = new arraylist<hashmap<string, string>>();                         log.d("path",path+""+"\n" +"");                         /** traversing legs */                         for(int j=0;j<jlegs.length();j++){                             jsteps = ( (jsonobject)jlegs.get(j)).getjsonarray("steps");                             log.d("jsteps",jsteps+""+"\n" +"");                             /** traversing steps */                             for(int k=0;k<jsteps.length();k++){                                  polyline = (string)((jsonobject)((jsonobject)jsteps.get(k)).get("polyline")).get("points");                                 list<latlng> list = decodepoly(polyline);                                 position_lat = (string)((jsonobject)((jsonobject)jsteps.get(k)).get("end_location")).get("lat").tostring();                                 position_lon = (string)((jsonobject)((jsonobject)jsteps.get(k)).get("end_location")).get("lng").tostring();                                 list_lat.add(position_lat);                                 list_lng.add(position_lon);                                 log.d("list", list+"");                                 /** traversing points */                                 for(int l=0;l<list.size();l++){                                     hashmap<string, string> hm = new hashmap<string, string>();                                     hm.put("lat", double.tostring(((latlng)list.get(l)).latitude) );                                     hm.put("lng", double.tostring(((latlng)list.get(l)).longitude) );                                     path.add(hm);                                     log.d("latlng", ""+double.tostring(((latlng)list.get(l)).latitude));                                 }                             }                           log.d("lat", list_lat+"");                            log.d("lon", list_lng+"");                            routes.add(path);                     }                 } 

i getting list of latitudes , longitudes.how can convert them latlng , represent markers in map ?

use route class. working code.

public class route {     googlemap mmap;     context context;     string lang;      static string language_spanish = "es";     static string language_english = "en";     static string language_french = "fr";     static string language_german = "de";     static string language_chinese_simplified = "zh-cn";     static string language_chinese_traditional = "zh-tw";      static string transport_driving = "driving";     static string transport_walking = "walking";     static string transport_bike = "bicycling";     static string transport_transit = "transit";      static arraylist<polyline> polyline ;     static arraylist<marker> markerprevious;      public boolean drawroute(googlemap map, context c, arraylist<latlng> points, boolean withindications, string language, boolean optimize)     {         mmap = map;         context = c;         lang = language;         if (points.size() == 2)         {             string url = makeurl(points.get(0).latitude, points.get(0).longitude, points.get(1).latitude, points.get(1).longitude, "driving");             new connectasynctask(url, withindications).execute();             return true;         }         else if (points.size() > 2)         {             string url = makeurl(points, "driving", optimize);             new connectasynctask(url, withindications).execute();             return true;         }          return false;      }      public boolean drawroute(googlemap map, context c, arraylist<latlng> points, string language, boolean optimize)     {         mmap = map;         context = c;         lang = language;         if (points.size() == 2)         {             string url = makeurl(points.get(0).latitude, points.get(0).longitude, points.get(1).latitude, points.get(1).longitude, "driving");             new connectasynctask(url, false).execute();             return true;         }         else if (points.size() > 2)         {             string url = makeurl(points, "driving", optimize);             new connectasynctask(url, false).execute();             return true;         }          return false;      }      public boolean drawroute(googlemap map, context c, arraylist<latlng> points, string mode, boolean withindications, string language,             boolean optimize)     {         mmap = map;         context = c;         lang = language;         if (points.size() == 2)         {             string url = makeurl(points.get(0).latitude, points.get(0).longitude, points.get(1).latitude, points.get(1).longitude, mode);             new connectasynctask(url, withindications).execute();             return true;         }         else if (points.size() > 2)         {             string url = makeurl(points, mode, optimize);             new connectasynctask(url, withindications).execute();             return true;         }          return false;      }      //      public void drawroute(googlemap map, context c, latlng source, latlng dest, boolean withindications, string language)     {         mmap = map;         context = c;          string url = makeurl(source.latitude, source.longitude, dest.latitude, dest.longitude, "driving");         new connectasynctask(url, withindications).execute();         lang = language;      }      public void drawroute(googlemap map, context c, latlng source, latlng dest, string language)     {         mmap = map;         context = c;          string url = makeurl(source.latitude, source.longitude, dest.latitude, dest.longitude, "driving");         new connectasynctask(url, false).execute();         lang = language;      }      public void drawroute(googlemap map, context c, latlng source, latlng dest, string mode, boolean withindications, string language)     {         mmap = map;         context = c;          string url = makeurl(source.latitude, source.longitude, dest.latitude, dest.longitude, mode);         new connectasynctask(url, withindications).execute();         lang = language;      }      private string makeurl(arraylist<latlng> points, string mode, boolean optimize)     {         stringbuilder urlstring = new stringbuilder();          if (mode == null)             mode = "driving";          urlstring.append("http://maps.googleapis.com/maps/api/directions/json");         urlstring.append("?origin=");//         urlstring.append(points.get(0).latitude);         urlstring.append(',');         urlstring.append(points.get(0).longitude);         urlstring.append("&destination=");         urlstring.append(points.get(points.size() - 1).latitude);         urlstring.append(',');         urlstring.append(points.get(points.size() - 1).longitude);          urlstring.append("&waypoints=");         if (optimize)             urlstring.append("optimize:true|");         urlstring.append(points.get(1).latitude);         urlstring.append(',');         urlstring.append(points.get(1).longitude);          (int = 2; < points.size() - 1; i++)         {             urlstring.append('|');             urlstring.append(points.get(i).latitude);             urlstring.append(',');             urlstring.append(points.get(i).longitude);         }          urlstring.append("&sensor=true&mode=" + mode);          return urlstring.tostring();     }      private string makeurl(double sourcelat, double sourcelog, double destlat, double destlog, string mode)     {         stringbuilder urlstring = new stringbuilder();          if (mode == null)             mode = "driving";          urlstring.append("http://maps.googleapis.com/maps/api/directions/json");         urlstring.append("?origin=");//         urlstring.append(double.tostring(sourcelat));         urlstring.append(",");         urlstring.append(double.tostring(sourcelog));         urlstring.append("&destination=");//         urlstring.append(double.tostring(destlat));         urlstring.append(",");         urlstring.append(double.tostring(destlog));         urlstring.append("&sensor=false&mode=" + mode + "&alternatives=true&language=" + lang);         return urlstring.tostring();     }      private list<latlng> decodepoly(string encoded)     {          list<latlng> poly = new arraylist<latlng>();         int index = 0, len = encoded.length();         int lat = 0, lng = 0;          while (index < len)         {             int b, shift = 0, result = 0;                         {                 b = encoded.charat(index++) - 63;                 result |= (b & 0x1f) << shift;                 shift += 5;             }             while (b >= 0x20);             int dlat = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));             lat += dlat;              shift = 0;             result = 0;                         {                 b = encoded.charat(index++) - 63;                 result |= (b & 0x1f) << shift;                 shift += 5;             }             while (b >= 0x20);             int dlng = ((result & 1) != 0 ? ~(result >> 1) : (result >> 1));             lng += dlng;              latlng p = new latlng((((double) lat / 1e5)), (((double) lng / 1e5)));             poly.add(p);         }          return poly;     }      private class connectasynctask extends asynctask<void, void, string>     {         private progressdialog progressdialog;         string url;         boolean steps;          connectasynctask(string urlpass, boolean withsteps)         {             url = urlpass;             steps = withsteps;          }          @override         protected void onpreexecute()         {             // todo auto-generated method stub             super.onpreexecute();             progressdialog = new progressdialog(context);             progressdialog.setmessage("fetching route, please wait...");             progressdialog.setindeterminate(true);             progressdialog.show();         }          @override         protected string doinbackground(void... params)         {             jsonparser jparser = new jsonparser();             string json = jparser.getjsonfromurl(url);             return json;         }          @override         protected void onpostexecute(string result)         {             super.onpostexecute(result);             progressdialog.hide();             if (result != null)             {                 drawpath(result, steps);             }         }     }      private void drawpath(string result, boolean withsteps)     {          try         {             //tranform string json object             final jsonobject json = new jsonobject(result);             jsonarray routearray = json.getjsonarray("routes");             jsonobject routes = routearray.getjsonobject(0);             jsonobject overviewpolylines = routes.getjsonobject("overview_polyline");             string encodedstring = overviewpolylines.getstring("points");             list<latlng> list = decodepoly(encodedstring);             if(polyline != null)             {                 (int = 0; < polyline.size(); i++)                 {                     polyline line = polyline.get(i);                     line.remove();                 }                 polyline.clear();             }             else             {                 polyline = new arraylist<polyline>();             }             (int z = 0; z < list.size() - 1; z++)             {                 latlng src = list.get(z);                 latlng dest = list.get(z + 1);                  polyline line = mmap.addpolyline(new polylineoptions()                         .add(new latlng(src.latitude, src.longitude), new latlng(dest.latitude, dest.longitude)).width(4).color(color.blue)                         .geodesic(true));                  polyline.add(line);              }               if(markerprevious != null)             {                 (int = 0; < markerprevious.size(); i++)                 {                     marker marker = markerprevious.get(i);                     marker.remove();                 }                 markerprevious.clear();             }             else             {                 markerprevious = new arraylist<marker>();             }              if (withsteps)             {                 jsonarray arraylegs = routes.getjsonarray("legs");                 jsonobject legs = arraylegs.getjsonobject(0);                 jsonarray stepsarray = legs.getjsonarray("steps");                 //put initial point                  (int = 0; < stepsarray.length(); i++)                 {                     step step = new step(stepsarray.getjsonobject(i));                     marker marker = mmap.addmarker(new markeroptions().position(step.location).title(step.distance).snippet(step.instructions)                             .icon(bitmapdescriptorfactory.defaultmarker(bitmapdescriptorfactory.hue_blue)));                     markerprevious.add(marker);                 }             }          }         catch (jsonexception e)         {          }     }      /**      * class represent every step of directions. store distance, location , instructions      */     private class step     {         public string distance;         public latlng location;         public string instructions;          step(jsonobject stepjson)         {             jsonobject startlocation;             try             {                  distance = stepjson.getjsonobject("distance").getstring("text");                 startlocation = stepjson.getjsonobject("start_location");                 location = new latlng(startlocation.getdouble("lat"), startlocation.getdouble("lng"));                 try                 {                     instructions = urldecoder.decode(html.fromhtml(stepjson.getstring("html_instructions")).tostring(), "utf-8");                 }                 catch (unsupportedencodingexception e)                 {                     // todo auto-generated catch block                     e.printstacktrace();                 }                 ;              }             catch (jsonexception e)             {                 // todo auto-generated catch block                 e.printstacktrace();             }         }     }  } 

call :

arraylist<latlng> allatlng = new arraylist<latlng>();                     latlng latlng = new latlng(double.parsedouble(strdestlat), double.parsedouble(strdestlng));                     allatlng.add(latlng);                     latlng latlng1 = new latlng(double.parsedouble(strcurrentlat), double.parsedouble(strcurrentlong));                     allatlng.add(latlng1);                      route route = new route();                     route.drawroute(googlemap, home.this, allatlng, true, route.language_english, true); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -