Select to view content in your preferred language

Custom PositionInfoSource on MacOS

406
2
Jump to solution
11-10-2024 09:38 PM
Labels (2)
JustinSteventon
Occasional Contributor

Hi folks,

I am migrating to Qt 6 and ran into an issue while changing the location source on MacOS. This works fine on Windows.

I do the following:

    auto dataSource = new DefaultLocationDataSource(this);
    dataSource->setPositionInfoSource(new MyPositionInfoSource(this));
    m_mapView->locationDisplay->setDataSource(dataSource);
    m_mapView->locationDisplay->start();


"MyPositionInfoSource" provides simulated data and does not touch the actual GPS.

On MacOS, I get a debug message about requiring location permissions and then it does not work. I have tried requesting permissions in the usual way, but still no luck.

Could you guys check it out?

Thanks!

0 Kudos
1 Solution

Accepted Solutions
bnoble0110
Esri Contributor

Hello @JustinSteventon 

Which version of Qt 6 are you migrating to?

Have you tried using `SimulatedLocationDataSource` instead of `DefaultLocationDataSource` ?

`DefaultLocationDataSource` will internally check (but not request) for location permissions with the latest versions of our SDK. The default result of that permission check will vary between platforms. On Windows, it always comes back as `Granted` for me, but on macOS, it will come back `Undetermined` and need to be requested explicitly. This may explain the differing behavior you are seeing on Windows vs macOS.

Further on macOS, if you're requesting permissions you'll need to make sure you have the correct entries in your `info.plist` file.

If you haven't already, you may benefit from checking out our `ShowLocationHistory` sample, which uses a `SimulatedLocationDataSource`.

I've attached an example that the Qt company provides to observe the behavior of requesting permissions among different platforms. (You'll need to modify it to request Location permissions and not Bluetooth permissions).

View solution in original post

0 Kudos
2 Replies
bnoble0110
Esri Contributor

Hello @JustinSteventon 

Which version of Qt 6 are you migrating to?

Have you tried using `SimulatedLocationDataSource` instead of `DefaultLocationDataSource` ?

`DefaultLocationDataSource` will internally check (but not request) for location permissions with the latest versions of our SDK. The default result of that permission check will vary between platforms. On Windows, it always comes back as `Granted` for me, but on macOS, it will come back `Undetermined` and need to be requested explicitly. This may explain the differing behavior you are seeing on Windows vs macOS.

Further on macOS, if you're requesting permissions you'll need to make sure you have the correct entries in your `info.plist` file.

If you haven't already, you may benefit from checking out our `ShowLocationHistory` sample, which uses a `SimulatedLocationDataSource`.

I've attached an example that the Qt company provides to observe the behavior of requesting permissions among different platforms. (You'll need to modify it to request Location permissions and not Bluetooth permissions).

0 Kudos
JustinSteventon
Occasional Contributor

Thanks, I did not notice that you have this amount of structure around the location system. For the record, I am migrating to 6 from 5.15.2. Fairly smooth so far.