Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Contributor
MrRobClarke
Posts: 11
Registered: ‎05-21-2012

QGeoSearchManager in the UK

Hi,

 

I have a QGeoSearchManager which I am using to geocode a search value.

 

QGeoAddress * searchAddress = new QGeoAddress();
searchAddress->setText(searchTerm)

searchReply = searchManager->geocode(*searchAddress);

 

If I search for "Boston", I get the one in the US and not the one in the UK.

 

Is there anyway localise the geocode search?

Please use plain text.
Contributor
chriske86
Posts: 43
Registered: ‎01-05-2013
My Carrier: Telenor Hungary

Re: QGeoSearchManager in the UK

Hi,

 

QGeoAddress has many variables to define the exact loaction. You can find them in the API reference:

http://harmattan-dev.nokia.com/docs/library/html/qtmobility/qgeoaddress.html

 

Don't worry, this is the same QGeoAddress object. So, it has for example country, countryCode and city variables. If you fill in these properties, the search manager will get the exact address what you want.

 

cheers,

chriske

--------------------------------------------------------------
If my post was helpful or it was the solution for Your problem, please don't forget to give me a like, and mark my post as a solution. Thanks!
Please use plain text.
BlackBerry Development Advisor
jehrismann
Posts: 67
Registered: ‎10-15-2012
My Carrier: Telus

Re: QGeoSearchManager in the UK

[ Edited ]

Hi,

 

You can also localise the search using the device's location. From https://developer.blackberry.com/cascades/reference/qtmobilitysubset__qgeosearchmanager.html#geocode

 

"Note that the BB10 QGeoSearchManager may give very different results depending if bounds is specified or not. Searching for an obscure address without providing a latitude/longitude hint can result in no matches found. The bounds center is used as a latitude/longitude hint of where to search for the address. To perform an unbounded search with a latitude/longitude hint ensure bounds is empty (i.e. bounds->isEmpty() is true). This is done by setting the radius to 0 (forQGeoBoundingCircle) or by ensuring the height and width are both 0 (for QGeoBoundingBox)."

 

If you want search results local to where the device is, get the device's position (see QGeoPositionInfoSource) and use that as the centre of the bounds parameter to QGeoSearchManager::geocode().

 

Your search found Boston in the US because the remote server is aware of "popular" places, which it relies on if there is no additional information provided. And in that case you get just 1 result. This can make the search behaviour a little inconsistent, since a search for little-known "Kirton" actually turns up 4 results. For other search terms, like "Elm Street", the remote server may not return any results without a latitude/longitude reference.

 

If you wish to search using the QGeoAddress text field via setText() then providing a latitude/longitude reference will give you localised results.

 

Note that if you are specifying other QGeoAddress fields, like city, country etc, then leave the text field blank (i.e. don't call setText(), just call setCity(), setCountry() etc.)

 

Regards,

Jim

Please use plain text.