The GetLocation method offered by the Maps external object allows getting the current location.
||Specifies the minimum accuracy required. This accuracy is specified in meters; 0 - ignores the accuracy of the GPS information.
||Specifies, in seconds, the maximum waiting time to get a location with the desired accuracy. If the device can't get a location in the specified time with the required accuracy, it returns the best location available. 0 means don't wait.
||Specifies if it is necessary to include the heading and speed information in the result.
||Specifies whether the execution of this operation cancels another operation or if this operation's errors are ignored by the application. If an error occurs and the ignore error flag is set to true, an empty value is returned. If an error occurs and the ignore errors flag is set to false, then a msg will prompt the user with the text "Could not get location information". This message can be translated from the language option.
The flag to ignore possible operation errors takes into account the following two errors:
- Location Services are disabled: The message shown is GXM_LocationServicesAreDisabled.
- The app does not have permission to get the Location Services: The message shown is GXM_CouldNotGetLocationInformation.
When you call the GetLocation method, it returns a LocationInfo Structured Data Type (SDT) object loaded with the information gathered from the GPS:
&locationInfo = Maps.GetLocation(Numeric, Numeric, Boolean, [Boolean])
&locationInfo = Maps.GetLocation(0,0,false,false)
&texto = &locationInfo.Location.ToString()
&locationInfo = Maps.GetLocation(10, 60, true, false)
Suppose minAccuracy is set to 10 meters, and the resulting accuracy is 500 meters. If the time specified in the timeout parameter has not elapsed, the method will try to get more precise data. However, if the specified time has elapsed and the desired accuracy is not achieved, the method will not provide any location information.
- In some Android devices, it is necessary to have the Google locator service enabled for this feature to work properly.
- This method is equivalent (and the newest one, which is suggested to be used) to the GetMyLocation method of the Geolocation external object.
This method has been available since GeneXus 17 upgrade 1.