Change AGSLocationDisplay data source dynamically

Discussion created by patrickhartling on Apr 15, 2013
Latest reply on Aug 5, 2018 by murugha23
In our app, we have a custom implementation of the AGSLocationDisplayDataSource protocol that receives updates from an external GPS service via a WebSocket. If the WebSocket connection cannot be established or if it is lost, we want to fall back on Core Location. This means that we need to be able to change the AGSLocationDisplayDataSource in use by the AGSLocationDisplay at any time.

So far, the approach I am using when the WebSocket connection status changes is as follows:

  1. If the current data source is running, stop it by sending -stopDataSource to the AGSLocationDisiplay object

  2. Update the dataSource property on the AGSLocationDisplay according to the new connection state

  3. If the map view is loaded, start the newly assigned data source by sending -startDataSource to the AGSLocationDisiplay object

The AGSCLLocationManagerLocationDisplayDataSource object and our custom AGSLocationDisplayDataSource implementation are allocated once during view controller setup in case that detail matters. The auto-pan mode is AGSLocationDisplayAutoPanModeNavigation unless the user has panned the map view and has not resumed navigation mode. In that case, it is AGSLocationDisplayAutoPanModeDefault.

The display of the current location after swapping the data source only sort of works. Basically, the blue dot from LocationDisplay.png stops being rendered after the first or second handling of the connection status change. The halo/pulse does get rendered at the right location on the map, although that seems somewhat unreliable as well. I am not sure if that is related to Core Location precision or something else.

Is switching the data source in this way supported? If AGSLocationDisplay is not meant to be used this way, I can go back to the drawing board regarding our handling of the connection status. Is there some other way to achieve the behavior that I want?