app/src/main/java/com/example/bs206/retrofittest/java/a/MapsActivity.java
// Executes in UI thread, after the parsing process
Executes in UI thread, after the parsing process
Executes in UI thread after the parsing process
@Override
        protected void onPostExecute(List<List<HashMap<String, String>>> result)
        {
            ArrayList<LatLng> points;
            PolylineOptions lineOptions = null;
            for (int i = 0; i < result.size(); i++)
            {
                points = new ArrayList<>();
                lineOptions = new PolylineOptions();
                List<HashMap<String, String>> path = result.get(i);
                for (int j = 0; j < path.size(); j++)
                {
                    HashMap<String, String> point = path.get(j);
                    double lat = Double.parseDouble(point.get("lat"));
                    double lng = Double.parseDouble(point.get("lng"));
                    LatLng position = new LatLng(lat, lng);
                    points.add(position);
                }
                lineOptions.addAll(points);
                lineOptions.width(10);
                lineOptions.color(Color.RED);
                Log.d("onPostExecute","onPostExecute lineoptions decoded");
            }
            if(lineOptions != null) {
                mMap.addPolyline(lineOptions);
            }
            else {
                Log.d("onPostExecute","without Polylines drawn");
            }
        }
@ Override protected void onPostExecute ( List < List < HashMap < String , String > > > result ) { ArrayList < LatLng > points ; PolylineOptions lineOptions = null ; for ( int i = 0 ; i < result . size ( ) ; i ++ ) { points = new ArrayList < > ( ) ; lineOptions = new PolylineOptions ( ) ; List < HashMap < String , String > > path = result . get ( i ) ; for ( int j = 0 ; j < path . size ( ) ; j ++ ) { HashMap < String , String > point = path . get ( j ) ; double lat = Double . parseDouble ( point . get ( "lat" ) ) ; double lng = Double . parseDouble ( point . get ( "lng" ) ) ; LatLng position = new LatLng ( lat , lng ) ; points . add ( position ) ; } lineOptions . addAll ( points ) ; lineOptions . width ( 10 ) ; lineOptions . color ( Color . RED ) ; Log . d ( "onPostExecute" , "onPostExecute lineoptions decoded" ) ; } if ( lineOptions != null ) { mMap . addPolyline ( lineOptions ) ; } else { Log . d ( "onPostExecute" , "without Polylines drawn" ) ; } }
Executes in UI thread, after the parsing process
Executes in UI thread after the parsing process
// Traversing through all the routes // Fetching i-th route // Fetching all the points in i-th route // Adding all the points in the route to LineOptions // Drawing polyline in the Google Map for the i-th route