Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Using Google Maps in an native mobile application

    Mobile and Embedded
    5
    19
    3801
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • ?
      Guest last edited by kshegunov

      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]

      kshegunov 1 Reply Last reply Reply Quote 0
      • kshegunov
        kshegunov Moderators @Guest last edited by

        Hi,
        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 https://github.com/vladest/googlemaps). You'll need to compile the plugin, but aside from that I have tested it and it works.

        Kind regards.

        Read and abide by the Qt Code of Conduct

        1 Reply Last reply Reply Quote 2
        • S
          simonh5 last edited by

          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?

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            Hi,

            You have to build and install the plugin first:

            qmake
            make
            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.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 2
            • S
              simonh5 last edited by simonh5

              @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!!

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                What OS are you developing on ?

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply Reply Quote 0
                • S
                  simonh5 last edited by

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

                  1 Reply Last reply Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by

                    Visual Studio or MinGW ?

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply Reply Quote 0
                    • S
                      simonh5 last edited by

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

                      1 Reply Last reply Reply Quote 0
                      • SGaist
                        SGaist Lifetime Qt Champion last edited by

                        Then replace make with nmake

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply Reply Quote 3
                        • S
                          simonh5 last edited by

                          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?

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

                          Kind regards.

                          kshegunov 1 Reply Last reply Reply Quote 0
                          • kshegunov
                            kshegunov Moderators @simonh5 last edited by

                            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.

                            Read and abide by the Qt Code of Conduct

                            1 Reply Last reply Reply Quote 2
                            • S
                              simonh5 last edited by simonh5

                              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: https://github.com/vladest/googlemaps 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: "http://maps.googleapis.com/maps/api/js?sensor=false" }
                                }
                              
                                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! =)

                              1 Reply Last reply Reply Quote 2
                              • D
                                danielusa last edited by

                                @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? :)

                                1 Reply Last reply Reply Quote 0
                                • SGaist
                                  SGaist Lifetime Qt Champion last edited by

                                  Hi,

                                  With which version of Qt are you building that plugin ?

                                  Interested in AI ? www.idiap.ch
                                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                  D 1 Reply Last reply Reply Quote 1
                                  • D
                                    danielusa @SGaist last edited by

                                    @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: https://bugreports.qt.io/browse/QTBUG-51644, for the second one this: https://bugreports.qt.io/browse/QTBUG-53017, 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.

                                    1 Reply Last reply Reply Quote 0
                                    • SGaist
                                      SGaist Lifetime Qt Champion last edited by

                                      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.

                                      Interested in AI ? www.idiap.ch
                                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      D 1 Reply Last reply Reply Quote 1
                                      • D
                                        danielusa @SGaist last edited by

                                        @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 :)

                                        1 Reply Last reply Reply Quote 0
                                        • SGaist
                                          SGaist Lifetime Qt Champion last edited by

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

                                          Interested in AI ? www.idiap.ch
                                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                          1 Reply Last reply Reply Quote 1
                                          • First post
                                            Last post