Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Nan in translation from geo to point coordinates in Map

Nan in translation from geo to point coordinates in Map

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 1.3k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    MTM_OSS
    wrote on last edited by
    #1

    import QtQuick 2.4
    import QtQuick.Window 2.2
    import QtPositioning 5.5
    import QtLocation 5.6

    Window {
    width: 800; height: 600; visible: true;

    property variant centerOfTheMap: QtPositioning.coordinate(48.0, 2.0);
    property real widthDegrees: 5; property real heightDegrees: 5;

    Map {
    id: mainMap
    anchors.centerIn: parent;
    anchors.fill: parent;
    plugin: Plugin { name: "osm" }
    visibleRegion: QtPositioning.rectangle(centerOfTheMap, widthDegrees, heightDegrees);

    Component.onCompleted: {
    console.log("Component.onCompleted called");
    var p=mainMap.fromCoordinate(centerOfTheMap);
    console.log("rect left ", centerOfTheMap, p);
    }
    } // Map
    }

    The printout is:

    qml: rect left 48° 0' 0.0" N, 2° 0' 0.0" E QPointF(nan, nan)

    Any idea why, and how can it be solved ?
    Thank you,
    MTM

    1 Reply Last reply
    0
    • Pablo J. RoginaP Offline
      Pablo J. RoginaP Offline
      Pablo J. Rogina
      wrote on last edited by
      #2

      @MTM_OSS your code worked fine under Linux/Qt 5.9.0
      I've just created a new Qt Quick application in Qt Creator and pasted your code in main.qml. Map visible with most of France, and output as follows:

      qml: Component.onCompleted called
      qml: rect left  48° 0' 0.0" N, 2° 0' 0.0" E QPointF(-0.494444, 0.347614)
      QGeoTileProviderOsm: Tileserver disabled at  QUrl("http://maps-redirect.qt.io/osm/5.8/satellite")
      QGeoTileFetcherOsm: all providers resolved
      

      Upvote the answer(s) that helped you solve the issue
      Use "Topic Tools" button to mark your post as Solved
      Add screenshots via postimage.org
      Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

      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