0

Currently, I am a using a $nearSphere mongo query to fetch documents to fetch based on a given latitude, longitude, and a radius.

Is there a possibility where I can use google maps API to fetch real-time data between two points and find the real-time shortest route distance instead of shortest sphere distance between two points.

For eg. I pass a position [lng, lat] to fetch all the documents i.e records from the mongo database using $nearSphere query and giving a radius as 5 km. It will cross check with other records and find the documents within 5 km relative to the position passed in the request. The distance between passed [lng, lat] in the query and that of the [lng, lat] present in the database records are sphere distance.

What I want to find is the real-time route distance like how it is shown in UBER app or between pickup and destination positions and not the sphere distance. Is this possible to write a code on the server side to achieve this case?

Artist
  • 93
  • 1
  • 10
  • Please explain more about what you mean by "documents to fetch based on...", "real time data between two points ", "real time shortest route distance". – Yunnosch Jul 30 '18 at 05:29
  • @Yunnosch I have added more details, please check – Artist Jul 30 '18 at 06:34

1 Answers1

0

You need to use google Map Direction API:-

https://maps.googleapis.com/maps/api/directions/json?origin=Disneyland&destination=Universal+Studios+Hollywood4&key=YOUR_API_KEY 

and read more about Google Direction web services.

This also help you find shortest and fastest route in Google Maps API

Ravindra Kumar
  • 1,842
  • 14
  • 23