Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QGeoCoordinate returns Nan

QGeoCoordinate returns Nan

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 461 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GrishaE
    wrote on last edited by
    #1

    Hi!
    I` m trying to implement positioning on Android, but it returns coordinates as "nan";
    Here is the code:

     QString *text = new QString;
    
    
        auto source = QGeoPositionInfoSource::createDefaultSource(this);
        if(source){
        text->append("sourceName: " + source->sourceName()); //return: core location
        source->setPreferredPositioningMethods(QGeoPositionInfoSource::AllPositioningMethods);
        source->setUpdateInterval(1000);
        source->requestUpdate();
    
    
        }
    
        QLabel *lbl = new QLabel;
        QGeoPositionInfo info = source->lastKnownPosition();
        QGeoCoordinate coordinate = info.coordinate();
        auto  latitude = QString::number(coordinate.latitude());
        auto longitude = QString::number(coordinate.longitude());
    
        lbl->setText(*text);
    
        QString all;
        all = latitude;
        all += ",";
        all += longitude;
        //lbl->setText(all);
    
        QString URL("https://www.google.ru/maps/@" + all);
    
        QUrl myUrl(URL);
        QDesktopServices::openUrl(myUrl);
    
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved