Gettting Different Distance When Using the Google Map and User defined Function

android

Solution

This diagram explains why you get 12.5 and 17.6 kms

To calculate the driving distance (17.6 km) , you need to use the directions API

Problem

I want to get the Distance between two latitude and longitude in meter / km . So i am using the below function . It gives me the different result than the google Map. Can you help me to solve my problem ? i dont understand What is the Problem ? Code ``` float[] results = {0}; android.location.Location.distanceBetween(lat1, lon1, lat2, lon2, results); ``` Current Latitude = `23.012281666666663` Current Longitude = `72.51798333333333` Destination Latitude = `23.1120487` Destination Latitude = `72.5766759` It gives this Result = 12579.679 in Meter, while in google map it gives this result = 17.9 Km I do not understand why this two gives the different result.

Original source