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. Setting Map.center from javascript
Forum Updated to NodeBB v4.3 + New Features

Setting Map.center from javascript

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
2 Posts 2 Posters 501 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.
  • S Offline
    S Offline
    Sriep
    wrote on last edited by
    #1

    I am having a problem setting Map.center from javascript Qt5.7. The code below is a variant on minimal_map for mapbox.
    The console log gives.
    qml: map.center.latitude -0
    qml: map.center.longitude 1.34624

    So the latitude value seems to get set to zero when setting coordinates. I have tried numerous approaches to trying to set map.ceter but cannot get any of them to work.

    It might be related to the following bug report https://bugreports.qt.io/browse/QTBUG-55424

    So what I want to know. If it's the same bug what is the work around? If it's not a bug what obvious thing am I overlooking?

    Window {
    width: 512
    height: 512
    visible: true

    Plugin {
        id: mpaboxPlugin
        name: "mapbox"
         PluginParameter {
             name: "mapbox.access_token"
             value: myAccessToken
         }
         PluginParameter {
             name: "mapbox.map_id"
             value: "examples.map-zr0njcqy"
         }
    }
    
    Map {
        id: map
        anchors.fill: parent
        plugin: mpaboxPlugin
        center {
            latitude: 29
            longitude: 15
        }
        zoomLevel: 6
    }
    
    PositionSource {
        id: positionSource
        onPositionChanged: {
            //map.center = QtPositioning.coordinate(59.91, 10.75);
            map.center.latitude = 52.0;
            map.center.longitude = 1.346240;
            console.log("map.center.latitude", map.center.latitude);
            console.log("map.center.longitude", map.center.longitude);
        }
    
    }
    

    }

    1 Reply Last reply
    0
    • S Offline
      S Offline
      skats
      wrote on last edited by
      #2

      I have exactly the same problem. Some help would be appreciated.

      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