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. [SOLVED] QGeoCoordinate returns Nan in iOS

[SOLVED] QGeoCoordinate returns Nan in iOS

Scheduled Pinned Locked Moved Mobile and Embedded
2 Posts 1 Posters 948 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.
  • H Offline
    H Offline
    hasti66
    wrote on last edited by
    #1

    Hi , I use qt 5.3.2 on mac to implement an application for iOS. I want to get user current location. My code is here:

    @
    source = QGeoPositionInfoSource::createDefaultSource(this);
    if (source){
    text->append("sourceName: " + source->sourceName()); //return: core location
    source->setPreferredPositioningMethods(QGeoPositionInfoSource::AllPositioningMethods);
    source->setUpdateInterval(10000);
    }

    QGeoPositionInfo info = source->lastKnownPosition();
    QGeoCoordinate coordinate = info.coordinate();
    latitude = QString::number(coordinate.latitude());
    longitude = QString::number(coordinate.longitude());
    

    @

    The code works for android but in iOS(iPhone 4s) latitude and longitude are nan.
    in .pro file, i added:
    @
    QT +=positioning
    LIBS += -framework CoreLocation
    @
    What's wrong in my code? please help me.

    Hasti Ranjkesh

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hasti66
      wrote on last edited by
      #2

      I found my problem. I added a line of code to above function and it works.

      @
      source->setUpdateInterval(10000);
      source->updateRequest(); //this line of code solve my problem
      @

      Hasti Ranjkesh

      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