QT QML QtLocation地图插件

时间:2017-02-22 21:35:46

标签: qt qml qtlocation

我有自己的本地Z / X / Y地图图块服务器,并希望将其用作QML应用程序中的地图背景。查看示例代码,似乎可以通过以下方式完成: -

 Plugin {
    id: osmPlugin
    name: "osm"
 }

所以我需要编写自己的插件。但是文档看起来很稀疏,我找不到osm版本或安装说明的源代码。

这是否相对容易,或者可以在不编写新插件的情况下完成?

2 个答案:

答案 0 :(得分:2)

您可以像这样设置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]
                }
            }
        }
    }

答案 1 :(得分:1)

如果文档没有详细说明或不详细说明,请务必记住Qt's source是公开可用的。

例如,OSM插件是here

如果你知道你所在的类或文件的名称Woboq code browser

looking for也非常好用