Articles → MICROSOFT BOT FRAMEWORK → Open Google Map In Microsoft Bot Framework
Open Google Map In Microsoft Bot Framework
Generate API Key
- Go to the URL - https://developers.google.com/maps/documentation/embed/get-api-key
- Scroll down and you will get the instructions.
Click to Enlarge
- Click on the "Go to the Credentials Page" button.
- On the credentials page, you will see the list of the projects.
Click to Enlarge
- Click on any project to go to the details screen.
- In the details screen, click on "+ Create Credentials" → "API Key".
Click to Enlarge
- A popup window will appear with the generated API key.
Click to Enlarge
- Copy the key and close the window.
Code In Bot Project
var images = new List <CardImage> ();
HeroCard _card = new HeroCard();
string apiKey = "<your_generated_api_key>";
string storeAddress = "Banaras";
images.Add(
new CardImage($"https://maps.googleapis.com/maps/api/staticmap?zoom=17&scale=2&size=600x300&maptype=roadmap&key={apiKey}&format=png&visual_refresh=true&markers=size:mid%10Ccolor:0xff0000%7Clabel:1%7C" + storeAddress));
var buttons = new List < CardAction > ();
buttons.Add(new CardAction(ActionTypes.OpenUrl, "Directions", value: $ "https://www.google.co.in/maps/dir/{"
"}/{storeAddress}"));
_card.Buttons = buttons;
_card.Images = images;
await turnContext.SendActivityAsync(MessageFactory.Attachment(_card.ToAttachment()), cancellationToken);
Output
Click to Enlarge