[Marble-devel] Re: Show GPS Position in MarbleWidget

Dennis Nienhüser earthwings at gentoo.org
Fri Apr 1 11:22:37 CEST 2011


Hi Malte,

On 01.04.2011 11:06, Malte Klug wrote:
> Hello everybody,
>
> I am fairly new to Marble, as I have only been working with it for a couple of days. What I am currently doing is using the MarbleWidget in a QML file as a part of an application. For this purpose, I have wrapped the MarbleWidget in a class inheriting from QGraphicsProxyWidget in order to register this class as a new QML type. All the configuration I needed to do (e.g. setShowCrosshairs(false)) is done in the constructor of said wrapper class. Up to here everything went well.

it would be great if you could use our experimental QML support for 
that. The plugin we provide (shipped with Marble 1.0 and later) provides 
a MarbleWidget usable in QML and some more stuff. See 
http://edu.kde.org/marble/current.php at the bottom of the website. 
We're interested in pushing this further, so feedback is very welcome 
(use cases, missing features/methods etc).

> Now I am trying to show the GPS position. I assumed this would be possible by calling MarbleWidget's setShowGps(true). However, this seems to have no effect at all, although showGps() returns true.

It enables the visual part of showing the GPS location. Once a GPS 
position is available, it would be shown when showGps() is true. 
setShowGps does not start any position provider, however, so the call 
alone seems to have no effect indeed.

> My GPS position provider is gpsd, which works fine. I was able to verify this using xgps, even the Marble application itself shows the position when activated under "Current Location". I read every Marble tutorial, how-to and example I could get my hands on and also briefly checked the archive of this mailing list, but I have not found anything on how to get the GPS position shown in MarbleWidget. I do not know, whether I am totally missing out something, but I did not manage to make any progress in this, so maybe you guys could give me a hint on how I could go on/solve the issue.
> Here are some further information about the environment I am developing in: I use Ubuntu 10.10, Qt 4.7 and QtCreator.
>
> Thanks in advance
> Malte Klug

Please give the following a try (not compiled/tested, but you'll get the 
idea):

PluginManager* pluginManager = marbleWidget->model()->pluginManager();
QList<PositionProviderPlugin*> = 
pluginManager->createPositionProviderPlugins();
foreach( const PositionProviderPlugin *plugin, 
d->m_positionProviderPlugins ) {
   if ( plugin->nameId() == "gpsd" ) {
     PositionProviderPlugin* instance = plugin->newInstance();
     PositionTracking *tracking = marbleWidget->model()->positionTracking();
     tracking->setPositionProviderPlugin( instance );
     marbleWidget->setShowGps( true );
     marbleWidget->update();
   }
}

Regards,
Dennis



More information about the Marble-devel mailing list