I have start latitude, longitude and end latitude,longitude.
I find Geo Point using latitude and longitude.
After that i draw line between the two Geo points
You can use Haversine formula
snippet and checked with this page
public static void midPoint(double lat1,double lon1,double lat2,double lon2){
double dLon = Math.toRadians(lon2 - lon1);
//convert to radians
lat1 = Math.toRadians(lat1);
lat2 = Math.toRadians(lat2);
lon1 = Math.toRadians(lon1);
double Bx = Math.cos(lat2) * Math.cos(dLon);
double By = Math.cos(lat2) * Math.sin(dLon);
double lat3 = Math.atan2(Math.sin(lat1) + Math.sin(lat2), Math.sqrt((Math.cos(lat1) + Bx) * (Math.cos(lat1) + Bx) + By * By));
double lon3 = lon1 + Math.atan2(By, Math.cos(lat1) + Bx);
//print out in degrees
System.out.println(Math.toDegrees(lat3) + " " + Math.toDegrees(lon3));
}
The checked solution does not work for me.
Anyway, i have found an easiest solution :
private GeoPoint midPoint(double lat1,double lon1,double lat2,double lon2){
//create origin geopoint from parameters
GeoPoint origin = new GeoPoint(lat1,lon1);
//create destination geopoints from parameters
GeoPoint destination = new GeoPoint(lat2,lon2);
//calculate and return center
return GeoPoint.fromCenterBetween(origin, destination);
}
If you have origin and destination as GeoPoint, you can use directly "GeoPoint.fromCenterBetween" method.
You can approximate the midpoint by taking the average of the latitudes of the two points and the average of the longitudes.
If you need it a bit more precisely, you can use the Haversine formula and some algebra to derive the midpoint.