Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Log.d("seee",makeURL());
- final MarkerOptions markerOptions=new MarkerOptions();
- final StringRequest stringRequest = new StringRequest(Request.Method.POST, makeURL(), new Response.Listener<String>() {
- List<LatLng> startLatLng=null;
- @Override
- public void onResponse(String response) {
- JSONObject json=null;
- try {
- json = new JSONObject(response);
- JSONArray routeArray = json.getJSONArray("routes");
- for(int i=0;i<routeArray.length();i++) {
- JSONObject routes = routeArray.getJSONObject(i);
- JSONArray rAQI=routeArray.getJSONObject(i).getJSONArray("legs").getJSONObject(0).getJSONArray("steps");
- startLatLng=getLatitudeLongitudes(rAQI);
- JSONObject overviewPolylines = routes
- .getJSONObject("overview_polyline");
- String encodedString = overviewPolylines.getString("points");
- List<LatLng> list = PolyUtil.decode(encodedString);
- if(i!=0) {
- PolylineOptions options = new PolylineOptions().width(17).color(ContextCompat.getColor(context,R.color.colorGreyline)).geodesic(true);
- for (int z = 0; z < list.size(); z++) {
- LatLng point = list.get(z);
- options.add(point);
- }
- gMap.addPolyline(options);
- options.clickable(true);
- }
- else {
- PolylineOptions options = new PolylineOptions().width(20).color(ContextCompat.getColor(context,R.color.colorBlueline)).geodesic(true);
- for (int z = 0; z < list.size(); z++) {
- LatLng point = list.get(z);
- options.add(point);
- }
- gMap.addPolyline(options);
- options.clickable(true);
- }
- }
- } catch (JSONException e) {
- e.printStackTrace();
- }
- Toast.makeText(context, ""+startLatLng.size(), Toast.LENGTH_SHORT).show();
- }
- }, new Response.ErrorListener() {
- @Override
- public void onErrorResponse(VolleyError error) {
- Toast.makeText(context, "" + error.getMessage(), Toast.LENGTH_SHORT).show();
- }
- }) {
- @Override
- protected Map<String, String> getParams() throws AuthFailureError {
- Map<String, String> params = new HashMap<>();
- return params;
- }
- };
- RequestQueue queue = Volley.newRequestQueue(context);
- queue.add(stringRequest);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement