Game Development Reference
In-Depth Information
To get started with the event-based GPS data collection, create a new
Geolocator
using the
ref new Geolocator()
method. The
Geolocator
object has two
changes that need to be tracked at all times: status and position. Either of these
could change, and you need to track the status of the
Geolocator
to know if
the position data provided is still good. To do this, we need to register with the
geolocator->PositionChanged
and
geolocator->StatusChanged
events.
For these we will use the
TypedEventHandler
, just like the orientation sensors,
and provide the following template arguments.
For the
PositionChanged
event, the arguments are as follows:
•
Geolocator
•
PositionChangedEventArgs
For the
StatusChanged
event, the arguments are the following:
•
Geolocator
•
StatusChangedEventArgs
Status
The status of the geolocator indicates if we can use the position data. Depending on
when we receive the information, or what response the user provides when promp-
ted for permission, we will be provided with a status from the
PositionStatus
enumeration. The values for the status are as follows:
•
Disabled
•
Initializing
•
NoData
•
NotAvailable
•
NotInitialized
•
Ready
The only value of status that will result in good position data is
Posi-
tionStatus::Ready
; however, based on the other values you can take certain ac-
tions.