Please nominate your Qt Champions for 2021!

Using Google Maps in an native mobile application

  • Hey Guys!

    I want to use Google Maps in an native mobile application under Qt 5.7. Has anybody experiences and even better, has anybody a kind of example how I can do this in Qt 5.7? Thanks for any help!

    Greetings, Simon

    [Moved to Mobile and Embedded ~kshegunov]

  • Moderators

    You can use the QtLocation module (there's examples in the docs) and switch the provider plugin to one supporting google maps (there's a user contributed plugin for google maps You'll need to compile the plugin, but aside from that I have tested it and it works.

    Kind regards.

  • Thank you. Because I am very new to Qt, is there any full functioning example with google maps on Git or here in Qt forum? -- A kind of minimal example?

  • Lifetime Qt Champion


    You have to build and install the plugin first:

    make install

    Then you can follow the example @kshegunov linked in his answer and change the selected plugin to use the one you just installed.

  • @SGaist

    This means calling in command line:

    1. qmake -o Makefile <Path to File>.pro
    2. make ??
    3. make install ??

    Can you help me with point 2 and 3 again? Thank you!!

  • Lifetime Qt Champion

    What OS are you developing on ?

  • I develop on Windows 10. Thanks for any help again!

  • Lifetime Qt Champion

    Visual Studio or MinGW ?

  • Hi!
    Sorry for the uncomplete answer.
    I use Windows 10, Qt 5.7 and Visual Studio 2013.

  • Lifetime Qt Champion

    Then replace make with nmake

  • Hi everyone!

    First thanks for all advices, very helpful. The plugin is installed.

    Now I am facing the problem that I want to integrate Google Maps into the qml code with the help of the QtLocation module.
    Do you have any kind of a minimal code example?

    What do you mean by "switch the provider plugin to one supporting google maps"?

    Kind regards.

  • Moderators

    I mean that after you download and compile one of the QtLocation examples, you open the QML file find where the plugin is specified and change the name, thus you load another plugin that provide maps.

  • Now, for all who wants to integrate Google Maps in their application, here is a summary with a minimal code example.
    Tested system environment: Windows 10, Qt 5.7, Visual Studio Compiler.

    1. Install the following plugin: by calling the qmake, nmake and nmake install via cmd

      If struggling with compiling the plugin in cmd regarding the error x86/x64, use the compiler of a real 64bit compiler of Visual Studio (not the Express version of Visual Studio) and call the vcvarsall.bat file with the parameter x64 first.

    2. Using the following qml code to call the map in your qt application.

      Plugin {
          id: myPlugin
          name: "googlemaps"
          PluginParameter { name: "googlemaps";
              value: "" }
      Map {
          anchors.fill: parent
          plugin: myPlugin
          zoomLevel: 0
          Component.onCompleted: {
              for( var i_type in supportedMapTypes ) {
                  print (supportedMapTypes[i_type].name)
                  if( supportedMapTypes[i_type].name.localeCompare( "Custom URL Map" ) === 0 ) {
                      activeMapType = supportedMapTypes[i_type]

    Good luck! =)

  • @simonh5 @SGaist
    I tried to qmake the project, but I get the following error:

    Project ERROR: Unknown module(s) in QT: positioning-private location-private 

    I'm on Ubuntu 14.04 and Qt 5.8. I googled that error but could not find a lot...any guess how to fix this? :)

  • Lifetime Qt Champion


    With which version of Qt are you building that plugin ?

  • @SGaist

    Hey, that was fast and a good hint, thank you :) My standard qmake was the wrong version. Qmake from Qt 5.8 works, but make (g++ (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4) throws directly the next errors:

    g++: error: unrecognized command line option ‘-std=c++1z’
    g++: error: unrecognized command line option ‘-Wdate-time’

    For the first one I found this Qt bug-report:, for the second one this:, but it seems like both should be fixed Qt 5.6...

    I'm not sure if this a Qt-related problem anymore, but any ideas? I can barely find anything about those on Google.

  • Lifetime Qt Champion

    For a quick solution you can edit the qt_common.prf and modify the logic selecting the date-time warning. As for the std switch IIRC you can use something like CONFIG += c++14.

  • @SGaist Hi,

    I edited the mkspecs/features/qt_common.prf and commented out the warning for the Wdate-time. Also I edited the mkspecs/common/q++-base.conf and replaced every "1z" with "11" (found this suggestion somewhere else, because your CONFIG =+ c++14 seemed not to work). I have to be honest, I don't know exactly what the error was and what I did to fix it, but it works now :D Thank you for your help :)

  • Lifetime Qt Champion

    You changed the standard used to compile your application. 1z is the equivalent of C++17 IIRC.

Log in to reply