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. Map - api key requared
Forum Updated to NodeBB v4.3 + New Features

Map - api key requared

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 3 Posters 1.0k 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
    Mihaill
    wrote last edited by Mihaill
    #1

    Hi!
    I use qt6.8, win 10.
    I tru using map and get error "api key requared " on tiles.

    Map {
        id: map
        anchors.fill: parent
        plugin: mapPlugin
        zoomLevel: 10
    }
    
    Plugin {
        id: mapPlugin
        name: "osm"
        parameters: [    
                    PluginParameter { name: "mapping.host"; value: "https://tile.openstreetmap.org/" }    
                ]
    }
    

    On qt5.15 same code is work.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      Mihaill
      wrote last edited by
      #2

      it's solvation https://www.youtube.com/watch?v=VlRMQWqI0S8&ab_channel=QtWithKetan

      SGaistS 1 Reply Last reply
      1
      • M Mihaill has marked this topic as solved
      • M Mihaill

        it's solvation https://www.youtube.com/watch?v=VlRMQWqI0S8&ab_channel=QtWithKetan

        SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote last edited by
        #3

        @Mihaill hi,

        It would be nice to also post here the code you used to fix your issue in case the video is taken down.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1
        • JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote last edited by JoeCFD
          #4

          The code in the video does not work. Not sure how he made the video. The tile address was typed to tite wrongly and the format was not correct either. The following code works for Qt5&6 QML without marker "API Key required".

          import QtQuick //2.15 for Qt5
          import QtLocation //5.15 for Qt5
          import QtPositioning //5.15 for Qt5
          
          Window {
              width: Qt.platform.os == "android" ? Screen.width : 512
              height: Qt.platform.os == "android" ? Screen.height : 512
              visible: true
              title: map.center + " zoom " + map.zoomLevel.toFixed(3)
                     + " min " + map.minimumZoomLevel + " max " + map.maximumZoomLevel
          
              Plugin {
                  id: mapPlugin
                  name: "osm"
                  PluginParameter {
                      name: "osm.mapping.providersrepository.disabled"
                      value: true  //fpr Qt5 value: "true"
                  }  
          
                  PluginParameter {
                      name: "osm.mapping.custom.host"
                      value: "https://tile.openstreetmap.org/%z/%x/%y.png"
                  }
              }
          
              Map {
                  id: map
                  anchors.fill: parent
                  plugin: mapPlugin
                  center: QtPositioning.coordinate(59.91, 10.75) // Oslo
                  zoomLevel: 14
                  activeMapType: map.supportedMapTypes[map.supportedMapTypes.length - 1]
          
                  property geoCoordinate startCentroid
          
                  PinchHandler {
                      id: pinch
                      target: null
                      onActiveChanged: if (active) {
                          map.startCentroid = map.toCoordinate(pinch.centroid.position, false)
                      }
          
                      onScaleChanged: (delta) => {
                          map.zoomLevel += Math.log2(delta)
                          map.alignCoordinateToPoint(map.startCentroid, pinch.centroid.position)
                      }
          
                      onRotationChanged: (delta) => {
                          map.bearing -= delta
                          map.alignCoordinateToPoint(map.startCentroid, pinch.centroid.position)
                      }
                      grabPermissions: PointerHandler.TakeOverForbidden
                  }
          
                  WheelHandler {
                      id: wheel
                      // workaround for QTBUG-87646 / QTBUG-112394 / QTBUG-112432:
                      // Magic Mouse pretends to be a trackpad but doesn't work with PinchHandler
          
                      // and we don't yet distinguish mice and trackpads on Wayland either
                      acceptedDevices: Qt.platform.pluginName === "cocoa" || Qt.platform.pluginName === "wayland"
                                       ? PointerDevice.Mouse | PointerDevice.TouchPad
                                       : PointerDevice.Mouse
                      rotationScale: 1/120
          
                      property: "zoomLevel"
                  }
          
                  DragHandler {
                      id: drag
                      target: null
                      onTranslationChanged: (delta) => map.pan(-delta.x, -delta.y)
                  }
          
                  Shortcut {
                      enabled: map.zoomLevel < map.maximumZoomLevel
                      sequence: StandardKey.ZoomIn
                      onActivated: map.zoomLevel = Math.round(map.zoomLevel + 1)
                  }
          
                  Shortcut {
                      enabled: map.zoomLevel > map.minimumZoomLevel
                      sequence: StandardKey.ZoomOut
                      onActivated: map.zoomLevel = Math.round(map.zoomLevel - 1)
                  }
              }
          }
          
          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