Qt sample application: Google maps
In this article we will see how can we display location on Map using Qt and Google Map API
Article Metadata
Code Example
Article
Idea and Implementation
We will create an application using Qt Webkit and Google Map API to point a location and show it on the map.The application also has a Zoom In and Zoom Out feature. The application can also send the current searched coordinate information to a given number on Symbian platform S60 phones. Currently, it does not use the Mobility API to do so, but rather it directly uses Symbian APIs to send the short messages.
The application can also be successfully deployed to Maemo N900 devices as well. Attached please find the debian file for installation as well.
The application demos how to do a hybrid application using Qt C++, Javascript, html, jQuery etc.
The example code be easily compiled to a mini-Browser by defining the macro BROWSER the following line in the file "config.pri".
DEFINES+='''BROWSER''' <=== if it is defined, the app is compiled to be a browser
DEFINES+='''PHONE_EMU''' <=== on Windows, the size is resized to 640x360 to mimic the N97 phone size.
Please be noted that the following API:
QNetworkProxyFactory::setUseSystemConfiguration(true);
only exists from Qt 4.6.0 onwards. If the app runs within a network without a proxy, the line could be commented out. As such, it could be compiled with Qt 4.5.2 and Qt 4.5.3 releases.
Meanwhile, you are free to replace the line with:
QList<QNetworkProxy> list = QNetworkProxyFactory::systemProxyForQuery ( QNetworkProxyQuery ( QUrl("http://maps.google.com/") ) );
if( list.count() >= 1)
QNetworkProxy::setApplicationProxy ( list.at(0) );
As such, it could be successfully compiled using Qt releases prior to Qt 4.6.0.
Here are some of the captured pictures for the application:
If the application is compiled to be a browser (BROWSER macro should be defined), the screen shot is shown as follows:
A user is able to rotate the .gif pictures in the website by clicking the rotate icon. It is accomplished using jQuery. Meanwhile, a user may also go back and forward, zoom in/out of the web contents.
The sample code can be found at File:Maps.zip








Thank you for sharing your code with us. I can run and show Beijing Map on emulator. but when I change to another city, the emulator close. However, when I tried to load it onto N97 mini, it can run, but loading MAP process hang when it comes to 65%.
Is it because the GoogleKey and any other setting problem? If another google key is required, how to apply google key for phone?
Best Rgds.
zbc
U.E.T. App developers - problem
I could not get how to make above code compile and run. In Qt environment in which file of project which piece should be added can't get it moreover what should be application type.
regards
saniaU.E.T. App developers 12:49, 26 October 2012 (EEST)
Hamishwillee - Sania - use Nokia Maps for Qt
Hi Sania
I suggest you use the Nokia Maps for Qt - since they are actually supported by Nokia.
In the zip file, its the .pro file which is imported into the Qt Creator IDE (.pro = project file)
Regards
Hamishhamishwillee 05:49, 29 October 2012 (EET)
Linhdong24 - error:610
i met a prolerm when i search position in Maps. it report error:610 .linhdong24 07:54, 7 April 2013 (EEST)