Qt Forum

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

    Unsolved Porting to Qt5 from Qt4 QGraphicsGeoMap

    General and Desktop
    2
    7
    1810
    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.
    • K
      kiye last edited by

      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-worx 1 Reply Last reply Reply Quote 0
      • raven-worx
        raven-worx Moderators @kiye last edited by 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?

        --- 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 Reply Quote 0
        • K
          kiye @raven-worx last edited by

          @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-worx 1 Reply Last reply Reply Quote 0
          • raven-worx
            raven-worx Moderators @kiye last edited by

            @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 Reply Quote 0
            • K
              kiye @raven-worx last edited by

              @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-worx 1 Reply Last reply Reply Quote 0
              • raven-worx
                raven-worx Moderators @kiye last edited by 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++

                --- 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 Reply Quote 0
                • K
                  kiye @raven-worx last edited by

                  @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 Reply Quote 0
                  • First post
                    Last post