Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Porting to Qt5 from Qt4 QGraphicsGeoMap

Porting to Qt5 from Qt4 QGraphicsGeoMap

Scheduled Pinned Locked Moved Unsolved General and Desktop
7 Posts 2 Posters 2.6k Views
  • 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.
  • K Offline
    K Offline
    kiye
    wrote on last edited by
    #1

    I found a simply code in order to display the Nokia map with Qt4 and QtMobility.
    Since the Nokia Maps was sold, white strips were inserted into map. I wanted to realize the porting to Qt5 to test the new Here plugin. I could'nt do it because QGraphicsGeoMap is not available with Qt5.5.2

    How to replace QGraphicsGeoMap , and display simply the Nokia/Here map?

    Thanks a lot for your help

    //my code here
    #include <QApplication>
    #include <QMessageBox>
    #include <QGraphicsScene>
    #include <QGraphicsView>
    #include <QGeoCoordinate>
    #include <QGeoMappingManager>
    #include <QGeoServiceProvider>
    
    using namespace QtMobility;
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);
        QStringList services = QGeoServiceProvider::availableServiceProviders();
    
        if (services.isEmpty()) {
            QMessageBox::critical(0,
                app.translate("graphicsmap", "Graphics Map"),
                app.translate("graphicsmap",
                              "Failed to find any map services. Please ensure that "
                              "the location services plugins for Qt Mobility have "
                              "been built and, if necessary, set the QT_PLUGIN_PATH "
                              "environment variable to the location of the Qt Mobility "
                              "plugins directory."));
            return 1;
        }
    
        QGeoServiceProvider service("nokia");
        if (service.error() != service.NoError) {
            QMessageBox::critical(0,
                app.translate("graphicsmap", "Graphics Map"),
                app.translate("graphicsmap",
                              "The service failed with the following error:\n"
                              "%1").arg(service.errorString()));
            return 1;
        }
    
        QGeoMappingManager *manager = service.mappingManager();
        
        QGraphicsScene scene;
        QGraphicsView view;
        view.setScene(&scene);
        
        QGraphicsGeoMap *geoMap = new QGraphicsGeoMap(manager);
        scene.addItem(geoMap);
        
        geoMap->resize(300, 300);
        geoMap->setCenter(QGeoCoordinate(52.75, -2.75));
        geoMap->setMapType(QGraphicsGeoMap::TerrainMap);
        geoMap->setZoomLevel(10);
        
        view.show();
        return app.exec();
    }```
    raven-worxR 1 Reply Last reply
    0
    • K kiye

      I found a simply code in order to display the Nokia map with Qt4 and QtMobility.
      Since the Nokia Maps was sold, white strips were inserted into map. I wanted to realize the porting to Qt5 to test the new Here plugin. I could'nt do it because QGraphicsGeoMap is not available with Qt5.5.2

      How to replace QGraphicsGeoMap , and display simply the Nokia/Here map?

      Thanks a lot for your help

      //my code here
      #include <QApplication>
      #include <QMessageBox>
      #include <QGraphicsScene>
      #include <QGraphicsView>
      #include <QGeoCoordinate>
      #include <QGeoMappingManager>
      #include <QGeoServiceProvider>
      
      using namespace QtMobility;
      
      int main(int argc, char *argv[])
      {
          QApplication app(argc, argv);
          QStringList services = QGeoServiceProvider::availableServiceProviders();
      
          if (services.isEmpty()) {
              QMessageBox::critical(0,
                  app.translate("graphicsmap", "Graphics Map"),
                  app.translate("graphicsmap",
                                "Failed to find any map services. Please ensure that "
                                "the location services plugins for Qt Mobility have "
                                "been built and, if necessary, set the QT_PLUGIN_PATH "
                                "environment variable to the location of the Qt Mobility "
                                "plugins directory."));
              return 1;
          }
      
          QGeoServiceProvider service("nokia");
          if (service.error() != service.NoError) {
              QMessageBox::critical(0,
                  app.translate("graphicsmap", "Graphics Map"),
                  app.translate("graphicsmap",
                                "The service failed with the following error:\n"
                                "%1").arg(service.errorString()));
              return 1;
          }
      
          QGeoMappingManager *manager = service.mappingManager();
          
          QGraphicsScene scene;
          QGraphicsView view;
          view.setScene(&scene);
          
          QGraphicsGeoMap *geoMap = new QGraphicsGeoMap(manager);
          scene.addItem(geoMap);
          
          geoMap->resize(300, 300);
          geoMap->setCenter(QGeoCoordinate(52.75, -2.75));
          geoMap->setMapType(QGraphicsGeoMap::TerrainMap);
          geoMap->setZoomLevel(10);
          
          view.show();
          return app.exec();
      }```
      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @kiye
      QtLocation in Qt5 doesn't rely anymore on the QgraphicsView/QGraphicsScene framework.
      So now there is QGeoMap class instead. But some classes are still private and not part of the public API yet - like this one. I think they will be along with Qt 5.7.

      But i don't understand why you want to bring up all the effort, when the Nokia (now called HERE) maps are still available as plugin in the QtLocation module?

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      K 1 Reply Last reply
      0
      • raven-worxR raven-worx

        @kiye
        QtLocation in Qt5 doesn't rely anymore on the QgraphicsView/QGraphicsScene framework.
        So now there is QGeoMap class instead. But some classes are still private and not part of the public API yet - like this one. I think they will be along with Qt 5.7.

        But i don't understand why you want to bring up all the effort, when the Nokia (now called HERE) maps are still available as plugin in the QtLocation module?

        K Offline
        K Offline
        kiye
        wrote on last edited by
        #3

        @raven-worx

        @raven-worx said:

        But i don't understand why you want to bring up all the effort, when the Nokia (now called HERE) maps are still available as plugin in the QtLocation module?

        That's just the reason why i want to test it. My problem is displaying the map on the scene (scene.addItem(???); )
        I 'm not be able to do that simply with QGeoMap

        raven-worxR 1 Reply Last reply
        0
        • K kiye

          @raven-worx

          @raven-worx said:

          But i don't understand why you want to bring up all the effort, when the Nokia (now called HERE) maps are still available as plugin in the QtLocation module?

          That's just the reason why i want to test it. My problem is displaying the map on the scene (scene.addItem(???); )
          I 'm not be able to do that simply with QGeoMap

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          @kiye
          yes because it isn't based on the graphics view framework. Instead there are is a QML Map element. So use a QQuickView to load a simple QML just displaying a Map.
          Now the workflow happens mainly behind the scenes in the QtLocation framework. You just need to implement the given API.
          See the github link to the official HERE plugin as a reference.

          --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
          If you have a question please use the forum so others can benefit from the solution in the future

          K 1 Reply Last reply
          0
          • raven-worxR raven-worx

            @kiye
            yes because it isn't based on the graphics view framework. Instead there are is a QML Map element. So use a QQuickView to load a simple QML just displaying a Map.
            Now the workflow happens mainly behind the scenes in the QtLocation framework. You just need to implement the given API.
            See the github link to the official HERE plugin as a reference.

            K Offline
            K Offline
            kiye
            wrote on last edited by
            #5

            @raven-worx
            I've tested the example 'Map Viewer (QML)'. The osm plugin works well, not the nokia one :(
            However, I execute the program with parameters "--plugin.here.app_id myappid --plugin.here.token myappcode".
            It seems there is bugs in nokia(here) plugin.
            Logs during execution:
            italicised textError message:Qt Location requires app_id and token parameters.
            Please register at https://developer.here.com/ to get your personal application credentials.
            The issue seems to be in the following function:

            void checkUsageTerms(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString)
                {
                    QString appId, token;
            
                    appId = parameters.value(QStringLiteral("here.app_id")).toString();
                    token = parameters.value(QStringLiteral("here.token")).toString();
            
                    if (isValidParameter(appId) && isValidParameter(token))
                        return;
            
                    if (parameters.contains(QStringLiteral("app_id")) || parameters.contains(QStringLiteral("token")))
                        qWarning() << QStringLiteral("Please prefix 'app_id' and 'token' with prefix 'here' (e.g.: 'here.app_id')");
            
                    *error = QGeoServiceProvider::MissingRequiredParameterError;
                    *errorString = QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, MISSED_CREDENTIALS);
                }
            

            To give an example that does't work is not serious from Qt Team.

            raven-worxR 1 Reply Last reply
            0
            • K kiye

              @raven-worx
              I've tested the example 'Map Viewer (QML)'. The osm plugin works well, not the nokia one :(
              However, I execute the program with parameters "--plugin.here.app_id myappid --plugin.here.token myappcode".
              It seems there is bugs in nokia(here) plugin.
              Logs during execution:
              italicised textError message:Qt Location requires app_id and token parameters.
              Please register at https://developer.here.com/ to get your personal application credentials.
              The issue seems to be in the following function:

              void checkUsageTerms(const QVariantMap &parameters, QGeoServiceProvider::Error *error, QString *errorString)
                  {
                      QString appId, token;
              
                      appId = parameters.value(QStringLiteral("here.app_id")).toString();
                      token = parameters.value(QStringLiteral("here.token")).toString();
              
                      if (isValidParameter(appId) && isValidParameter(token))
                          return;
              
                      if (parameters.contains(QStringLiteral("app_id")) || parameters.contains(QStringLiteral("token")))
                          qWarning() << QStringLiteral("Please prefix 'app_id' and 'token' with prefix 'here' (e.g.: 'here.app_id')");
              
                      *error = QGeoServiceProvider::MissingRequiredParameterError;
                      *errorString = QCoreApplication::translate(NOKIA_PLUGIN_CONTEXT_NAME, MISSED_CREDENTIALS);
                  }
              

              To give an example that does't work is not serious from Qt Team.

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by raven-worx
              #6

              @kiye said:

              I've tested the example 'Map Viewer (QML)'. The osm plugin works well, not the nokia one :(
              However, I execute the program with parameters "--plugin.here.app_id myappid --plugin.here.token myappcode".
              It seems there is bugs in nokia(here) plugin.

              i am not sure, but is passing the parameters via command line arguments even possible?
              Normally you should pass them to the plugin directly. QML / C++

              --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
              If you have a question please use the forum so others can benefit from the solution in the future

              K 1 Reply Last reply
              0
              • raven-worxR raven-worx

                @kiye said:

                I've tested the example 'Map Viewer (QML)'. The osm plugin works well, not the nokia one :(
                However, I execute the program with parameters "--plugin.here.app_id myappid --plugin.here.token myappcode".
                It seems there is bugs in nokia(here) plugin.

                i am not sure, but is passing the parameters via command line arguments even possible?
                Normally you should pass them to the plugin directly. QML / C++

                K Offline
                K Offline
                kiye
                wrote on last edited by
                #7

                @raven-worx
                Yes I know, but this example is like that. The plugin is built dynamically with the parameters.
                I put a breakpoint in checkUsageTerms function. I can see my parameters with good values but appId and token are not correct.
                "appId = parameters.value(QStringLiteral("here.app_id")).toString();"
                "token = parameters.value(QStringLiteral("here.token")).toString();"

                parameters is good:
                parameters[o] : key= "here.app_id" value="myappid"
                parameters[1] : key="here.token value="myappcode"

                but
                appId="" (value = 0xC0A2AA6B in memory)
                token="" (value = 0xC0A2AA6B in memory)

                I don't understand why parameters.value("key").toString() failed.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved