<?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: Dynamically connect a position source in Qt Maps SDK Questions</title>
    <link>https://community.esri.com/t5/qt-maps-sdk-questions/dynamically-connect-a-position-source/m-p/1073881#M4292</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/389538"&gt;@ChristopherSwingley&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp; We have a few samples that use similar workflows. If your plugin conforms to the&amp;nbsp;&lt;SPAN&gt;QGeoPositionInfoSource class, then we can work directly with it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You can start, stop and replace the entire data source on the LocationDisplay at any time provided that you stop it before replacing it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here is some sample code you can work with:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;// take the default
mapView-&amp;gt;locationDisplay()-&amp;gt;setDataSource(new DefaultLocationDataSource(this));
mapView-&amp;gt;locationDisplay()-&amp;gt;start();

// then later on, if you want to change it to a custom data source:

mapView-&amp;gt;locationDisplay()-&amp;gt;stop();

auto* newSource = DefaultLocationDataSource(this);
newSource-&amp;gt;setPositionInfoSource(myCustomPositionInfoSource);

mapView-&amp;gt;locationDisplay()-&amp;gt;setDataSource(newSource);

mapView-&amp;gt;locationDisplay()-&amp;gt;start();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can replace this as many times as needed until it's configured properly. You can also delay setting any locationDisplay settings at all until you have them configured and ready.&lt;/P&gt;&lt;P&gt;Here are some samples where we show the basic workflows of the LocationDisplay and LocationDataSource.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_CppSamples/Maps/ShowLocationHistory" target="_blank"&gt;https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_CppSamples/Maps/ShowLocationHistory&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_CppSamples/Maps/DisplayDeviceLocation" target="_blank"&gt;https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_CppSamples/Maps/DisplayDeviceLocation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_CppSamples/Maps/DisplayDeviceLocationWithNmeaDataSources" target="_blank"&gt;https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_CppSamples/Maps/DisplayDeviceLocationWithNmeaDataSources&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 29 Jun 2021 20:18:42 GMT</pubDate>
    <dc:creator>JamesBallard1</dc:creator>
    <dc:date>2021-06-29T20:18:42Z</dc:date>
    <item>
      <title>Dynamically connect a position source</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/dynamically-connect-a-position-source/m-p/1073840#M4290</link>
      <description>&lt;P&gt;I'm using the 100.8 SDK with Qt 5.14.2 and trying to connect to a variety of GPS units with the serialnmea plugin. The issue I'm having is that the MapView is loading before the Settings can be read, so the user-specified serial port and baud rate aren't set when the PositionSource PluginParameter(s) are begin set up. I would also like to be able to reset the position source when users change the port/baud rate settings so they don't have to restart the program to try out new port/baud settings.&lt;/P&gt;&lt;P&gt;Can someone share some code for dynamically instantiating a MapView and associated LocationDisplay/DefaultLocationDataSource/PositionSource components for connecting GPS location to the map view? I've been able to instantiate a PositionSource with port/baud from Settings, but by the time that happens, my MapView is already instantiated and I can't figure out how to tell the MapView about the newly instantiated PositionSource. I feel like I'm missing something simple, but trial and error isn't getting me anywhere.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2021 18:38:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/dynamically-connect-a-position-source/m-p/1073840#M4290</guid>
      <dc:creator>ChristopherSwingley</dc:creator>
      <dc:date>2021-06-29T18:38:55Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically connect a position source</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/dynamically-connect-a-position-source/m-p/1073881#M4292</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/389538"&gt;@ChristopherSwingley&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp; We have a few samples that use similar workflows. If your plugin conforms to the&amp;nbsp;&lt;SPAN&gt;QGeoPositionInfoSource class, then we can work directly with it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;You can start, stop and replace the entire data source on the LocationDisplay at any time provided that you stop it before replacing it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Here is some sample code you can work with:&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="cpp"&gt;// take the default
mapView-&amp;gt;locationDisplay()-&amp;gt;setDataSource(new DefaultLocationDataSource(this));
mapView-&amp;gt;locationDisplay()-&amp;gt;start();

// then later on, if you want to change it to a custom data source:

mapView-&amp;gt;locationDisplay()-&amp;gt;stop();

auto* newSource = DefaultLocationDataSource(this);
newSource-&amp;gt;setPositionInfoSource(myCustomPositionInfoSource);

mapView-&amp;gt;locationDisplay()-&amp;gt;setDataSource(newSource);

mapView-&amp;gt;locationDisplay()-&amp;gt;start();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can replace this as many times as needed until it's configured properly. You can also delay setting any locationDisplay settings at all until you have them configured and ready.&lt;/P&gt;&lt;P&gt;Here are some samples where we show the basic workflows of the LocationDisplay and LocationDataSource.&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_CppSamples/Maps/ShowLocationHistory" target="_blank"&gt;https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_CppSamples/Maps/ShowLocationHistory&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_CppSamples/Maps/DisplayDeviceLocation" target="_blank"&gt;https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_CppSamples/Maps/DisplayDeviceLocation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_CppSamples/Maps/DisplayDeviceLocationWithNmeaDataSources" target="_blank"&gt;https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_CppSamples/Maps/DisplayDeviceLocationWithNmeaDataSources&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2021 20:18:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/dynamically-connect-a-position-source/m-p/1073881#M4292</guid>
      <dc:creator>JamesBallard1</dc:creator>
      <dc:date>2021-06-29T20:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically connect a position source</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/dynamically-connect-a-position-source/m-p/1073893#M4293</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/405084"&gt;@JamesBallard1&lt;/a&gt;&amp;nbsp;. I realize in seeing your reply that I completely failed to mention that I'm working in QML, not C++ (with the exception of hacking the serialnmea plugin code). That said, it seems as though most of what you've written can be translated into QML:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;mapView.locationDisplay.dataSource = defaultLocationDataSource;
