我有我自己的本地Z/X/Y地图瓷砖服务器,并希望将它用作QML应用程序中的地图背景。看看示例代码,它看起来是这样做的: -QT QML QtLocation地图插件
Plugin {
id: osmPlugin
name: "osm"
}
所以我需要写我自己的插件。但文档看起来很稀疏,我找不到osm版本或安装说明的源代码。
这样做相对容易吗,还是可以在不编写新插件的情况下完成?
我有我自己的本地Z/X/Y地图瓷砖服务器,并希望将它用作QML应用程序中的地图背景。看看示例代码,它看起来是这样做的: -QT QML QtLocation地图插件
Plugin {
id: osmPlugin
name: "osm"
}
所以我需要写我自己的插件。但文档看起来很稀疏,我找不到osm版本或安装说明的源代码。
这样做相对容易吗,还是可以在不编写新插件的情况下完成?
如果文档没有包含足够详细的内容,请务必记住Qt's source是公开可用的。
例如,OSM插件here
的Woboq code browser也很不错的,如果你知道类名或文件,你是looking for
好,我已经想出了一个办法做到这一点无需编写插件。
OSM插件使用tileserver来检索图块。 URL设置为插件选项osm.mapping.custom.host将其设置为本地URL允许我使用自己的瓷砖,只要它们符合osm结构。
可以这样设置osm.mapping.host:
Plugin {
id: osmPlugin
name: "osm"
PluginParameter { name: "osm.mapping.host"; value: "https://tile.openstreetmap.org/" }
PluginParameter { name: "osm.geocoding.host"; value: "https://nominatim.openstreetmap.org" }
PluginParameter { name: "osm.routing.host"; value: "https://router.project-osrm.org/viaroute" }
PluginParameter { name: "osm.places.host"; value: "https://nominatim.openstreetmap.org/search" }
PluginParameter { name: "osm.mapping.copyright"; value: "" }
PluginParameter { name: "osm.mapping.highdpi_tiles"; value: true }
}
但不要忘记使用下面的代码来设置自定义地图类型:
Map {
id: map
height: parent.width
width: parent.width
plugin: osmPlugin
Component.onCompleted: {
for(var i_type in supportedMapTypes) {
if(supportedMapTypes[i_type].name.localeCompare("Custom URL Map") === 0) {
activeMapType = supportedMapTypes[i_type]
}
}
}
}
谢谢,但作为我的问题的第二部分是有一个替代方案,因为它似乎很多工作,特别是在OSM代码中没有评论。 –