01-21-2013 11:48 AM
I have a QGeoSearchManager which I am using to geocode a search value.
QGeoAddress * searchAddress = new QGeoAddress();
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?
01-22-2013 03:31 AM
QGeoAddress has many variables to define the exact loaction. You can find them in the API reference:
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.
01-23-2013 04:53 PM - edited 01-23-2013 04:59 PM
You can also localise the search using the device's location. From https://developer.blackberry.com/cascades/referenc
"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.)