GetMyLocation method

Unofficial Content

Gets the current location of the Device taking in consideration a new flag to ignore possible errors on the operation. The two errors that are considered are:

  • Location Services are disabled. The message shown is GXM_LocationServicesAreDisabled
  • The app does not have permissions to get the Location Services. The message shown is GXM_CouldNotGetLocationInformation

Availability

Available in GeneXus Evolution 2 Upgrade 3.

Parameters

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 maximun waiting time to get a location with the desired accuracy. If the device cant 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 where the execution of this operation cancels other operation or this operations error are ignored by the application. If an error ocurred and the ignore error flag is set to true an empty value is returned. If an error ocurred and the ignore errors flag is set to false then a msg will prompt the user with a legen saying "Could not get location information" this message can be translated form the language option. False

For example, minAccuracy has a value of 10 meters and the return value has an accuracy of 500 meters, if the time set in the timeout parameter was not reached yet, it will attempt to obtain a more precise data. If that time was reached and the desired accuracy was not obtained, the method won't return any location.

Return value

  • GeolocationInfo
    type: Geolocation Info SDT
    A GeoLocationInfo Structure Data Type loaded with the information gathered from the GPS.

Compatibility

Until GeneXus Evolution 2 Upgrade 3 the behaviour of the app when an error ocurred trying to get de Location Information was different

  • iOS: If an error ocurred getting the Location Information the composite block where the method was would be interrupted.
  • Android: Would continue the Composite Block that was in it without problems.

From GeneXus Evolution 2 Upgrade 3 the default behaviour will be the same and can be changed with the ignoreErrors flag on the method.

How To's

Note: 

In some Android devices, it is necessary to be activated the locator google service in order to work properly with this feature