Select to view content in your preferred language

What is the best way to pass arbitrary coordinates to a QML app?

924
3
02-01-2019 06:04 AM
SimonKoch
New Contributor

I want to use the locationDisplay functionality of a MapView (i.e. for simulation purposes)

I haven't had much luck trying to implement a custom PositionSource in C++...I  tried to base it on the Qt Positioning Log File example, but it doesn't use QML.

When I access the custom PositionSource.position attribitute generated in C++ or Python, I get a "Qvariant(QGeoPositionInfo)". Why?

Basically, I have a stream of regular position update which I want to display on a map.

Thx!

0 Kudos
3 Replies
LucasDanzinger
Esri Frequent Contributor

The Location Display was built to work with Qt's native position type, PositionSource, and any subclasses of it. If you can manage to get a customized PositionSource going, that should work just fine with Location Display. We've subclassed QGeoPositionInfoSource to make a Position Source based off GPX files instead (for an example app) - dynamic-situational-awareness-qt/GPXLocationSimulator.h at master · Esri/dynamic-situational-awarene... 

Not sure on the specifics about why the log file example isn't working - might be good to cross post on Qt's forums too.

Also, if you wanted, you could simply display a Graphic on the Map/Scene and update it's geometry as it comes in. This would require no position source. But it also means you won't be using Location Display, which means you will loose some built in functionality, like automatically follow/center. However, there are other ways you can accomplish similar things with the API. 

SimonKoch
New Contributor

Hi Lucas, thanks for your reply! I didn‘t geht the QML PositionSource working, I guess my approach is wrong…I thought I had to subclass a QGeoPositionInfoSource on the C++ side and register it via qmlRegisterType in QML (pretty new to Qt…).

Your suggestion using graphics and updating geometries works, though I still have a follow-up question: how can I smoothly animate the transitions between two coordinate points and avoid the disappearing and reappearing of the graphic (similar to the smoothly moving LocationDisplay)? Is there any higher level functionality or would I have to implement the transitions on my own?

I‘d be thankful if you could come up with another suggestion and shed some light on correctly customizing a QML PositionSource!

0 Kudos
LucasDanzinger
Esri Frequent Contributor

We don't have a high level animation framework in the API yet. However, using a timer and our GeometryEngine, you can create animation. We do this in the GeoElement viewshed sample, where you click on the scene, and the graphic animates towards it until it reaches the point - arcgis-runtime-samples-qt/ViewshedGeoElement.qml at master · Esri/arcgis-runtime-samples-qt · GitHub 

As for a custom PositionSource, I believe you are correct that you need to subclass it and then register it as a QML Type. The DSA link I sent you shows you the subclassing of it to make it a GPX reader, but in this case, it is used in our C++ API instead of QML, so it doesn't need to be registered as a QML type. I unfortunately don't have an example for you of this. I'll let you know if I come up with anything to share. Otherwise, cross posting in Qt's forum might be good. They don't usually know about our types, but they know about Qt types like PositionSource/QGeoPositionInfoSource.

0 Kudos