Drawn of polylines in Google Maps Api

4

I have managed to trace the routes on the map, what I want to achieve is that the union between the polylines is rounded, or that there are no sharp cuts between strokes.

Stroke achieved:

Stroke to which you wish to arrive:

public void onDrawRoutes(final GoogleMap mMap) throws JSONException {

    final JSONArray polyline = mArray.getJSONObject(mRoute).getJSONArray("legs").getJSONObject(0).getJSONArray("steps");

    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            for (int i = 0; i < polyline.length(); i ++) {
                String points = null;
                try {
                    points = polyline.getJSONObject(i).getJSONObject("polyline").getString("points");
                } catch (JSONException e) {
                    e.printStackTrace();
                }
                lists.add(i, PolyUtil.decode(points));
            }
            return null;
        }

        @RequiresApi(api = Build.VERSION_CODES.M)
        @Override
        protected void onPostExecute(Void aVoid) {
            for (int j = 0; j < lists.size(); j++) {
                List<LatLng> iterable = lists.get(j);
                mMap.addPolyline(new PolylineOptions()
                        .addAll(iterable)
                        .width(20)
                        .color(mContext.getResources().getColor(R.color.ligthBlue, null)).geodesic(true));
            }
        }
    }.execute();

}
    
asked by Jorge Gonzalez 05.01.2017 в 01:38
source

1 answer

2

I think you're trying to achieve with polylines what addresses .

If it is mandatory that you use polylines, try to reduce the width of it, or in "the corners", use several lines to "soften" the angle between them. The simplest way to implement this is through a ochava

    
answered by 26.02.2017 / 18:53
source