How to use the Google Maps API on a Windows Form in c#?

Asked

Viewed 233 times

0

I’m having trouble with how to do that. My TCC has a tab where there are some addresses (Label), where, when clicking, I want the address to appear in Maps. I’ve thought about using Webbrowser, but I don’t want the user browsing beyond that address.

Exemplo

I want that window to appear. But I don’t know what to do.

  • Welcome to Stackoverflow in English. I edited your question to remove the greetings as we usually keep the text as clean as possible to focus on your scheduling question. If you are interested in visiting a part of the site that is not aimed to ask questions can know the [chat]. If you have questions about the operation, rules and procedures of the site visit the [meta] :)

1 answer

0

You didn’t say whether these addresses will be static or not. If it’s static, you can do it like this:

  1. Search each location on the google maps website and adjust the zoom level, terrain type and etc.

  2. Still on the google maps website, click on the menu button (those three little stripes on the top right) and then click on Share or embed map.

  3. Click enter map, make the necessary adjustments and copy the generated code. Do this for each address.
  4. Add to your form a Webview and each time you click on an address you call the function below by passing as parameter the code generated by each address in google.

This way Webview will only display the portion of the map you choose Code:

public void updateWebView(string codigoIncorporado)
{
    webBrowser1.Refresh();
    var str = "<html><head></head><body>" + codigoIncorporado + "</body></html>";
    webBrowser1.DocumentText = str;
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.