Use google maps in desktop applications

By | March 11, 2012

Google maps is a popular geomap service used by many sites to display maps and locations. The api provides javascript code to integrate itself into any website.

It is now possible to use google maps in desktops applications. Check Terms for more information. For this a browser has to be embedded in the desktop application.

Here is a desktop application made in c++ that uses google maps.

Google map in a desktop application

The application is called Turbotrace and can be downloaded from here.

It uses an embedded browser (IE rendering engine Trident) and loads up html code for showing google maps just like it should be done on a webpage. The only difference is that google will allow to load the map even if the "request" comes from a non-website referer.

The code as usual is simple :

<body onload="load()" onunload="GUnload()" >
	<div id="map" style="height:100%; width:100%;"></div>
	<script type="text/javascript" src=""></script>
	<script type="text/javascript">
		var map = false;
		//load google map
		function load() 
			var myOptions = 
				center: new google.maps.LatLng(22, 88),
				zoom: 2,
				mapTypeId: google.maps.MapTypeId.ROADMAP
			map = new google.maps.Map( document.getElementById("map") , myOptions);
			document.getElementById("map").google = google;

You can just put the above code in a html file on your desktop and open it , and it should load the google maps , and you can move around in it.

So all that the desktop application needs to do is to load this html file in an embedded browser. An api key can be generated from the API Console at ( You need an api key for Google Maps V3 service. You need to create a "Server Key" without any IP restriction. So this key will allow accessing google maps service from "any ip" machines and desktops are a part of it.

There are different options to integrate a browser in your app depending on the language , api and libraries being used. The above application Turbotrace is build using wxWidgets GUI library and it provides a widget to embed webbrowser. Similar things are available in libraries like MFC , C#.NET , Java etc.
You need to research out the best library for your application and you are done. Most of them should allow executing javascript in the web browser. So you can do things like adding markers etc from within the application.

About Silver Moon

A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected].

3 thoughts on “Use google maps in desktop applications

  1. binta

    Will the map be loaded if there is no internet connection? If we are using embedded browser component,do we need internet?

  2. Guerzize Brahim

    Thanks, works fine; but how to put a marker ? and is it possible to draw a polygone to define a spécific region ?

Leave a Reply to Silver Moon Cancel reply

Your email address will not be published. Required fields are marked *