QReverseGeocode component for quick reverse geocoding in QML
m (Galazzo - - →QML) |
hamishwillee
(Talk | contribs) m (Text replace - "<code cpp>" to "<code cpp-qt>") |
||
| (3 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
| − | [[Category:Qt]][[Category:Qt Mobility]][[Category:Qt Quick]][[Category:Location]][[Category:Code Examples]][[Category:Nokia Maps]][[Category:MeeGo]] | + | [[Category:Qt]][[Category:Qt Mobility]][[Category:Qt Quick]][[Category:Location]][[Category:Code Examples]][[Category:Nokia Maps]][[Category:MeeGo Harmattan]] |
{{ArticleMetaData <!-- v1.2 --> | {{ArticleMetaData <!-- v1.2 --> | ||
|sourcecode= [https://projects.developer.nokia.com/QReverseGeocode QReverseGeocode] Nokia Project | |sourcecode= [https://projects.developer.nokia.com/QReverseGeocode QReverseGeocode] Nokia Project | ||
| Line 7: | Line 7: | ||
|platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later --> | |platform= <!-- Compatible platforms - e.g. Symbian^1 and later, Qt 4.6 and later --> | ||
|devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) --> | |devicecompatability= <!-- Compatible devices e.g.: All* (must have internal GPS) --> | ||
| − | |dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 --> | + | |dependencies= <!-- Any other/external dependencies e.g.: Google Maps Api v1.0 --> |
| − | |signing=<!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer --> | + | |signing= <!-- Signing requirements - empty or one of: Self-Signed, DevCert, Manufacturer --> |
|capabilities= NetworkServices | |capabilities= NetworkServices | ||
|keywords= Reverse Geocode | |keywords= Reverse Geocode | ||
|language= <!-- Language category code for non-English topics - e.g. Lang-Chinese --> | |language= <!-- Language category code for non-English topics - e.g. Lang-Chinese --> | ||
|translated-by= <!-- [[User:XXXX]] --> | |translated-by= <!-- [[User:XXXX]] --> | ||
| − | |translated-from-title= <!-- Title only --> | + | |translated-from-title= <!-- Title only --> |
|translated-from-id= <!-- Id of translated revision --> | |translated-from-id= <!-- Id of translated revision --> | ||
| − | |review-by=<!-- After re-review: [[User:username]] --> | + | |review-by= <!-- After re-review: [[User:username]] --> |
|review-timestamp= <!-- After re-review: YYYYMMDD --> | |review-timestamp= <!-- After re-review: YYYYMMDD --> | ||
|update-by= <!-- After significant update: [[User:username]]--> | |update-by= <!-- After significant update: [[User:username]]--> | ||
| Line 29: | Line 29: | ||
== Introduction == | == Introduction == | ||
Reverse geocoding is the process of back (reverse) coding of a point location (latitude, longitude) to a readable address or place name. This permits the identification of nearby street addresses, places, and/or areal subdivisions such as neighbourhoods, county, state, or country. Combined with geocoding and routing services, reverse geocoding is a critical component of mobile location-based services.<br /> | Reverse geocoding is the process of back (reverse) coding of a point location (latitude, longitude) to a readable address or place name. This permits the identification of nearby street addresses, places, and/or areal subdivisions such as neighbourhoods, county, state, or country. Combined with geocoding and routing services, reverse geocoding is a critical component of mobile location-based services.<br /> | ||
| − | Nokia provides one of the best location based services available and reverse geocoding is well supported in Qt/C++ and HTML5, but | + | Nokia provides one of the best location based services available and reverse geocoding is well supported in Qt/C++ and HTML5, but sometimes could be tricky to access this service from QML.<br /> |
QReverseGeocode provide a quick and easy solution to manage reverse geocoding from QML. | QReverseGeocode provide a quick and easy solution to manage reverse geocoding from QML. | ||
| Line 37: | Line 37: | ||
=== .pro === | === .pro === | ||
| − | <code cpp> | + | <code cpp-qt> |
include(./qreversegeocode/reversegeocode.pri) | include(./qreversegeocode/reversegeocode.pri) | ||
</code> | </code> | ||
=== main.cpp === | === main.cpp === | ||
| − | <code cpp> | + | <code cpp-qt> |
#include <QtGui/QApplication> | #include <QtGui/QApplication> | ||
#include "qmlapplicationviewer.h" | #include "qmlapplicationviewer.h" | ||
Revision as of 04:17, 11 October 2012
Article Metadata
Code Example
Tested with
Platform Security
Article
See Also
- Location API (Qt reference)
- QGeoSearchManager (Qt reference)
- QGeoServiceProvider (Qt reference)
Contents |
Introduction
Reverse geocoding is the process of back (reverse) coding of a point location (latitude, longitude) to a readable address or place name. This permits the identification of nearby street addresses, places, and/or areal subdivisions such as neighbourhoods, county, state, or country. Combined with geocoding and routing services, reverse geocoding is a critical component of mobile location-based services.
Nokia provides one of the best location based services available and reverse geocoding is well supported in Qt/C++ and HTML5, but sometimes could be tricky to access this service from QML.
QReverseGeocode provide a quick and easy solution to manage reverse geocoding from QML.
Installation
- Download source code from here
- Include QReverseGeocode directory into your project
.pro
include(./qreversegeocode/reversegeocode.pri)
main.cpp
#include <QtGui/QApplication>
#include "qmlapplicationviewer.h"
#include <QtDeclarative>
#include "qreversegeocode.h"
Q_DECL_EXPORT int main(int argc, char *argv[])
{
QScopedPointer<QApplication> app(createApplication(argc, argv));
qmlRegisterType<QReverseGeocode>("QReverseGeocode", 1, 0, "QReverseGeocode");
QmlApplicationViewer viewer;
viewer.setMainQmlFile(QLatin1String("qml/QReverseGeocodeSample/main.qml"));
viewer.showExpanded();
return app->exec();
}
QML
import QtQuick 1.1
import com.nokia.symbian 1.1
import QtWebKit 1.0
import QtMobility.location 1.2
import QReverseGeocode 1.0
Page {
id: mainPage
Text {
id: place
text: ""
}
PositionSource {
id: positionSource
active: true
onPositionChanged: {
reverseGeocoder.latitude = positionSource.position.coordinate.latitude
reverseGeocoder.longitude = positionSource.position.coordinate.longitude
reverseGeocoder.process();
}
}
QReverseGeocode {
id:reverseGeocoder
onReverseGeocodeFinished:{
place.text=reverseGeocoder.postCode+" "+reverseGeocoder.city
}
}
}
API Reference
Properties ( To use before calling process() )
- latitude - Property that hold the latitude value
- longitude - Property that hold the longitude value
Properties ( Filled when onReverseGeocodeFinished() is emitted )
- city - Property that hold the city value
- postCode - Property that hold post code value
- street - Property that hold the street value
- country - Property that hold the country value
Signals (handlers)
- onLatitudeChanged() - Invoked when latitude property changes.
- onLongitudeChanged() - Invoked when the longitude changes.
- onReverseGeocodeFinished() - Invoked when the reverse geocode process is finished.
Slots
- process() - Start the reverse geocoding process. Before calling this method the latitude and longitude properties have to be filled.
onReverseGeocodeFinished
When onReverseGeocodeFinished() is emitted all address informations are stored into the properties described before, so you can compose your informations in the way you need. For example you could need to display just post code and city:
onReverseGeocodeFinished:{
place.text=reverseGeocoder.postCode+" "+reverseGeocoder.city
}
or just city and country:
onReverseGeocodeFinished:{
place.text=reverseGeocoder.city+" "+reverseGeocoder.country
}
rather than all informations:
onReverseGeocodeFinished:{
place.text=reverseGeocoder.street+"<br/>"+reverseGeocoder.postCode+" "+reverseGeocoder.city+"<br/>"+reverseGeocoder.country
}

