You can use the iphonesettings. startlocationserviceupdates () method to start locating service updates. Finally, you can use iphoneinput. lastlocation to retrieve the Location Coordinate variable.
API: static
VoidStartlocationserviceupdates(FloatDesiredaccuracyinmeters=
10f, floatUpdatedistanceinmeters=
10f)
Parameter 1: desiredaccuracyinmeters
-Ideal service accuracy (in meters ). Using a higher value like 500 usually does not need to turn on the GPS chip to keep the battery power, and a value like 5-10 can be used for the best accuracy. The default value is 10 meters.
Parameter 2: updatedistanceinmeters
-A service with the smallest distance (in meters) must be updated before being moved horizontally.Iphoneinput. lastlocationAttribute. For example, 500 means less overhead. The default value is 10 meters.
Void start () {// before starting the serviceIphonesettings. startlocationserviceupdates ();// Wait for the Service to be known for initialization
// Iphonesettings. locationservicestatus is the current service status int maxwait = 20; while (iphonesettings. locationservicestatus = locationservicestatus. initializing & maxwait> 0) {yield return waitforseconds (1); maxwait --;} // the service is not initialized within 20 seconds if (maxwait <1) {print ("timed out"); return;} // The user rejects access to the positioning service if (iphonesettings. locationservicestatus = locationservicestatus. failed) {print ("User denied access to device location"); return;} // you can retrieve else {print ("Location:" +Iphoneinput. lastlocation. Latitude+ "" +Iphoneinput. lastlocation. longpolling+ "" +Iphoneinput. lastlocation. Altitude+ "" +Iphoneinput. lastlocation. horizontalaccuracy+ "" +Iphoneinput. lastlocation. Timestamp);} // If you do not need to continuously query and refresh, locate and stop the service iphonesettings. stoplocationserviceupdates ();}