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







