我在地图中添加了一条概述多段线,但现在我希望它在不同的纬度和经度下看起来是彩色的。 如果可以的话,请帮助我找到解决这个问题的方法
public void User(final Context context,final GoogleMap gMap) {
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);
}
我想买点like this