<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Provide position through QGeoPositionInfoSource in Qt Maps SDK Questions</title>
    <link>https://community.esri.com/t5/qt-maps-sdk-questions/provide-position-through-qgeopositioninfosource/m-p/52549#M258</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're just need to call start, for example in Component.onCompleted:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;Component.onCompleted: mapView.locationDisplay.start();&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 10 Jan 2020 22:09:49 GMT</pubDate>
    <dc:creator>GuillaumeBelz</dc:creator>
    <dc:date>2020-01-10T22:09:49Z</dc:date>
    <item>
      <title>Provide position through QGeoPositionInfoSource</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/provide-position-through-qgeopositioninfosource/m-p/52546#M255</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear all, I am making an application which must show the location of a ship. The actual location comes from outside the application which I am making. To show the location, I want to make use of the LocationDisplay class. So I started a default ArcGIS application in Qt Creator (I tried both a QML and C++ app), and made a class, which is derived from QGeoPositionInfoSource, according to this example(https://github.com/Esri/dynamic-situational-awareness-qt/blob/master/Shared/GPXLocationSimulator.h), linked by LDanzinger-esristaff, also on this forum. However, I just can't seem to get it to work. It seems I just don't understand it, and to be hones I'm getting a bit frustrated &lt;IMG src="https://community.esri.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My code is as follows:&lt;/P&gt;&lt;P&gt;The header:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;#ifndef SHIPPOSITIONSOURCE_H&lt;BR /&gt;#define SHIPPOSITIONSOURCE_H&lt;/P&gt;&lt;P&gt;#include &amp;lt;QGeoPositionInfoSource&amp;gt;&lt;/P&gt;&lt;P&gt;class ShipPositionSource : public QGeoPositionInfoSource&lt;BR /&gt;{&lt;BR /&gt; Q_OBJECT&lt;/P&gt;&lt;P&gt;public:&lt;BR /&gt; explicit ShipPositionSource(QObject* parent = nullptr);&lt;BR /&gt; ~ShipPositionSource();&lt;/P&gt;&lt;P&gt;QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const override;&lt;BR /&gt; PositioningMethods supportedPositioningMethods() const override;&lt;BR /&gt; int minimumUpdateInterval() const override;&lt;BR /&gt; QGeoPositionInfoSource::Error error() const override;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;public slots:&lt;BR /&gt; void startUpdates() override;&lt;BR /&gt; void stopUpdates() override;&lt;BR /&gt; void requestUpdate(int timeout = 0) override;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;private:&lt;/P&gt;&lt;P&gt;QGeoPositionInfo currentPosition;&lt;BR /&gt; QGeoPositionInfoSource::Error lastError = QGeoPositionInfoSource::NoError;&lt;/P&gt;&lt;P&gt;bool started;&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;#endif // SHIPPOSITIONSOURCE_H&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;The source:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;#include "shippositionsource.h"&lt;/P&gt;&lt;P&gt;ShipPositionSource::ShipPositionSource(QObject* parent) :&lt;BR /&gt; QGeoPositionInfoSource(parent)&lt;BR /&gt;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;setUpdateInterval(500);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;currentPosition.setCoordinate(QGeoCoordinate(52.920905, 4.862173));&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;emit positionUpdated(currentPosition);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;ShipPositionSource::~ShipPositionSource()&lt;BR /&gt;{}&lt;/P&gt;&lt;P&gt;void ShipPositionSource::startUpdates()&lt;BR /&gt;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;if(started)&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;return;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;started = true;&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;//TODO: start communication with bridge&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void ShipPositionSource::stopUpdates()&lt;BR /&gt;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;if(!started)&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;return;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;started = false;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;//TODO: stop communication with bridge&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void ShipPositionSource::requestUpdate(int timeout)&lt;BR /&gt;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;Q_UNIMPLEMENTED();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;QGeoPositionInfo ShipPositionSource::lastKnownPosition(bool fromSatellitePositioningMethodsOnly) const&lt;BR /&gt;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;Q_UNUSED(fromSatellitePositioningMethodsOnly);&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;return currentPosition;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;QGeoPositionInfoSource::PositioningMethods ShipPositionSource::supportedPositioningMethods() const&lt;BR /&gt;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;return QGeoPositionInfoSource::PositioningMethod::NoPositioningMethods;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int ShipPositionSource::minimumUpdateInterval() const&lt;BR /&gt;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;return updateInterval();&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;QGeoPositionInfoSource::Error ShipPositionSource::error() const&lt;BR /&gt;{&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;return lastError;&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;BR /&gt;I made a Quick C++ app, called TestProject, and in TestProject.cpp I only edited the TestProject::setMapView method with the following lines:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;m_mapView = mapView;&lt;BR /&gt;m_mapView-&amp;gt;locationDisplay()-&amp;gt;setPositionSource(&amp;amp;positionSource);&lt;BR /&gt; m_mapView-&amp;gt;locationDisplay()-&amp;gt;setAutoPanMode(LocationDisplayAutoPanMode::Recenter);&lt;BR /&gt;m_mapView-&amp;gt;locationDisplay()-&amp;gt;start();&lt;BR /&gt;m_mapView-&amp;gt;setMap(m_map);&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result is that I don't see any location updated, or the map centering on the position I gave in the constructor. I must be doing something wrong or I don't understand something, but I don't see what. I would be very thankful for hints and tips!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Dec 2019 12:56:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/provide-position-through-qgeopositioninfosource/m-p/52546#M255</guid>
      <dc:creator>Arjenvan_Heteren</dc:creator>
      <dc:date>2019-12-23T12:56:16Z</dc:date>
    </item>
    <item>
      <title>Re: Provide position through QGeoPositionInfoSource</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/provide-position-through-qgeopositioninfosource/m-p/52547#M256</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi &lt;A href="https://community.esri.com/migrated-users/387378"&gt;Arjen van Heteren&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The "updated" signals should be emitted when the map is ready to handle them. If you're emitting a signal in the constructor, it's never possible to connect to the signal. The best is probably to use a timer, like in the Lucas' code (with "setSingleShot(true)" if you want to emit only once).&lt;/P&gt;&lt;P&gt;Note: don't forget to initialize "started" before use it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 27 Dec 2019 18:39:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/provide-position-through-qgeopositioninfosource/m-p/52547#M256</guid>
      <dc:creator>GuillaumeBelz</dc:creator>
      <dc:date>2019-12-27T18:39:24Z</dc:date>
    </item>
    <item>
      <title>Re: Provide position through QGeoPositionInfoSource</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/provide-position-through-qgeopositioninfosource/m-p/52548#M257</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Oh wow, I should've thought of that myself. It works now, thank you very much &lt;A href="https://community.esri.com/migrated-users/182431"&gt;Guillaume Belz&lt;/A&gt;!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Now I want to do the same in a QML app. So I made a default ArcGIS Qt Quick QML app, copied my now working shippositionsource in this project, and registered this class with the following line:&amp;nbsp;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;qmlRegisterType&amp;lt;ShipPositionSource&amp;gt;("Ship.Source", 1, 0, "ShipPositionSource");&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;In the main.qml, I added of course the import:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;import Ship.Source 1.0&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;However, I'm now getting stuck at how to get this to work. My complete main.qml file is as follows:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;&lt;BR /&gt;// Copyright 2019 ESRI&lt;BR /&gt;//&lt;BR /&gt;// All rights reserved under the copyright laws of the United States&lt;BR /&gt;// and applicable international laws, treaties, and conventions.&lt;BR /&gt;//&lt;BR /&gt;// You may freely redistribute and use this sample code, with or&lt;BR /&gt;// without modification, provided you include the original copyright&lt;BR /&gt;// notice and use restrictions.&lt;BR /&gt;//&lt;BR /&gt;// See the Sample code usage restrictions document for further information.&lt;BR /&gt;//&lt;/P&gt;&lt;P&gt;import QtPositioning 5.12&lt;BR /&gt;import QtQuick 2.6&lt;BR /&gt;import QtQuick.Controls 2.13&lt;BR /&gt;import QtSensors 5.12&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;import Esri.ArcGISRuntime 100.7&lt;BR /&gt;import &lt;SPAN style="background-color: #f6f6f6;"&gt;Ship.Source&lt;/SPAN&gt; 1.0&lt;/P&gt;&lt;P&gt;ApplicationWindow&lt;BR /&gt;{&lt;BR /&gt; id: appWindow&lt;BR /&gt; width: 800&lt;BR /&gt; height: 600&lt;BR /&gt; title: "Gui"&lt;/P&gt;&lt;P&gt;property double mapMenuRatio: 0.7&lt;BR /&gt; property double maxMapMenuRation: 0.9&lt;BR /&gt; property double minMapMenuRation: 0.5&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; SplitView&lt;BR /&gt; {&lt;BR /&gt; id: splitViewBase&lt;BR /&gt; anchors.fill: parent&lt;BR /&gt; orientation: Qt.Horizontal&lt;/P&gt;&lt;P&gt;Rectangle {&lt;BR /&gt; id: centerItem&lt;BR /&gt; SplitView.minimumWidth: 50&lt;BR /&gt; SplitView.fillWidth: true&lt;BR /&gt; color: "black"&lt;/P&gt;&lt;P&gt;MapView&lt;BR /&gt; {&lt;BR /&gt; id: mapView&lt;BR /&gt; anchors.fill: parent&lt;BR /&gt; // set focus to enable keyboard navigation&lt;BR /&gt; focus: true&lt;/P&gt;&lt;P&gt;// add a map to the mapview&lt;BR /&gt; Map&lt;BR /&gt; {&lt;BR /&gt; id: map&lt;BR /&gt; // add the BasemapOceans basemap to the map&lt;BR /&gt; BasemapOceans {}&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;locationDisplay&lt;BR /&gt; {&lt;BR /&gt; positionSource :ShipPositionSource{}&lt;BR /&gt; autoPanMode: Enums.LocationDisplayAutoPanModeRecenter&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;Rectangle {&lt;BR /&gt; id: menu&lt;/P&gt;&lt;P&gt;implicitWidth: appWindow.width * (1 - mapMenuRatio)&lt;BR /&gt; SplitView.maximumWidth: appWindow.width * (1 - minMapMenuRation)&lt;BR /&gt; color: "brown"&lt;/P&gt;&lt;P&gt;//MenuFrame&lt;BR /&gt; //{&lt;BR /&gt; // anchors.fill: parent&lt;BR /&gt; //}&lt;BR /&gt; }&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Due to some debug logging, I can see the ShipPositionSource has been created, but I can't actually see the position yet. I think I have to enable the locationDisplay, but I can't seem to find how to do this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be very much appreciated again!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 06 Jan 2020 10:59:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/provide-position-through-qgeopositioninfosource/m-p/52548#M257</guid>
      <dc:creator>Arjenvan_Heteren</dc:creator>
      <dc:date>2020-01-06T10:59:47Z</dc:date>
    </item>
    <item>
      <title>Re: Provide position through QGeoPositionInfoSource</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/provide-position-through-qgeopositioninfosource/m-p/52549#M258</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You're just need to call start, for example in Component.onCompleted:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;Component.onCompleted: mapView.locationDisplay.start();&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 10 Jan 2020 22:09:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/provide-position-through-qgeopositioninfosource/m-p/52549#M258</guid>
      <dc:creator>GuillaumeBelz</dc:creator>
      <dc:date>2020-01-10T22:09:49Z</dc:date>
    </item>
    <item>
      <title>Re: Provide position through QGeoPositionInfoSource</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/provide-position-through-qgeopositioninfosource/m-p/52550#M259</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you for your answer!&lt;/P&gt;&lt;P&gt;I added a Component.onCompleted in the MapView (id: mapView), which I validated was called by also putting in a log line.&lt;/P&gt;&lt;P&gt;However, when I ran the application, I saw in the output the following line:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;QMetaObject::invokeMethod: No such method ShipPositionSource::start()&lt;BR /&gt;&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;So I added a public slot, called start(), in my ShipPositionSource class. Unfortunately, nothing happened yet. So I thought, maybe I have to start the position source itself somehow. So I added a oncompleted event to the positionsource, where I call startUpdates(). However, this also didn't work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For clarity, my MapView now looks as follows:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;MapView&lt;BR /&gt;{&lt;BR /&gt; id: mapView&lt;BR /&gt; anchors.fill: parent&lt;BR /&gt; // set focus to enable keyboard navigation&lt;BR /&gt; focus: true&lt;/P&gt;&lt;P&gt;// add a map to the mapview&lt;BR /&gt; Map&lt;BR /&gt; {&lt;BR /&gt; id: map&lt;BR /&gt; // add the BasemapOceans basemap to the map&lt;BR /&gt; BasemapOceans {}&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;locationDisplay&lt;BR /&gt; {&lt;BR /&gt; positionSource: ShipPositionSource&lt;BR /&gt; {&lt;BR /&gt; id: src&lt;/P&gt;&lt;P&gt;onPositionUpdated:&lt;BR /&gt; {&lt;BR /&gt; console.log("onPositionUpdated called");&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;Component.onCompleted:&lt;BR /&gt; {&lt;BR /&gt; src.startUpdates();&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;autoPanMode: Enums.LocationDisplayAutoPanModeRecenter&lt;BR /&gt; wanderExtentFactor: 0.1&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;Component.onCompleted:&lt;BR /&gt; {&lt;BR /&gt; locationDisplay.start();&lt;BR /&gt; console.log("on completed called");&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;My ShipPositionSource class hasn't been changed from the one in my starting post, with the exception of a timer, which gives a new position every 2 seconds, via the following line:&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;emit positionUpdated(currentPosition);&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I'm looking forward to any advice.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 13 Jan 2020 08:46:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/provide-position-through-qgeopositioninfosource/m-p/52550#M259</guid>
      <dc:creator>Arjenvan_Heteren</dc:creator>
      <dc:date>2020-01-13T08:46:08Z</dc:date>
    </item>
  </channel>
</rss>

