Revision as of 12:01, 29 April 2011 by kpakarin (Talk | contribs)

QML Geohelper Plugin

From Nokia Developer Wiki
Jump to: navigation, search

Article Metadata
Tested with
Devices(s): ...
Platform(s): ...
Keywords: ...
Created: (29 Aug 2014)
Last edited: kpakarin (29 Apr 2011)

Delete the guidance text written in italics.


Geohelper plugin to expose Qt mobility location geoservice apis to Qml environment

This snippet can be self-signed.


Qt 4.7.1 or newer and Qt mobility 1.1.0 or newer installed

Pro file (optional)

The following capabilities and libraries are required:

CAPABILITY: symbian:TARGET.CAPABILITY = NetworkServices Location ReadUserData WriteUserData

Header file

geohelper.h applying this macro to definitions of member functions to allow them to be invoked via the meta-object system

#include <QObject>
#include <QMap>
#include <QGeoServiceProvider>
#include <QGeoMappingManager>
#include <QGeoSearchManager>
#include <QGeoRoutingManager>
#include <QDeclarativeEngine>
#include <QGeoRouteReply>
#include <QGeoRouteRequest>
#include <QGeoCoordinate>
#include <QDeclarativeItem>
#include <QGeoMapPolylineObject>
#include <QGeoMapPixmapObject>
#include <QGeoMapTextObject>
class GeoHelper : public QObject
Q_PROPERTY(QDeclarativeItem* map READ map WRITE setMap)
explicit GeoHelper(QObject *parent = 0);
QDeclarativeItem *map() const {return mapitem; }
void setMap(QDeclarativeItem *map) { mapitem = map; listRef = QDeclarativeListReference(mapitem, "objects");};
Q_INVOKABLE void findRoute(double fromLatitude, double fromLongitude, double toLatitude, double toLongitude);
Q_INVOKABLE void findAddress(double latitude, double longitude);
Q_INVOKABLE void findCoordinates(QString street, QString city, QString country = QString("FINLAND"));
Q_INVOKABLE void clearMap();
Q_INVOKABLE void removeFromMap(QString id);
Q_INVOKABLE void drawPolyline(QString id, QString coordinateArr);
Q_INVOKABLE void drawImage(QString id, double latitude, double longitude, QString imagepath, int xOffset, int yOffset);
Q_INVOKABLE void drawText(QString id, double latitude, double longitude, QString text);
Q_INVOKABLE void findObjectsInCoordinates(double latitude, double longitude);
void searchError(const QString &error);
void routingError(const QString &error);
void searchReply(const QString &reply);
void routingReply(const QString &reply);
void geomapobjectSelected(QString id, bool selected);
void debugMsg(const QString &reply);
private slots:
void searchErrorSlot(QGeoSearchReply *reply, QGeoSearchReply::Error error, QString errorString = QString());
void searchFinishedSlot(QGeoSearchReply *reply);
void routingErrorSlot(QGeoRouteReply *reply, QGeoRouteReply::Error error, QString errorString);
void routingFinishedSlot(QGeoRouteReply * reply);
QGeoServiceProvider* provider;
QGeoMappingManager* mappingManager;
QGeoSearchManager* searchManager;
QGeoRoutingManager* routingManager;
QDeclarativeContext* context;
QDeclarativeItem* mapitem;
QMap<QString, QGeoMapObject *> mapobjects;
QDeclarativeListReference listRef;
#endif // GEOHELPER_H

Source file

Not the complete file but relevant code blocks.

You do not need to provide complete error handling but it should be commented as TODO for developers.



Explain what the code snippet is expected to do.

Test application and other attachments (optional)

The attachments should be provided with the visible info page (Categories need to be defined, the attached file must be uploaded to Wiki, and internal Wiki links must be used). Every attachment should have its own page (however, a ZIP package can be used for multiple source code files).

115 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.