Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.

Maps and Navigation API: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
==Qt Mobility 1.1 Features==
[toc align_right="yes" depth="3"]


[http://labs.qt.nokia.com/2011/05/04/qt-4-7-3-and-qt-mobility-1-1-3-have-been-released/ Qt Mobility 1.1.3 Release] ''[labs.qt.nokia.com]'' is available now for commercial app development and deployment on Ovi store.<br />[http://labs.qt.nokia.com/2011/05/12/qt-mobility-1-2-0-released/ Qt Mobility 1.2.0 release] ''[labs.qt.nokia.com]'' is available now.
== Qt Mobility 1.1 Features ==


=Maps and Navigation <span class="caps">API</span>=
&quot;Qt Mobility 1.1.3 Release&amp;quot;:http://labs.qt.nokia.com/2011/05/04/qt-4-7-3-and-qt-mobility-1-1-3-have-been-released/ is available now for commercial app development and deployment on Ovi store.<br />&quot;Qt Mobility 1.2.0 release&amp;quot;:http://labs.qt.nokia.com/2011/05/12/qt-mobility-1-2-0-released/ is available now.


==Summary==
= Maps and Navigation API =


The Maps and Navigation <span class="caps">API</span> provides access to mapping, routing and geocoding services.
== Summary ==


The <span class="caps">API</span> is designed so that the core functionality it provided by a plugin. Qt Mobility will ship with a plugin that accesses Nokia services by default but there should be nothing to stop someone from writing plugins that work with other services (provided that we designed the <span class="caps">API</span> correctly).
The Maps and Navigation API provides access to mapping, routing and geocoding services.


What we have at the moment should give you some idea of what we’re aiming at in terms of functionality offered and the <span class="caps">API</span> which provides access to it.
The API is designed so that the core functionality it provided by a plugin. Qt Mobility will ship with a plugin that accesses Nokia services by default but there should be nothing to stop someone from writing plugins that work with other services (provided that we designed the API correctly).


The current code can be viewed as a draft of the <span class="caps">API</span> which we’ll be releasing. We have applied some of the <span class="caps">API</span> review feedback although there are still some changes which will still have to make, and there is some additional functionality we’d like to add to the <span class="caps">API</span>, so some of the classes and methods might be renamed between now and the release.
What we have at the moment should give you some idea of what we're aiming at in terms of functionality offered and the API which provides access to it.


==Functionality==
The current code can be viewed as a draft of the API which we'll be releasing. We have applied some of the API review feedback although there are still some changes which will still have to make, and there is some additional functionality we'd like to add to the API, so some of the classes and methods might be renamed between now and the release.


Since most providers of mapping, routing and geocoding information offer no guarantees that their data is interoperable with the data provided by other services, the plugins are used to group the functionality per service provider. This doesn’t mean that you can’t mix and match your sources of data, although it’s a hint from us that you may want to be really sure that the “matching” part is done with care.
== Functionality ==


Plugin are loaded using the <code>QGeoServiceProvider</code> class, which give access to instances of the classes reponsible for each area of functionality in the <span class="caps">API</span>.
Since most providers of mapping, routing and geocoding information offer no guarantees that their data is interoperable with the data provided by other services, the plugins are used to group the functionality per service provider. This doesn't mean that you can't mix and match your sources of data, although it's a hint from us that you may want to be really sure that the &quot;matching&amp;quot; part is done with care.


For the communications with the routing and search services we borrowed quite a bit of <span class="caps">API</span> from the Qt Network module.
Plugin are loaded using the &lt;code&amp;gt;QGeoServiceProvider&amp;lt;/code&amp;gt; class, which give access to instances of the classes reponsible for each area of functionality in the API.


The QGeoRoutingManager and QGeoSearchManager classes have methods which return QGeoRouteReply and QGeoSearchReply instances respectively, in the same way that QNetworkAccessManager returns QNetworkReply instances, and those classes are heavily influences by QNetworkReply. The class documentation for the QGeoRoutingManager and QGeoSearchManager contain example code which should help users get started in these areas.
<code>QGeoMappingManager *mappingManager = 0;<br />QGeoRoutingManager *routingManager = 0;<br />QGeoSearchManager *searchManager = 0;


===Maps===
QGeoServiceProvider serviceProvider(&quot;nokia&amp;quot;);


The class at the center of the mapping functionality is <code>QGeoMapWidget</code>. This will be renamed before the beta release since it’s not a widget at all.
if (serviceProvider.error() == QGeoServiceProvider::NoError) {<br /> mappingManager = serviceProvider.mappingManager();<br /> routingManager = serviceProvider.routingManager();<br /> searchManager = serviceProvider.searchManager();<br />}</code>


You can get hold of an instance of QGeoMapWidget with:<br />
For the communications with the routing and search services we borrowed quite a bit of API from the Qt Network module.


The widget instance allows the user to
The QGeoRoutingManager and QGeoSearchManager classes have methods which return QGeoRouteReply and QGeoSearchReply instances respectively, in the same way that QNetworkAccessManager returns QNetworkReply instances, and those classes are heavily influences by QNetworkReply. The class documentation for the QGeoRoutingManager and QGeoSearchManager contain example code which should help users get started in these areas.


* set or get the coordinate at the center of the map
=== Maps ===
* set or get the zoom level
 
* set or get the map type (street map, satellite map, etc…)
The class at the center of the mapping functionality is &lt;code&amp;gt;QGeoMapWidget&amp;lt;/code&amp;gt;. This will be renamed before the beta release since it's not a widget at all.
* pan the map
 
* convert between coordinates and positions on the screen
You can get hold of an instance of QGeoMapWidget with:<br /><code>QGeoMapWidget '''widget = new QGeoMapWidget(mappingManager);<code>
* add, remove and retrieve map objects
<br />The widget instance allows the user to<br />''' set or get the coordinate at the center of the map<br />* set or get the zoom level<br />* set or get the map type (street map, satellite map, etc…)<br />* pan the map<br />* convert between coordinates and positions on the screen<br />* add, remove and retrieve map objects<br />* get the minimum and maximum zoom levels supported by the mapping service<br />* get the map types supported by the mapping service
* get the minimum and maximum zoom levels supported by the mapping service
* get the map types supported by the mapping service


Multiple widgets can make use of the same QGeoMappingManager in the one application.
Multiple widgets can make use of the same QGeoMappingManager in the one application.


We’re not quite done with the map objects at the moment, but in the future they’ll include
We're not quite done with the map objects at the moment, but in the future they'll include<br />* a rectangle object<br />* a circle object (all points within a given distance of a center point)<br />* a polygon object<br />* a polyline object<br />* an image object for map markers<br />* possibly some others
 
* a rectangle object
* a circle object (all points within a given distance of a center point)
* a polygon object
* a polyline object
* an image object for map markers
* possibly some others


The MapsViewer example is available for those who’d like to see the code in action before diving in.
The MapsViewer example is available for those who'd like to see the code in action before diving in.


====Current status====
==== Current status ====


The Nokia plugin provides basic mapping functionality, although the performance is undergoing a major overhaul and the map objects are not complete.
The Nokia plugin provides basic mapping functionality, although the performance is undergoing a major overhaul and the map objects are not complete.


We haven’t finished the map objects yet.
We haven't finished the map objects yet.
 
We are looking at ways in which we might be able to allow users to specify map overlays, and are working on a set of convenience classes to form a tiled mapping <span class="caps">API</span> in order to assist plugin implementers who are working with tile-based mapping services.


We have some work to do before we’re ready for vector based mapping services, but it’s on our list.
We are looking at ways in which we might be able to allow users to specify map overlays, and are working on a set of convenience classes to form a tiled mapping API in order to assist plugin implementers who are working with tile-based mapping services.


===Routing===
We have some work to do before we're ready for vector based mapping services, but it's on our list.


Routes can be calculated using<br />
=== Routing ===


The QGeoRouteRequest class contains:
Routes can be calculated using<br /></code>QGeoRouteReply* QGeoRoutingManager::calculateRoute(const QGeoRouteRequest &amp;amp;request)</code>


* the waypoints of the route
The QGeoRouteRequest class contains:<br />* the waypoints of the route<br />* the number of alternative routes to provide<br />* the travel mode (or modes)<br />'''''' Car, Pedestrian, Bicycle, PublicTransit, Truck<br />* the route optimization to use<br />'''''' Shortest, Fastest, MostEconomic, MostScenic<br />* the features to avoid<br />'''''' Tolls, Highways, etc<br />* geographic areas to exclude from the route<br />* whether to retrieve the route segment information<br />* whether to retrueve the navigation instruction information
* the number of alternative routes to provide
* the travel mode (or modes)
** Car, Pedestrian, Bicycle, PublicTransit, Truck
* the route optimization to use
** Shortest, Fastest, MostEconomic, MostScenic
* the features to avoid
** Tolls, Highways, etc
* geographic areas to exclude from the route
* whether to retrieve the route segment information
* whether to retrueve the navigation instruction information


The QGeoRoutingManager instance has a related set of functions which can be used to determine whether the service supports a particular feature or constraint.
The QGeoRoutingManager instance has a related set of functions which can be used to determine whether the service supports a particular feature or constraint.
Line 87: Line 66:
The QGeoRouteReply instance returned by calculateRoute() will contain one or more QGeoRoute instances, depending on whether alternative routes were requested.
The QGeoRouteReply instance returned by calculateRoute() will contain one or more QGeoRoute instances, depending on whether alternative routes were requested.


The routing information may contain a number of instructions to be issued at various locations along the route these instructions are described by the QGeoNavigationInstruction class.
The routing information may contain a number of instructions to be issued at various locations along the route - these instructions are described by the QGeoNavigationInstruction class.


We break the route up into a number of QGeoRouteSegment instances which correspond to the segments of the route which occur between two consecutive instructions.
We break the route up into a number of QGeoRouteSegment instances which correspond to the segments of the route which occur between two consecutive instructions.


The QGeoRoute class contains summary information for the route:
The QGeoRoute class contains summary information for the route:<br />* the estimated travel time for the route<br />* the estimated total distance covered by the route<br />* a route ID, for use when updating the route<br />* a geographical bounding box for the route<br />* the travel mode used by the route<br />as well as a list of QGeoRouteSegment instances


* the estimated travel time for the route
The QGeoRouteSegment contains:<br />* the estimated travel time for the route<br />* the estimated total distance covered by the route<br />* a list of QGeoCoordinates which defines the path taken by the route segment<br />* a QGeoNavigationInstruction instance<br />and the QGeoNavigationInstruction contains:<br />* the instruction text<br />* the distance and time to the next instruction<br />* the position of the instruction<br />'''''' this might be before the end of the corresponding segment<br />''''''* especially if the speed limit is high
* the estimated total distance covered by the route
* a route ID, for use when updating the route
* a geographical bounding box for the route
* the travel mode used by the route<br /> as well as a list of QGeoRouteSegment instances
 
The QGeoRouteSegment contains:
 
* the estimated travel time for the route
* the estimated total distance covered by the route
* a list of QGeoCoordinates which defines the path taken by the route segment
* a QGeoNavigationInstruction instance<br /> and the QGeoNavigationInstruction contains:
* the instruction text
* the distance and time to the next instruction
* the position of the instruction
** this might be before the end of the corresponding segment
*** especially if the speed limit is high


We plan to provide a QGeoMapObject subclass to assist with displaying routes on maps soon.
We plan to provide a QGeoMapObject subclass to assist with displaying routes on maps soon.


====Current status====
==== Current status ====


The Nokia plugin provides routing functionality.
The Nokia plugin provides routing functionality.
Line 121: Line 84:
The ability to specify features to avoid will probably be enhanced in order to support more fine-grained preferences with regard to features.
The ability to specify features to avoid will probably be enhanced in order to support more fine-grained preferences with regard to features.


===Geocoding and places searching===
=== Geocoding and places searching ===


Geocoding and reverse geocoding are used to convert between address and coordinates:<br />
Geocoding and reverse geocoding are used to convert between address and coordinates:<br /><code>QGeoSearchReply* QGeoSearchManager::geocode(const QGeoCoordinate &amp;amp;coordinate,<br /> const QGeoBoundingBox &amp;amp;boundingBox = QGeoBoundingBox());<br />QGeoSearchReply* QGeoSearchManager::geocode(const QGeoAddress &amp;amp;address,<br /> const QGeoBoundingBox &amp;amp;boundingBox = QGeoBoundingBox());</code>


The QGeoSearchReply class contains a list of QGeoPlace instances, each of which contains a coordinate, and address and an optional bounding box. We return both pieces of information as the address or coordinate that was used in the geocode() function may be slightly different from the corresponding address or coordinate in the reply.
The QGeoSearchReply class contains a list of QGeoPlace instances, each of which contains a coordinate, and address and an optional bounding box. We return both pieces of information as the address or coordinate that was used in the geocode() function may be slightly different from the corresponding address or coordinate in the reply.


The optional bounds parameters is used to limit the results to those within a certain geographical area usually the area corresponding to what a user has in their map viewport. When converting from address to coordinate the bounds parameter is most useful when a partially filled out address object is used a QGeoAddress with city set to “London” could represent London, Great Britain or London, Kentucky, <span class="caps">USA</span>.
The optional bounds parameters is used to limit the results to those within a certain geographical area - usually the area corresponding to what a user has in their map viewport. When converting from address to coordinate the bounds parameter is most useful when a partially filled out address object is used - a QGeoAddress with city set to &quot;London&amp;quot; could represent London, Great Britain or London, Kentucky, USA.


When converting from coordinate to address some geocoding services will give the coordinate/address pairs at multiple levels of detail for the street address, the suburb, the city, the state and the country and the bounds parameter can be used to limit that behaviour.
When converting from coordinate to address some geocoding services will give the coordinate/address pairs at multiple levels of detail - for the street address, the suburb, the city, the state and the country - and the bounds parameter can be used to limit that behaviour.


These functions will only work if <br /> returns true.
These functions will only work if<br /><code>bool QGeoSearchManager::supportsGeocoding() const<code><br />returns true.


To do a free text search, use:<br />
To do a free text search, use:<br /></code>QGeoSearchReply* QGeoSearchManager::placeSearch(const QString &amp;amp;searchString,<br /> SearchTypes searchTypes = SearchTypes( SearchAll ),<br /> const QGeoBoundingBox &amp;amp; bounds = QGeoBoundingBox());<code>


The searchTypes parameter is used to specify whether searchString is to be used for geocoding (in which case it will be treated as an address), for landmarks searching (in which case it will be used to search the services landmarks database) or both.
The searchTypes parameter is used to specify whether searchString is to be used for geocoding (in which case it will be treated as an address), for landmarks searching (in which case it will be used to search the services landmarks database) or both.


The values of searchType supported by the plugin can be found with:<br />
The values of searchType supported by the plugin can be found with:<br /></code>SearchTypes QGeoSearchManager::supportedSearchTypes()</code>


The return type for this method is still a list of QGeoPlace objects. The QLandmark class from the Landmarks <span class="caps">API</span> is a subclass of QGeoPlace, and users can check QGeoPlace instances to see if they’re actually QLandmark instances and make a conversion from a QGeoPlace instance to a QLandmark instance if necessary.
The return type for this method is still a list of QGeoPlace objects. The QLandmark class from the Landmarks API is a subclass of QGeoPlace, and users can check QGeoPlace instances to see if they’re actually QLandmark instances and make a conversion from a QGeoPlace instance to a QLandmark instance if necessary.


The user can also specify additional QLandmarkManager instances to be used with QGeoSearchManager. This can be used so that a single search can make use of the plugins landmark database and a users personal landmark database at the same time.
The user can also specify additional QLandmarkManager instances to be used with QGeoSearchManager. This can be used so that a single search can make use of the plugins landmark database and a users personal landmark database at the same time.


For more involved handling of landmarks, the Qt Mobility Landmarks <span class="caps">API</span> should be used.
For more involved handling of landmarks, the Qt Mobility Landmarks API should be used.


====Current status====
==== Current status ====


The Nokia plugin provides geocoding and reverse geocoding, but does not search online landmark databases at present.
The Nokia plugin provides geocoding and reverse geocoding, but does not search online landmark databases at present.


We still need to work out the best way to do paging, in order to handle the case where someone searches for landmarks containing the text “the”. The current method (return them all) is not exactly network friendly.
We still need to work out the best way to do paging, in order to handle the case where someone searches for landmarks containing the text &quot;the&amp;quot;. The current method (return them all) is not exactly network friendly.


We also need to write the code to combine the placeSearch results from the plugin implementation and from the additional landmark managers.
We also need to write the code to combine the placeSearch results from the plugin implementation and from the additional landmark managers.


==Writing a new plugin==
== Writing a new plugin ==


A plugin implementer needs to subclass QGeoServiceProviderFactory.
A plugin implementer needs to subclass QGeoServiceProviderFactory.
Line 161: Line 124:
The plugin implementer should subclass QGeoMappingManagerEngine, QGeoRoutingManagerEngine and QGeoSearchManagerEngine in order to provide the requried functionality, and should take care to set the various metadata associated with each so that clients of the plugin can determine the specific capabilities of any particular plugin. See the class documentation for more informaiton.
The plugin implementer should subclass QGeoMappingManagerEngine, QGeoRoutingManagerEngine and QGeoSearchManagerEngine in order to provide the requried functionality, and should take care to set the various metadata associated with each so that clients of the plugin can determine the specific capabilities of any particular plugin. See the class documentation for more informaiton.


==Example applications==
== Example applications ==


There are two example applications provided.
There are two example applications provided.


The first is the [http://doc.qt.nokia.com/qtmobility/mapviewer.html Map Viewer example] ''[doc.qt.nokia.com]'', which demonstrates the Mapping functionality.
The first is the &quot;Map Viewer example&amp;quot;:http://doc.qt.nokia.com/qtmobility/mapviewer.html, which demonstrates the Mapping functionality.


Users can double click to center and zoom, drag to change position, and use the + and keys to change the zoom level. Right clicking will bring up a menu which can be used to add objects to the map.
Users can double click to center and zoom, drag to change position, and use the + and - keys to change the zoom level. Right clicking will bring up a menu which can be used to add objects to the map.


The second is QGeoAPIUI (which will be renamed soon) which demonstrates the routing and geocoding functionality.
The second is QGeoAPIUI (which will be renamed soon) which demonstrates the routing and geocoding functionality.
===Categories:===
* [[:Category:Developing with Qt|Developing_with_Qt]]
** [[:Category:Developing with Qt::QtMobility|QtMobility]]

Revision as of 09:45, 24 February 2015

[toc align_right="yes&quot; depth="3&quot;]

Qt Mobility 1.1 Features

"Qt Mobility 1.1.3 Release&quot;:http://labs.qt.nokia.com/2011/05/04/qt-4-7-3-and-qt-mobility-1-1-3-have-been-released/ is available now for commercial app development and deployment on Ovi store.
"Qt Mobility 1.2.0 release&quot;:http://labs.qt.nokia.com/2011/05/12/qt-mobility-1-2-0-released/ is available now.

Maps and Navigation API

Summary

The Maps and Navigation API provides access to mapping, routing and geocoding services.

The API is designed so that the core functionality it provided by a plugin. Qt Mobility will ship with a plugin that accesses Nokia services by default but there should be nothing to stop someone from writing plugins that work with other services (provided that we designed the API correctly).

What we have at the moment should give you some idea of what we're aiming at in terms of functionality offered and the API which provides access to it.

The current code can be viewed as a draft of the API which we'll be releasing. We have applied some of the API review feedback although there are still some changes which will still have to make, and there is some additional functionality we'd like to add to the API, so some of the classes and methods might be renamed between now and the release.

Functionality

Since most providers of mapping, routing and geocoding information offer no guarantees that their data is interoperable with the data provided by other services, the plugins are used to group the functionality per service provider. This doesn't mean that you can't mix and match your sources of data, although it's a hint from us that you may want to be really sure that the "matching&quot; part is done with care.

Plugin are loaded using the <code&gt;QGeoServiceProvider&lt;/code&gt; class, which give access to instances of the classes reponsible for each area of functionality in the API.

QGeoMappingManager *mappingManager = 0;<br />QGeoRoutingManager *routingManager = 0;<br />QGeoSearchManager *searchManager = 0;

QGeoServiceProvider serviceProvider(&quot;nokia&amp;quot;);

if (serviceProvider.error() == QGeoServiceProvider::NoError) {<br /> mappingManager = serviceProvider.mappingManager();<br /> routingManager = serviceProvider.routingManager();<br /> searchManager = serviceProvider.searchManager();<br />}

For the communications with the routing and search services we borrowed quite a bit of API from the Qt Network module.

The QGeoRoutingManager and QGeoSearchManager classes have methods which return QGeoRouteReply and QGeoSearchReply instances respectively, in the same way that QNetworkAccessManager returns QNetworkReply instances, and those classes are heavily influences by QNetworkReply. The class documentation for the QGeoRoutingManager and QGeoSearchManager contain example code which should help users get started in these areas.

Maps

The class at the center of the mapping functionality is <code&gt;QGeoMapWidget&lt;/code&gt;. This will be renamed before the beta release since it's not a widget at all.

You can get hold of an instance of QGeoMapWidget with:

QGeoMapWidget '''widget = new QGeoMapWidget(mappingManager);<code>
<br />The widget instance allows the user to<br />''' set or get the coordinate at the center of the map<br />* set or get the zoom level<br />* set or get the map type (street map, satellite map, etc)<br />* pan the map<br />* convert between coordinates and positions on the screen<br />* add, remove and retrieve map objects<br />* get the minimum and maximum zoom levels supported by the mapping service<br />* get the map types supported by the mapping service

Multiple widgets can make use of the same QGeoMappingManager in the one application.

We're not quite done with the map objects at the moment, but in the future they'll include<br />* a rectangle object<br />* a circle object (all points within a given distance of a center point)<br />* a polygon object<br />* a polyline object<br />* an image object for map markers<br />* possibly some others

The MapsViewer example is available for those who'd like to see the code in action before diving in.

==== Current status ====

The Nokia plugin provides basic mapping functionality, although the performance is undergoing a major overhaul and the map objects are not complete.

We haven't finished the map objects yet.

We are looking at ways in which we might be able to allow users to specify map overlays, and are working on a set of convenience classes to form a tiled mapping API in order to assist plugin implementers who are working with tile-based mapping services.

We have some work to do before we're ready for vector based mapping services, but it's on our list.

=== Routing ===

Routes can be calculated using<br />

QGeoRouteReply* QGeoRoutingManager::calculateRoute(const QGeoRouteRequest &amp;request)

The QGeoRouteRequest class contains:
* the waypoints of the route
* the number of alternative routes to provide
* the travel mode (or modes)
' Car, Pedestrian, Bicycle, PublicTransit, Truck
* the route optimization to use
'
Shortest, Fastest, MostEconomic, MostScenic
* the features to avoid
' Tolls, Highways, etc
* geographic areas to exclude from the route
* whether to retrieve the route segment information
* whether to retrueve the navigation instruction information

The QGeoRoutingManager instance has a related set of functions which can be used to determine whether the service supports a particular feature or constraint.

The QGeoRouteReply instance returned by calculateRoute() will contain one or more QGeoRoute instances, depending on whether alternative routes were requested.

The routing information may contain a number of instructions to be issued at various locations along the route - these instructions are described by the QGeoNavigationInstruction class.

We break the route up into a number of QGeoRouteSegment instances which correspond to the segments of the route which occur between two consecutive instructions.

The QGeoRoute class contains summary information for the route:
* the estimated travel time for the route
* the estimated total distance covered by the route
* a route ID, for use when updating the route
* a geographical bounding box for the route
* the travel mode used by the route
as well as a list of QGeoRouteSegment instances

The QGeoRouteSegment contains:
* the estimated travel time for the route
* the estimated total distance covered by the route
* a list of QGeoCoordinates which defines the path taken by the route segment
* a QGeoNavigationInstruction instance
and the QGeoNavigationInstruction contains:
* the instruction text
* the distance and time to the next instruction
* the position of the instruction
' this might be before the end of the corresponding segment
'
* especially if the speed limit is high

We plan to provide a QGeoMapObject subclass to assist with displaying routes on maps soon.

Current status

The Nokia plugin provides routing functionality.

The relationships between QGeoRoute, QGeoRouteSegment and QGeoNavigationInstruction are going to be re-examined, and QGeoRouteSegment and QGeoNavigationInstruction will probably be renamed.

The ability to specify features to avoid will probably be enhanced in order to support more fine-grained preferences with regard to features.

Geocoding and places searching

Geocoding and reverse geocoding are used to convert between address and coordinates:

QGeoSearchReply* QGeoSearchManager::geocode(const QGeoCoordinate &amp;amp;coordinate,<br /> const QGeoBoundingBox &amp;amp;boundingBox = QGeoBoundingBox());<br />QGeoSearchReply* QGeoSearchManager::geocode(const QGeoAddress &amp;amp;address,<br /> const QGeoBoundingBox &amp;amp;boundingBox = QGeoBoundingBox());

The QGeoSearchReply class contains a list of QGeoPlace instances, each of which contains a coordinate, and address and an optional bounding box. We return both pieces of information as the address or coordinate that was used in the geocode() function may be slightly different from the corresponding address or coordinate in the reply.

The optional bounds parameters is used to limit the results to those within a certain geographical area - usually the area corresponding to what a user has in their map viewport. When converting from address to coordinate the bounds parameter is most useful when a partially filled out address object is used - a QGeoAddress with city set to "London&quot; could represent London, Great Britain or London, Kentucky, USA.

When converting from coordinate to address some geocoding services will give the coordinate/address pairs at multiple levels of detail - for the street address, the suburb, the city, the state and the country - and the bounds parameter can be used to limit that behaviour.

These functions will only work if

bool QGeoSearchManager::supportsGeocoding() const<code><br />returns true.

To do a free text search, use:<br />

QGeoSearchReply* QGeoSearchManager::placeSearch(const QString &amp;searchString,
SearchTypes searchTypes = SearchTypes( SearchAll ),
const QGeoBoundingBox &amp; bounds = QGeoBoundingBox());

The searchTypes parameter is used to specify whether searchString is to be used for geocoding (in which case it will be treated as an address), for landmarks searching (in which case it will be used to search the services landmarks database) or both.

The values of searchType supported by the plugin can be found with:<br />

SearchTypes QGeoSearchManager::supportedSearchTypes()

The return type for this method is still a list of QGeoPlace objects. The QLandmark class from the Landmarks API is a subclass of QGeoPlace, and users can check QGeoPlace instances to see if they’re actually QLandmark instances and make a conversion from a QGeoPlace instance to a QLandmark instance if necessary.

The user can also specify additional QLandmarkManager instances to be used with QGeoSearchManager. This can be used so that a single search can make use of the plugins landmark database and a users personal landmark database at the same time.

For more involved handling of landmarks, the Qt Mobility Landmarks API should be used.

Current status

The Nokia plugin provides geocoding and reverse geocoding, but does not search online landmark databases at present.

We still need to work out the best way to do paging, in order to handle the case where someone searches for landmarks containing the text "the&quot;. The current method (return them all) is not exactly network friendly.

We also need to write the code to combine the placeSearch results from the plugin implementation and from the additional landmark managers.

Writing a new plugin

A plugin implementer needs to subclass QGeoServiceProviderFactory.

In addition to specifying the name and version of the plugin, the QGeoServiceProviderFactory subclass can provide implementations of createMappingManagerEngine(), createRoutingManagerEngine() and createSearchManagerEngine() as appropriate. The default implementations of these last three functions will be suitable if the plugin does not provide that particular set of functionality.

The plugin implementer should subclass QGeoMappingManagerEngine, QGeoRoutingManagerEngine and QGeoSearchManagerEngine in order to provide the requried functionality, and should take care to set the various metadata associated with each so that clients of the plugin can determine the specific capabilities of any particular plugin. See the class documentation for more informaiton.

Example applications

There are two example applications provided.

The first is the "Map Viewer example&quot;:http://doc.qt.nokia.com/qtmobility/mapviewer.html, which demonstrates the Mapping functionality.

Users can double click to center and zoom, drag to change position, and use the + and - keys to change the zoom level. Right clicking will bring up a menu which can be used to add objects to the map.

The second is QGeoAPIUI (which will be renamed soon) which demonstrates the routing and geocoding functionality.