[SOLVED]GeoHelper plugin - doesn't work?
-
Hey all,
I added recently the GeoHelper plugin to make it easier to work with ovi maps api requests:
"GEO HELPER PLUGIN":http://www.developer.nokia.com/Community/Wiki/QML_Geohelper_Plugin
Issue is - though I can refer to it in QML without problems via:
@GeoHelper {
id: geohelper
}@
it is just not working when I am trying to use some of the methods it provides like:geohelper.findCoordinates("street", "city", "country") // tried many combinations of real streets & cities
geohlper.findAddress(Latitude, Longitude) // same here tried a lotalso tried addressing other functions and always results in undefined or insufficient parameters.
What's wrong? did something change in Location module that the plugin is not working now?(btw I am using simulator at the moment not sure if it is important as I hope it works in it)
-
Well one thing I found working:
if map object is defined in QML e.g.
@GeoHelper {
id: geohelper
map: mymapobject
}@I succeeded in placing a text on the map via geohelper.drawText(id, latitude, longitude, "MYTEXT")
But I wonder how geocoding and reversegeo coding work...
-
Hmm seems like geo things are not popular topic;)
Could someone sanity check the code below I am using for the geohelper plugin?
Here is source code for ReverseGeo in source file:
@#include "geohelper.h"
#include <QScriptEngine>
#include <QScriptValue>
#include <QScriptValueIterator>#include <QDeclarativeListReference>
#include <QGeoMapRouteObject>GeoHelper::GeoHelper(QObject *parent) :
QObject(parent)
{
provider = new QGeoServiceProvider("nokia");
mappingManager = provider->mappingManager();
searchManager = provider->searchManager();
routingManager = provider->routingManager();
mapitem = NULL;QObject::connect(searchManager, SIGNAL(error(QGeoSearchReply *, QGeoSearchReply::Error, QString)), this, SLOT(searchErrorSlot(QGeoSearchReply *, QGeoSearchReply::Error, QString))); QObject::connect(searchManager, SIGNAL(finished(QGeoSearchReply*)), this, SLOT(searchFinishedSlot(QGeoSearchReply*))); QObject::connect(routingManager, SIGNAL(error(QGeoRouteReply*, QGeoRouteReply::Error, QString)), this, SLOT(routingErrorSlot(QGeoRouteReply*, QGeoRouteReply::Error, QString))); QObject::connect(routingManager, SIGNAL(finished(QGeoRouteReply*)), this, SLOT(routingFinishedSlot(QGeoRouteReply*)));
}
GeoHelper::~GeoHelper()
{
clearMap();if (provider) { delete provider; provider = NULL; }
}
void GeoHelper::findAddress(double latitude, double longitude)
{
QGeoCoordinate location(latitude,longitude);
searchManager->reverseGeocode(location);
}@Here is the header file:
@#ifndef GEOHELPER_H
#define GEOHELPER_H#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>QTM_USE_NAMESPACE
class GeoHelper : public QObject
{
Q_OBJECT
Q_PROPERTY(QDeclarativeItem* map READ map WRITE setMap)
public:
explicit GeoHelper(QObject *parent = 0);
~GeoHelper();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);
signals:
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);
private:
QGeoServiceProvider* provider; QGeoMappingManager* mappingManager; QGeoSearchManager* searchManager; QGeoRoutingManager* routingManager; QDeclarativeContext* context; QDeclarativeItem* mapitem; QMap<QString, QGeoMapObject *> mapobjects; QDeclarativeListReference listRef;
};
#endif // GEOHELPER_H@
Now here is my QML snippet:
@GeoHelper {
id: geohelper
map: qmlmap
}@I address it with the following to reverse geo GPS coordinates:
geohelper.findAddress(51.12,35.45)
I also tried to "read" the searchReply via geohelper.searchReply but it returns [object Object] to me...
Sorry I am noob to C++ and just trying to make sure the plugin works..
-
Hi,
You can find more information how to use geohelper from Forum Nokia Projects Wiki.
https://projects.developer.nokia.com/carpool/wiki/WikiStart see end of page or files tab
Geohelper is used in Carpool application, you can install .sis file or compile project and test it in real environment. See first Carpool Quick Guide
Following files include geohelper functionalities:
geohelper.cpp
main.cpp
MapView.qml-Kari-