Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Integrate G-MAP in VB.NET Windows Application without API

0.00/5 (No votes)
13 Nov 2014 1  
How to Integrate Google map in VB.NET without using any API in VB.NET Windows application

Introduction

WebBrowser ActiveX documents are embeddable OLE objects that behave more like ActiveX controls than traditional OLE objects. Unlike a traditional embedded object, an ActiveX document is not designed to be a contained object in a larger document. Instead, it is considered in itself a complete document that is merely being viewed (such as with Microsoft Internet Explorer) or collected in a single resource with other documents (such as a Microsoft Office Binder file). An ActiveX document that is hosted in the WebBrowser control is always active; therefore, unlike traditional OLE embedded objects, there is no sense of in-place activation.
For getting direction using source and destinations in Google map, we have to use following URL:

https://www.google.com/maps/dir/

  • google map identifies space as + e.g. :acb xyz replace space with + e.g. :abc+xyz
  • and next line with comma e.g. abc+xyz,czy.
  • To make difference between source and destination, separate by ‘/’. Then use string builder to append the URL to web browser control. Each and every thing is explained in code. Code declaration of string builder and other things.
Dim queryaddress As New System.Text.StringBuilder 
Dim sStreet As String = String.Empty 
Dim sCity As String = String.Empty 
Dim sState As String = String.Empty 
Dim sPincode As String = String.Empty 
Dim sProvider_no As String = String.Empty 

queryaddress.Append("https://www.google.com/maps/dir/") 

Append source address to string builder

If txtprovider_no.Text <> ""
Then sProvider_no = txtprovider_no.Text.Replace(" ", "+") 
queryaddress.Append(sProvider_no + "," & "+")
End If
If txtState.Text <> ""
Then sState = txtState.Text.Replace(" ", "+") 
queryaddress.Append(sState + "," & "+")
End If
If txtCity.Text <> ""
Then sCity = txtCity.Text.Replace(" ", "+") 
queryaddress.Append(sCity + "," & "+")
End If

Append / for destination

queryaddress.Append("/")

Append destination address to string builder

sStreet = String.Empty
sCity = String.Empty
sState = String.Empty
sPincode = String.Empty

If ttxtclient_city.Text <> "" 
Then sPincode = ttxtclient_city.Text.Replace(" ", "+")
 queryaddress.Append(sPincode)
End If
If txtclient_state.Text <> "" 
Then sState = txtclient_state.Text.Replace(" ", "+") 
queryaddress.Append(sState + "," & "+")
End If

Last append URL to web browser control

WebBrowser.Navigate(queryaddress.ToString()) 

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here