Official Content

The GetLocation method offered by the Maps external object allows getting the current location.



Name Type Description Default
minAccuracy Numeric (8,0) Specifies the minimum accuracy required. This accuracy is specified in meters; 0 - ignores the accuracy of the GPS information. 0
timeout Numeric (8,0) 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. 0
includeHeadingAndSpeed Boolean Specifies if it is necessary to include the heading and speed information in the result. False
ignoreErrors Boolean 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. False

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.

Return value

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])


Sample #1

&locationInfo =  Maps.GetLocation(0,0,false,false)
&texto = &locationInfo.Location.ToString()

Sample #2

&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.

Last update: November 2023 | © GeneXus. All rights reserved. GeneXus Powered by Globant