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
Regular Contributor
Posts: 93
Registered: ‎08-20-2013
My Device: BB 10 -BlackBerry Z10
My Carrier: BlackBerry

ReverseGeocoding in BlackBerry 10

Hello,

 

 

       could anyone tell me how to do Reverse geocoding in BB10. I have got latitude , longitude and now I need to convert it into address. 

Developer
Posts: 237
Registered: ‎05-21-2012
My Device: BlackBerry RED Z10
My Carrier: WiFi

Re: ReverseGeocoding in BlackBerry 10

You can use Google's Reverse Geo Coding API

Developer
Posts: 16,997
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: ReverseGeocoding in BlackBerry 10

this should help:

https://developer.blackberry.com/native/reference/cascades/qtmobilitysubset__qgeosearchmanager.html#...
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Regular Contributor
Posts: 93
Registered: ‎08-20-2013
My Device: BB 10 -BlackBerry Z10
My Carrier: BlackBerry

Re: ReverseGeocoding in BlackBerry 10

[ Edited ]

Hi nemory,

 

Thanks for replying.

I don't want to use Google's API . I have gone through BlackBerry docs and found some classe for geocoding but didn't understand their code and how to implement this. Do you know how to do this using these Classes .If so can you provide simple code for it.

Retired
Posts: 81
Registered: ‎09-09-2013
My Device: BlackBerry Z10
My Carrier: Etisalat UAE

Re: ReverseGeocoding in BlackBerry 10

Hello -

 

 

 

Please find the below code snippets, since you got the lat & Lang. it pretty much simple, you search with the lat & lang and create slot to recieve the results as (addresses matching the provieded lat & lang). You would need to tweak the code to work in your project.

 

QGeoCoordinate GCoor(lat,lang);

//Reverse GeoCoding
	QStringList serviceProviders =
			QGeoServiceProvider::availableServiceProviders();
	if (serviceProviders.size()) {
		QGeoServiceProvider *serviceProvider = new QGeoServiceProvider(
				serviceProviders.at(0));
		QGeoSearchManager *searchManager = serviceProvider->searchManager();
		//searchManager->setProperty("boundary", "city");
		reply = searchManager->reverseGeocode(GCoor);

		bool finished_connected = QObject::connect(reply, SIGNAL(finished()),
				this, SLOT(readReverseGeocode()));

		bool error_connected = QObject::connect(reply,
				SIGNAL(error(QGeoSearchReply::Error, QString)), this,
				SLOT(reverseGeocodeError(QGeoSearchReply::Error, QString)));

 

//Reverse GeoLocation
void LocationHandler::readReverseGeocode() {
	QList<QGeoPlace> LocDetList = reply->places();
	QGeoPlace locDe = LocDetList.at(0);
	qDebug() << "City --> " << locDe.address().state();
	qDebug() << "Country Code --> " << locDe.address().countryCode();
	qDebug() << "Country --> " << locDe.address().country();

	reply->deleteLater();
}

void LocationHandler::reverseGeocodeError(QGeoSearchReply::Error error,
		QString errorString) {
	qDebug() << "( Geo::reverseGeocodeError ) " << errorString;
	reply->deleteLater();
}

 

Hope this help.

 

Thanks,

Kareem.

 

Kareem ELSayed | Application Development Consultant | Developer Relations | BlackBerry | Twitter:@kemobyte
Regular Contributor
Posts: 93
Registered: ‎08-20-2013
My Device: BB 10 -BlackBerry Z10
My Carrier: BlackBerry

Re: ReverseGeocoding in BlackBerry 10

Hi Kareem_ELSayed,

 

     I have implemented this code in sample app but the control is not going in readReverseGeocode() slot.

Developer
Posts: 6,152
Registered: ‎07-05-2012
My Device: Playbook, Dev Alpha C, Z10 LE, Z30
My Carrier: Orange

Re: ReverseGeocoding in BlackBerry 10

Did you check both finished_connected and error_connnected are returning true?


If you've been helped click on Like Button, if you've been saved buy the app. Smiley Happy

Developer of stokLocker, Sympatico and Super Sentences.
Regular Contributor
Posts: 93
Registered: ‎08-20-2013
My Device: BB 10 -BlackBerry Z10
My Carrier: BlackBerry

Re: ReverseGeocoding in BlackBerry 10

Hello,

        Now the slot is executing but application is exiting at this line in readReverseGeocode() method. 

QGeoPlace locDe = LocDetList.at(0);

 whats the problem here ?

Regular Contributor
Posts: 93
Registered: ‎08-20-2013
My Device: BB 10 -BlackBerry Z10
My Carrier: BlackBerry

Re: ReverseGeocoding in BlackBerry 10

Hello, Now the slot is executing but application is exiting at this line in readReverseGeocode() method. QGeoPlace locDe = LocDetList.at(0); whats the problem here ?
Retired
Posts: 249
Registered: ‎07-14-2008
My Device: Not Specified

Re: ReverseGeocoding in BlackBerry 10

Chances are very high that 

LocDetList.at(0)

does not exist at that point..