I am using OSM and here map plugins for QML app. I use map.activeMapType = map.supportedMapTypes[currentIndex]
in ComboBox to display supported map types from map providers on the map area. Here map plugin works with "here.app_id"
and "here.token"
parameters. But for OSM plugin, Terrain, transit and other tiles except Street map tile display "API Key Required". I got API key from thunderforest.com. When using the parameter, it still shows "API Key Required" :
ComboBox {
id: selectmap
width: parent.width
model:map.supportedMapTypes
textRole:"description"
onCurrentIndexChanged:{
map.activeMapType = map.supportedMapTypes[currentIndex]
}
}
Plugin {
id: pluginOSM
name: "osm"
PluginParameter {
name: "osm.mapping.providersrepository.address";
// name: "osm.geocoding.host"; (also didn't work)
value: "https://tile.thunderforest.com/transport/{z}/{x}/{y}.png?apikey=<my_api_key>" }
}
I also downloaded terrain file parameter from http://maps-redirect.qt.io/osm/5.8/ site to use with qrc like this:
import QtQuick 2.6
import QtQuick.Controls 2.0
import QtLocation 5.12
import QtPositioning 5.12
ApplicationWindow{
id: root
width: 500
height: 700
visible: true
Flickable {
height: parent.height
width: parent.width
clip: true
boundsBehavior: Flickable.StopAtBounds
contentHeight: Math.max(mapColumn.implicitHeight, height)+50
ScrollBar.vertical: ScrollBar {}
z: 2
Column{
anchors.horizontalCenter: parent.horizontalCenter
id:mapColumn
spacing: 5
anchors.fill : parent
Row{
anchors.horizontalCenter: parent.horizontalCenter
spacing:25
id:maprow
Rectangle{
width:mapColumn.width
height:mapColumn.height/2
Map {
id:map
anchors.fill: parent
plugin: Plugin {
name: "osm"
PluginParameter {
name: "osm.mapping.host";
value: "qrc:/terrain"
}
}
}
}
}
Column{
id: combos
spacing: 10
width: parent.width
anchors.verticalCenter: root.verticalCenter
Row{
anchors.horizontalCenter: parent.horizontalCenter
spacing:1
Label{ text:"Map Type: " }
// Map Types
ComboBox {
id: selectmap
width: 200
model:map.supportedMapTypes
textRole:"description"
onCurrentIndexChanged: map.activeMapType = map.supportedMapTypes[currentIndex]
}
}
}
}
}
}
In terrain file I updated the parameter as "UrlTemplate" : "https://tile.thunderforest.com/landscape/{z}/{x}/{y}.png?apikey=<api-key>",
This didn't work, the custom map view was empty. Is it possible to remove it with API key? Thanks