mapView.locationDisplay.start();

// User changes port/baud settings

mapView.locationDisplay.stop();
// instantiate a newPostitionSource with different PluginParameters (?)
// instantiate a newDefaultLocationDataSource using PositionSource
newDefaultLocationDataSource.positionInfoSource = newPositionSource
mapView.locationDisplay.dataSource = newDefaultLocationDataSource;
mapView.locationDisplay.start();&lt;/LI-CODE&gt;&lt;P&gt;But I am a little fuzzy on how to create a new PositionSource and DefaultLocationDataSource in QML/JavaScript. Would that be using Qt.createComponent()/component.createObject(), or maybe Qt.createQmlObject()?&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2021 20:52:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/dynamically-connect-a-position-source/m-p/1073893#M4293</guid>
      <dc:creator>ChristopherSwingley</dc:creator>
      <dc:date>2021-06-29T20:52:46Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically connect a position source</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/dynamically-connect-a-position-source/m-p/1073928#M4294</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/389538"&gt;@ChristopherSwingley&lt;/a&gt;&amp;nbsp; you're on the right track. Any Runtime object can be created programmatically via the ArcGISRuntimeEnvironment.createObject call.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const defaultDataSource = ArcGISRuntimeEnvironment.createObject("DefaultLocationDataSource");&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/qt/qml/api-reference/qml-esri-arcgisruntime-arcgisruntimeenvironment.html#createObject-method" target="_blank"&gt;https://developers.arcgis.com/qt/qml/api-reference/qml-esri-arcgisruntime-arcgisruntimeenvironment.html#createObject-method&lt;/A&gt;&lt;/P&gt;&lt;P&gt;As for the PositionSource object, that will be one of Qt's objects in QML.&lt;/P&gt;&lt;P&gt;&lt;A href="https://doc.qt.io/qt-5/qml-qtpositioning-positionsource.html" target="_blank"&gt;https://doc.qt.io/qt-5/qml-qtpositioning-positionsource.html&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;We accept those on the DefaultLocationDataSource object directly:&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/qt/qml/api-reference/qml-esri-arcgisruntime-defaultlocationdatasource.html#positionInfoSource-prop" target="_blank"&gt;https://developers.arcgis.com/qt/qml/api-reference/qml-esri-arcgisruntime-defaultlocationdatasource.html#positionInfoSource-prop&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In order to use a custom QML PositionSource in QML, it may require writing some custom code since that's non-trivial to derive your own type in QML. However if the Qt-provided types provide sufficient logic you can use those directly.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2021 22:49:49 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/dynamically-connect-a-position-source/m-p/1073928#M4294</guid>
      <dc:creator>JamesBallard1</dc:creator>
      <dc:date>2021-06-29T22:49:49Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically connect a position source</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/dynamically-connect-a-position-source/m-p/1073932#M4295</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/405084"&gt;@JamesBallard1&lt;/a&gt;&amp;nbsp;Thanks. For dynamically creating the QML PositionSource I use the Qt.createComponent/component.createObject, yes? Which presumably means I need to create a new QML file containing a PositionSource { } to pass into Qt.createComponent.&lt;/P&gt;&lt;P&gt;Or maybe changing the PluginParameter(s) on an existing PositionSource (serialnmea in my case) causes it to disconnect and reconnect to a different port, after which I can connect it to the new&amp;nbsp;DefaultLocationDataSource? I feel like I've tried this approach and it didn't work.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Jun 2021 23:02:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/dynamically-connect-a-position-source/m-p/1073932#M4295</guid>
      <dc:creator>ChristopherSwingley</dc:creator>
      <dc:date>2021-06-29T23:02:25Z</dc:date>
    </item>
    <item>
      <title>Re: Dynamically connect a position source</title>
      <link>https://community.esri.com/t5/qt-maps-sdk-questions/dynamically-connect-a-position-source/m-p/1074277#M4299</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/389538"&gt;@ChristopherSwingley&lt;/a&gt;&amp;nbsp; your approach should work just fine. You could also just declare the PositionSource in the same qml file&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;// for example
PositionSource {
    id: positionSourceSimulated
    nmeaSource: "qrc:///Resources/nmeaSimulation.txt"
}&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 30 Jun 2021 17:11:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/qt-maps-sdk-questions/dynamically-connect-a-position-source/m-p/1074277#M4299</guid>
      <dc:creator>JamesBallard1</dc:creator>
      <dc:date>2021-06-30T17:11:48Z</dc:date>
    </item>
  </channel>
</rss>

