Nan in translation from geo to point coordinates in Map

  • 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_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("")
    QGeoTileFetcherOsm: all providers resolved

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.