dsciitbbs / iitbbsguide

Google Action for IIT Bhubaneswar
5 stars 2 forks source link

Add dynamic Map route #1

Open PalAditya opened 5 years ago

PalAditya commented 5 years ago

For now, when the map preview shows up, it only shows the marker to destination. We need it to show the complete route from our location to destination.

Idea: Use directions API (https://maps.googleapis.com/maps/api/directions/json?origin={Start}&destination={End}&mode=driving&key=YOUR_API_KEY) to get the driving route (in result.overview_polyline.points ), which is encoded. The function to decode it is already in index.js, and you need to send a request to maps static API (http://maps.googleapis.com/maps/api/staticmap?sensor=false&zoom=16&size=400x400&path=The_decoded_path_from_above}&key=YOUR_API_KEY) to show the image on the Basic Card already there in dialogflow

Requirements: Synchronous operation is not allowed. Use Promises and asynchronous operation to chain the API calls and then return the results.

apsknight commented 4 years ago

@PalAditya Could you please add some screenshots of required feature by mimicking the behavior in native Google Assistant?

PalAditya commented 4 years ago

Sure. For a longer distance (say Kolkata-Bhubaneswar), the Google assistant shows:

drawing

For a shorter distance (say Khurdha-Bhubaneswar), we have:

drawing

We want to mimic this functionality accurately, with as many polylines (turns) as possible to get from the maps API.