QML Maps



  • Hello!
    I used to work with osm map plugin but since 11 july 2016 direct tile access has been discontinued. Now i want to be able to use osm map plugin or another plugin that it is compatible with android and iOS. Is there any solution about my problem?


  • Moderators



  • So the answer is that there is no plugin in order to have maps in my app? Can you please give me an example of using thunder forest plugin?

    Thanks in advance!


  • Moderators

    @NickV
    Officially Qt comes beside OSM with HERE (formerly Nokia) and Mapbox plugins

    Otherwise there are some 3rd party map plugins available on the web (e.g. for Google maps)
    You would need to compile and link them against your Qt version yourself.



  • I wrote my own map component. It was hard, but it works. OSM, Google Maps and more are supported



  • Sorry, but in the instruction of open street map plugin I read that I can use a different host and specify my preferred tile server (e.g. mapnik??)

    I tried the following solution, but it doesn't work. I do not understand why? It seems that the app continue to use mapquest tiles...

    Plugin {
    id: myosmplugin
    //preferred: ["osm", "nokia", "foo"]
    name: "osm"
    //required: Plugin.AnyMappingFeatures | Plugin.AnyGeocodingFeatures
    PluginParameter{name: "osm.mapping.host"; value: "http://tile.openstreetmap.org"}
    //PluginParameter { name: "osm.mapping.host"; value: "http://c.tile.thunderforest.com/outdoors/" }
    }



  • @rmarzocchi84

    I was just dealing with this issue and am answering this as the community forums have been quite helpful with my project. If you found the documentation that I read, at http://doc.qt.io/qt-5/location-plugin-osm.html, then it is wrong as of this writing.

    It states that "This parameter should be set to a valid server url with the correct osm api and the Map::activeMapType to the corresponding MapType.CustomMap". The Map::activeMapType is a MapType not an integer type, so setting this enumeration did not work resulting in error

    Unable to assign int to QDeclarativeGeoMapType*
    

    Digging through the 5.7 source produces (in qtlocation/src/plugins/geoservices/osm/qgeotiledmappingmanagerengineosm.cpp):

        if (parameters.contains(QStringLiteral("osm.mapping.custom.host"))
                || parameters.contains(QStringLiteral("osm.mapping.host"))) {
    
    ...
    
            m_providers.push_back(
                new QGeoTileProviderOsm("",
                    nm,
                    QGeoMapType(QGeoMapType::CustomMap, tr("Custom URL Map"), tr("Custom url map view set via urlprefix parameter"), false, false, 8),
                    QGeoTileProviderOsm::TileProvider(tmsServer + QStringLiteral("%z/%x/%y.png"),
                        QStringLiteral("png"),
                        mapCopyright,
                        dataCopyright
                    )));
    ...
    }
    

    There is a Map::supportedMapTypes available of type list<MapType>. On my desktop system, JSON.stringify( supportedMapTypes ) using a Map with an "osm" plugin produces:

    {"0":{"objectName":"","style":1,"name":"Street Map","description":"Street map view in daylight mode","mobile":false,"night":false},"1":{"objectName":"","style":2,"name":"Satellite Map","description":"Satellite map view in daylight mode","mobile":false,"night":false},"2":{"objectName":"","style":10,"name":"Cycle Map","description":"Cycle map view in daylight mode","mobile":false,"night":false},"3":{"objectName":"","style":6,"name":"Transit Map","description":"Public transit map view in daylight mode","mobile":false,"night":false},"4":{"objectName":"","style":6,"name":"Night Transit Map","description":"Public transit map view in night mode","mobile":false,"night":true},"5":{"objectName":"","style":4,"name":"Terrain Map","description":"Terrain map view","mobile":false,"night":false},"6":{"objectName":"","style":8,"name":"Hiking Map","description":"Hiking map view","mobile":false,"night":false},"7":{"objectName":"","style":100,"name":"Custom URL Map","description":"Custom url map view set via urlprefix parameter","mobile":false,"night":false}}
    

    Note item "7":{"objectName":"","style":100,"name":"Custom URL Map","description":"Custom url map view set via urlprefix parameter","mobile":false,"night":false} is the "Custom URL Map" from the C++ source.

    So, finally, the following code snippet from a simple test app worked (Qt 5.7):

    import QtQuick 2.5
    import QtQuick.Window 2.2
    import QtLocation 5.3
    
    Window {
        visible: true
        width: 640
        height: 480
    
        Plugin {
            id: myPlugin
            name: "osm"
            PluginParameter { name: "osm.mapping.host";
                value: "http://myobfuscatedhost.tld/osm/" }
            PluginParameter { name: "osm.mapping.copyright";
                value: "The documentation is wrong." }
        }
    
        Map {
            anchors.fill: parent
            plugin: myPlugin
    
            Component.onCompleted: {
                for( var i_type in supportedMapTypes ) {
                    if( supportedMapTypes[i_type].name.localeCompare( "Custom URL Map" ) === 0 ) {
                        activeMapType = supportedMapTypes[i_type]
                    }
                }
            }
        }
    }
    

    The images displayed by the resulting map have been confirmed to be from the switch2osm test server I setup.

    Good luck.


  • Lifetime Qt Champion

    @user901735110 Hi and welcome to devnet,

    You should open a bug report about this on the bug report sysetm mentioning your findings. You could even fix the documentation itself by submitting a patch for integration.



  • Esri plans on releasing a geolocation provider for Qt Location, and will be discussing it at QtCon this year. I think everyone will be interested to see the basemaps offered, and to take advantage of routing and geocoding as well. If anyone is in Berlin for the conference, I encourage you to attend this session.



  • I wonder is there any progress done on this issue? If yes; may you please guide us how to use OSM with Qt

    I run "Places Map (QML)" example to find the ugly error message of discontinued service :(



  • BTW, I found this widget which view OSM but unfortunately it doesn't work under Android and I couldn't find a way to add places in the map
    https://github.com/raptorswing/MapGraphics


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.