Calculating The Distance Between "setmylocationenabled" And A Marker Set On The Google Map
I am trying to make an application on Android which allows me to see the distance between two points on google maps, the distance points being The location i am currently at and th
Solution 1:
You can use the Location
class here.
First set the marker location:
LocationmarkerLoc=newLocation("Marker");
markerLoc.setLatitude(marker.latitude);
markerLoc.setLongitude(marker.longitude);
See this to get the current Location using OnMyLocationChangeListener
and set your Current Location:
LocationcurrentLoc=newLocation("Current");
currentLoc.setLatitude(location.latitude);
currentLoc.setLongitude(location.longitude);
Then you can use the Location
class' distanceTo
method to get the distance in meters like this:
Floatdistance= currentLoc.distanceTo(markerLoc);
Post a Comment for "Calculating The Distance Between "setmylocationenabled" And A Marker Set On The Google Map"