-1

i'm developing an App in Android that check some parameters like Fuel Level from OBD port and with this parameter i would like to advice the user that the Fuel level is inadeguate for the entire travel.

So i need to get distance in Km from GPS or phone position to some Marker B in the map (like fuel shop). It's possible to get distance from phone position and some specified Marker B without integrate a Google Maps inside my application? And only if the user press "Ok guide me to point B" i use the app google maps for the navigation?

I see in the documentations that i can select some type of search with a Place Picker and now i need the distance from selected position and my position and check if the fuel is enough for the entire travel.

Some suggestions?

Dario
  • 732
  • 7
  • 30
  • [Here](https://stackoverflow.com/a/14394403/6950238) is the solution without using Google Maps, but this is distance between points, not via road. – Andrii Omelchenko Oct 10 '17 at 19:44
  • Possible duplicate of [How to find distance (by road) between 2 geo points in Android application?](https://stackoverflow.com/questions/16249693/how-to-find-distance-by-road-between-2-geo-points-in-android-application) – Andrii Omelchenko Oct 10 '17 at 19:56

1 Answers1

1
var current_coords = new google.maps.LatLng(latitude1, longitude1);
var shop_coords = new google.maps.LatLng(latitude2, longitude2);

var distance = google.maps.geometry.spherical.computeDistanceBetween(current_coords, shop_coords)

NOTE: THIS WILL CALCULATE DIRECT DISTANCE BETWEEN TWO POINTS.MEANS NOT DISTANCE VIA ROAD

krishnar
  • 2,537
  • 9
  • 23
  • Thanks, but i need the Road distance for check if the fuel is enough! There is some way? current_coords i think that i take from my marker via GPS...but how i get the shop_coords that you write? – Dario Oct 10 '17 at 18:12
  • 1
    @Dario Then you should go for DistanceMatric API. – krishnar Oct 10 '17 at 18:13