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. QT Location OSM API Key required
Forum Updated to NodeBB v4.3 + New Features

QT Location OSM API Key required

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
6 Posts 5 Posters 3.5k Views 2 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
    Markus Ippy
    wrote on 12 Jun 2019, 06:16 last edited by
    #1

    I am trying to build a QML Map with the OSM plugin . All the map tiles show Api Key required
    How do i set the API key in my QML code ?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 12 Jun 2019, 07:07 last edited by
      #2

      Hi,

      Can you share a minimal buildable example that shows that behaviour ?

      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
      0
      • M Offline
        M Offline
        Markus Ippy
        wrote on 12 Jun 2019, 15:11 last edited by
        #3

        my example

        import QtQuick 2.8
        import QtLocation 5.9
        import QtPositioning 5.9
        import QtQuick.Controls 2.1
        
        Item {
            id: mapItem
            anchors.fill: parent
        
            Rectangle{
                anchors.fill: parent
                Plugin {
                    id: mapPlugin
                    name: "osm"
                }
        
                Map {
                    id: map
                    height : 480
                    width : 800
                    plugin: mapPlugin
                    zoomLevel: 16
                    activeMapType: map.supportedMapTypes[1]
                    copyrightsVisible : false
                    gesture.enabled: false
                    tilt: 0
                    color: "black"
                    center: marker.coordinate
        
                    // Draw a small red circle for current Vehicle Location
                    MapQuickItem {
                        id: marker
                        anchorPoint.x: 10
                        anchorPoint.y: 10
                        width: 15
                        coordinate: QtPositioning.coordinate(-25.8,28.1)
                        sourceItem: Rectangle {
                            id: image
                            width:20
                            height: width
                            radius: width*0.5
                            color: "red"
                        }
                    }
                }
            }
        }
        
        1 Reply Last reply
        0
        • M Offline
          M Offline
          MikeSheldon
          wrote on 24 Jun 2020, 10:13 last edited by
          #4

          MikeSheldon 24 minutes ago

          Hi,

          I realise this topic is a bit old but I've just run into this same issue myself, and have discovered a solution for it. So for the sake of anyone else coming across this on Google the mechanism I discovered for providing an API key to the OSM plugin is to set up your own providers repository, that way you can specify the API key as part of the URL template.

          I made a simple github repo with a script for creating a repository here: https://github.com/Elleo/qt-osm-map-providers

          And I wrote up a more detailed explanation of everything on my blog here: https://blog.mikeasoft.com/2020/06/22/qt-qml-maps-using-the-osm-plugin-with-api-keys/

          Hope that helps,
          Mike

          M 1 Reply Last reply 14 Sept 2023, 08:51
          0
          • M MikeSheldon
            24 Jun 2020, 10:13

            MikeSheldon 24 minutes ago

            Hi,

            I realise this topic is a bit old but I've just run into this same issue myself, and have discovered a solution for it. So for the sake of anyone else coming across this on Google the mechanism I discovered for providing an API key to the OSM plugin is to set up your own providers repository, that way you can specify the API key as part of the URL template.

            I made a simple github repo with a script for creating a repository here: https://github.com/Elleo/qt-osm-map-providers

            And I wrote up a more detailed explanation of everything on my blog here: https://blog.mikeasoft.com/2020/06/22/qt-qml-maps-using-the-osm-plugin-with-api-keys/

            Hope that helps,
            Mike

            M Offline
            M Offline
            Madhusmita_123
            wrote on 14 Sept 2023, 08:51 last edited by
            #5

            @MikeSheldon hi
            import QtQuick 2.15
            import QtQuick.Window 2.15
            import QtLocation 5.15
            import QtPositioning 5.15

            Window {
            width: 640
            height: 480
            visible: true
            title: qsTr("Hello World")

            Map{
                id: mapView
                anchors.fill: parent
                plugin: Plugin{
                    id:mapPlugin
                    name: "osm"
                    PluginParameter { name: "osm.mapping.providersrepository.address"; value: "http://www.mywebsite.com/osm_repository" }
                    PluginParameter { name: "osm.mapping.highdpi_tiles"; value: true }
                }
                activeMapType: supportedMapTypes[1] // Cycle map provided by Thunderforest
            }
            

            }
            this is my qml code i have an api key where can I give in this code

            J 1 Reply Last reply 14 Sept 2023, 14:17
            0
            • M Madhusmita_123
              14 Sept 2023, 08:51

              @MikeSheldon hi
              import QtQuick 2.15
              import QtQuick.Window 2.15
              import QtLocation 5.15
              import QtPositioning 5.15

              Window {
              width: 640
              height: 480
              visible: true
              title: qsTr("Hello World")

              Map{
                  id: mapView
                  anchors.fill: parent
                  plugin: Plugin{
                      id:mapPlugin
                      name: "osm"
                      PluginParameter { name: "osm.mapping.providersrepository.address"; value: "http://www.mywebsite.com/osm_repository" }
                      PluginParameter { name: "osm.mapping.highdpi_tiles"; value: true }
                  }
                  activeMapType: supportedMapTypes[1] // Cycle map provided by Thunderforest
              }
              

              }
              this is my qml code i have an api key where can I give in this code

              J Offline
              J Offline
              JKSH
              Moderators
              wrote on 14 Sept 2023, 14:17 last edited by
              #6

              @Madhusmita_123 said in QT Location OSM API Key required:

              i have an api key where can I give in this code

              You currently cannot, unfortunately. There is a feature request for it: https://bugreports.qt.io/browse/QTBUG-115742

              The feature request describes how to patch qgeotiledmappingmanagerengineosm.cpp to accept an API key (the source code is at https://github.com/qt/qtlocation/blob/dev/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp )

              Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved