Search code examples
androidgoogle-mapspathgoogle-polyline

How to draw line between two Latlong points?


Using Polyline i can able to create a path between two points.

but when i am using these two points (Ahmedabad to New york) polyline is not create. else it works if there is no SEA between two points.

i'am getting issue when points are like

enter image description here

but in this case its working from Bhuj to Ahmedabad enter image description here


Solution

  • Finally I got the Answer how Ola and Uber app doing these..

    enter image description here

    ArrayList<LatLng> points = new ArrayList<LatLng>();
                    PolylineOptions polyLineOptions = new PolylineOptions();
                    points.add(new LatLng(from_latitude,from_longitude));
                    points.add(new LatLng(to_latitude,to_longitude));
                    polyLineOptions.width(7 * 1);
                    polyLineOptions.geodesic(true);
                    polyLineOptions.color(activity.getResources().getColor(R.color.black));
                    polyLineOptions.addAll(points);
                    Polyline polyline = mMap.addPolyline(polyLineOptions);
                    polyline.setGeodesic(true);