Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
geocode() form QGeoCodingManager class not returning anything after passing an address.
Hey guys! I feel like I almost have geocode() working but I pass an address to geocode() and it returns an empty list ( longitude gets set to -1 below). Any tips would be greatly appreciated!
// QMap<QString,QVariant> params;
// params["osm.geocoding.host"] = "https://nominatim.openstreetmap.org";
QGeoServiceProvider* geoSrv = new QGeoServiceProvider( "osm");
QGeoCodingManager *geoCoder = geoSrv->geocodingManager();
addr.setCountry( "Canada" );
QGeoCodeReply *geoCode = geoCoder->geocode(addr);
latitude = 14;
longitude = (geoCode->locations()).first().coordinate().longitude();
latitude = (geoCode->locations()).first().coordinate().latitude();
This post is deleted!
@Christian-Ehrlicher Hey, thanks for the reply! I tried implementing the slot handleFinish() but the values I'm getting are wonky, however, the list is no longer empty! I feel like the issue could be due to me making QGeoCodeReply *geoCode public as I was unsure how to pass it to the slot. Any tips are greatly appreciated!
Sorry but this code is neither correct in any way nor does it compile at all. Please learn basic c++ and take a look at the Qt signals/slots examples.
CaptainJuice last edited by CaptainJuice
@Christian-Ehrlicher Ok, thankyou for your help. I have reviewed my code and reviewed the documentation. The slots and signals are now recognized but I am still not getting reasonable values. The issue is that neither slots are being called. If you could point me in the right direction that would be great.
@CaptainJuice Are you sure handleError is not called? How did you check that?
Also, please post your code as text, not screen-shots.
@jsulm Sorry about that, will make sure to change that next time. I know it never enters either one of handleError() or handleFinish() because in my QML i have,
for the application window. If I set values in those handle() functions they do not get reflected in the console log. For example I set longitude= 14 in handleFinish() and I comment out the other code and this has no effect on the output. For handleError() the values do not get set to -1 so it doesn't get called.