【问题标题】:QT QML QtLocation map pluginQT QML QtLocation 地图插件
【发布时间】:2017-07-13 03:59:01
【问题描述】:

我有自己的本地 Z/X/Y 地图切片服务器,并希望将其用作 QML 应用程序中的地图背景。查看示例代码,这似乎是由以下人员完成的:-

 Plugin {
    id: osmPlugin
    name: "osm"
 }

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

这是比较容易做到的,还是不用写新插件就可以做到?

【问题讨论】:

    标签: qt qml qtlocation


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      如果文档没有涵盖某些内容或不够详细,最好记住Qt's source 是公开的。

      例如 OSM 插件是here

      Woboq code browser 也非常好,如果你知道你是 looking for 的类或文件的名称

      【讨论】:

      • 谢谢,但至于我的问题的第二部分是否有替代方案,因为它似乎需要做很多工作,特别是考虑到 OSM 代码中没有 cmets。
      【解决方案3】:

      好的,我已经找到了一种无需编写插件即可做到这一点的方法。

      OSM 插件使用 tileserver 来检索图块。该 url 使用插件选项 osm.mapping.custom.host 设置,将其设置为本地 url 允许我使用我自己的图块,只要它们符合 osm 结构。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2015-03-11
        • 1970-01-01
        • 1970-01-01
        • 2015-05-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多