123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- /********************************************************************************************
- ** Copyright © 2011 Nokia Corporation. All rights reserved.
- ** Nokia and Nokia Connecting People are registered trademarks of Nokia Corporation.
- ** Java and all Java-based marks are trademarks or registered trademarks of
- ** Sun Microsystems, Inc. Other product and company names mentioned herein may be
- ** trademarks or trade names of their respective owners.
- **
- ** Subject to the conditions below, you may, without charge:
- **
- ** · Use, copy, modify and/or merge copies of this software and
- ** associated content and documentation files (the “Software”)
- **
- ** · Publish, distribute, sub-licence and/or sell new software
- ** derived from or incorporating the Software.
- **
- ** Some of the documentation, content and/or software maybe licensed under open source
- ** software or other licenses. To the extent such documentation, content and/or
- ** software are included, licenses and/or other terms and conditions shall apply
- ** in addition and/or instead of this notice. The exact terms of the licenses, disclaimers,
- ** acknowledgements and notices are reproduced in the materials provided.
- **
- ** This file, unmodified, shall be included with all copies or substantial portions
- ** of the Software that are distributed in source code form.
- **
- ** The Software cannot constitute the primary value of any new software derived
- ** from or incorporating the Software.
- **
- ** Any person dealing with the Software shall not misrepresent the source of the Software.
- **
- ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- ** INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
- ** PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
- ** HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
- ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- ** SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- ********************************************************************************************/
- #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
|