2

I have found that Google map provides PolylineOptions but I haven't been able to find anything for Osmdroid.

If any one can suggest a solution with an example it would be very helpfull.

Josef Adamcik
  • 5,620
  • 3
  • 36
  • 42

1 Answers1

1

You may not be able to draw a real curved line, but you should be able to create a Polyline which would appear to be curved. Polyline composes from straight line segments which are not curved.

It's seems that also the Google Map API you are referring to supports only Polylines without curves. See Google Map documentation

A Polyline is a series of connected line segments that can form any shape you want and can be used to mark paths and routes on the map.

Polylines and Polygons are supported by the Osmdroid library. Detail can be found in the Osmdroid documentation.

You can create Polyline easily:

List<GeoPoint> geoPoints = new ArrayList<>();
geoPoints.add(start);
//... add other points that should form the curve
geoPoints.add(end);

//add your points here
Polyline line = new Polyline();   //see note below!
line.setPoints(geoPoints);
map.getOverlayManager().add(line);

The tricky part would be to compute the points between your two known coordinates.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Josef Adamcik
  • 5,620
  • 3
  • 36
  • 42
  • thanks for your answer but how to calculated other points that should form a curve between two coordinates(source & Destination). – Dheeraj Kumar Singh Feb 06 '19 at 08:34
  • @DheerajKumarSingh I guess that would depend on what is the curve supposed to represent. You haven't specified that in your question. – Josef Adamcik Feb 06 '19 at 16:34
  • which algorithm we use for this. please suggest any link. – Dheeraj Kumar Singh Feb 07 '19 at 10:47
  • @DheerajKumarSingh You should be able to achieve a similar result with the osmdroid library. The first result is from this SO question https://stackoverflow.com/questions/47950659/draw-a-curve-bezier-curve-between-two-lat-long-points-on-google-maps-android and you can see they are also using only Polyline and basically adding a lot of points so it appears to be a nice curve. You can also see the algorithm from the bazier curve. – Josef Adamcik Feb 07 '19 at 10:49