I want to create a program in VB.NET2005 windows application which will show google map on the form along with its contols of zoom.
OR
Also an image on form having zoomin and zoomout buttons.
Please Help!!!!
You can do this two different ways as I see it, both involving using a WebBrowser control. When you go to http://maps.google.com/ there is a 'link to this page' where you can copy the provided Html and paste into your own webpage document, this may also be a local file, for example:
If you save this to googlemap.html file you can navigate the control to it:
VB.NET:
Dim path As String = IO.Path.Combine(Application.StartupPath, "googlemap.html")
Me.WebBrowser1.Navigate(path)
It would look similar to this:
Another option is creating your own page with a map object and interacting with the Google Maps API through Javascript, once you have set up a page you can load it into WebBrowser control and interact with it from client application. The keys to this webpage-client interaction is the ObjectForScripting property where you can let JS access a COM object from your application, and HtmlElement.InvokeMember method where you can run JS functions in the page. (or HtmlDocument.InvokeScript)
I found an excellent example of doing this from this ComponentOne sample, Using C1Ribbon as an Interface to Google Maps, and took the liberty to write a VB.Net translation for educational purposes from the C# sample there. Check out the attached project, it is using the ComponentOne map, but ordinary .Net controls and not the nice control set they have. If they decide to move the map I've also included the source code for Html/JS in componentone.com.map.html file in zip package, you should examine this closely anyway to learn how it is done. It is not difficult to set up a map page like this on your own homepage. (you have to sign up for your own Google API key to use).
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.