Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Unsolved How used apiKey in OSM Plugin?

    Mobile and Embedded
    3
    3
    255
    Loading More Posts
    • 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
      Mikeeeeee last edited by

      Hi!
      How used apiKey in OSM Plugin?
      This my code:

      import QtQuick 2.12
      import QtQuick.Window 2.12
      import QtLocation 5.12
      import QtPositioning 5.12
      
      Item {
          visible: true
          width: 480
          height: 720
      
          property double old : 19
          property double now
      
          Rectangle
          {
              anchors.fill: parent
              color: "#eee"
      
              Plugin
              {
                  id: plugin
                  name: "osm"
                  PluginParameter { name: "osm.useragent"; value: "My great Qt OSM application" }
              }
      
              Map
              {
                  id: maps
                  anchors.fill: parent
                  plugin: plugin
                  gesture.enabled: true
                  gesture.acceptedGestures: MapGestureArea.PinchGesture | MapGestureArea.PanGesture | MapGestureArea.FlickGesture
                  gesture.flickDeceleration: 3000
                  zoomLevel: 19
                  center: QtPositioning.coordinate(55.845741, 37.660652) // Moscow
                  copyrightsVisible: false 
                  activeMapType: maps.supportedMapTypes[5] 
                  //activeMapType: SatelliteMapNight
                  //activeMapType: PedestrianMap
                  //activeMapType: MapType.SatelliteMapNight
                  //activeMapType: MapType.PedestrianMap
      
      
                  onCenterChanged:
                  {
                      if (zoomLevel >= 17.5) 
                      {
      
      
                      }
                  }
      
                  minimumZoomLevel: 1
      
                  focus: true
      
                  PlaceSearchModel {
                      id: mySearchModel
                      plugin: plugin
                      searchArea: visibleRegion.boundingGeoRectangle()
                      onSearchAreaChanged:  //it's work
                      {
                          console.log("onSearchAreaChanged :" )
                          console.log("count :" + mySearchModel.count)
                          if (count == 1) {
      
                          }
      
                      }
                  }
      
                  GeocodeModel {           //Location get(index) должно возвращать координаты
                      id: geocodeModel
                      plugin: plugin
                      onLocationsChanged:
                      {
                          //console.log("count: " + geocodeModel.count)
                          //console.log("bounds: " + geocodeModel.bounds)
                          console.log("onLocationsChanged")
                          if (count == 1) {
      
                              console.log("text:" + geocodeModel.get(0).address.text )
                              console.log("coordinate:" + geocodeModel.get(0).coordinate)
                          }
                      }
                  }
              }
          }
      }
      
      1 Reply Last reply Reply Quote 0
      • MikeSheldon
        MikeSheldon last edited by

        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

        D 1 Reply Last reply Reply Quote 0
        • D
          dama @MikeSheldon last edited by

          @MikeSheldon Hi. I tried to follow your instructions with my own api key, but did not succeed in removing the watermark. How did you retrieve the original setup files from the Tunderforest server?

          --
          Dag Magne

          1 Reply Last reply Reply Quote 0
          • First post
            Last post