This project demonstrates a quick and easy way to add mapping to a windows desktop application (with an available internet connection) using Google Maps as the basis and source for the map.
The demonstration application will map a point by either its physical address or its latitude and longitude. Building the application does not require any sort of agreement or licensing with Google; there is no required API to invoke and using this approach it really won’t take more than a few minutes to put a map into your Visual Basic 2005 built desktop application.
Since the application is based entirely on Google Maps, as an added bonus, the Google Maps site provides all of the view manipulation controls necessary to navigate the map; so with no additional effort you pick up panning and zooming, traffic maps, street maps, raster imagery, and hybrid maps combining street maps with raster. You even get an overview map, the ability to print the map, email it, or link to it at no extra charge.
One could also remove the interface and feed specific addresses or coordinates directly to equivalent code and access specific maps directly through a web browser control.
Getting Started
The solution contains a single project for a Windows desktop application. The project is called “VB_QuickMap” and this project contains one form. The form contains all of the controls and code necessary to request and display a map from the Google Maps site.
Form 1 contains a split panel control oriented horizontally; the top pane contains the controls used to enter the search terms. There are two sets of controls in this panel; the first set will collect an address in the form of the street, city, state, and zip code (5 digits). The second set of controls will collect a latitude and longitude. Both sets of controls have buttons; the click event handlers for these buttons are used to construct a query string used to retrieve the map based on either the address or coordinates supplied by the user.
The bottom pane of the control contains a panel with a web browser control docked into it. The query string is appended to the basic URL used to query Google Maps; the combined string is set as the navigation URL property for the web browser control.
This article was intended to demonstrate a very simple approach to integrating maps into a desktop application (so long as the desktop application user has a viable internet connection). Since the application operates against a public website, there is no requirement for licensing the application or its users; of course there is also no guarantee that the URL and query string will not change at some point in the future.
Attachments
File | Uploaded | Size |
---|---|---|
930-20180210-062842-GoogleMapInYourApp.zip | 2/10/2018 6:28:42 AM | 4617 |