Web map directions

Does anyone have an example of how to use the WebMapViewer to plot directions from current location to another location?

Hello Nathan,

I do not believe this can be done with the WebMapViewer, however it can be achieved with the WebHTMLViewer.

My current understanding is that the WebMapViewer only interacts with:

Google Geocoding API when Geocoding an address passed to WebMapLocation; and
Google Maps Javascript API when setting the Latitude and Longitude properties.

Both of which are used in conjunction with Add Location and/or GoToLocation only.

To plot directions, you need to use the Google Directions API (you will need to enable this API in your Google Cloud Console first). You may then use a WebHTMLViewer in place of the WebMapViewer.

Example use:

Source example code from the Google Maps Support page for the Directions API. Remember to include your API Key in your code.
In the Open or Shown event of the WebHTMLViewer:

Var url As String = "your sample Directions code here" HTMLViewer1.LoadPage(url)

I hope that helps.

Kind regards, Andrew

[quote=490627:@Andrew Paul Dickey]Hello Nathan,

I do not believe this can be done with the WebMapViewer, however it can be achieved with the WebHTMLViewer.

My current understanding is that the WebMapViewer only interacts with:

Google Geocoding API when Geocoding an address passed to WebMapLocation; and
Google Maps Javascript API when setting the Latitude and Longitude properties.

Both of which are used in conjunction with Add Location and/or GoToLocation only.

To plot directions, you need to use the Google Directions API (you will need to enable this API in your Google Cloud Console first). You may then use a WebHTMLViewer in place of the WebMapViewer.

Example use:

Source example code from the Google Maps Support page for the Directions API. Remember to include your API Key in your code.
In the Open or Shown event of the WebHTMLViewer:

Var url As String = "your sample Directions code here" HTMLViewer1.LoadPage(url)

I hope that helps.

Kind regards, Andrew[/quote]

Thanks Andrew for a brilliant reply.