Give us feedback
Mobile icon

Location Plugin

Stable version 5.2.0 (Compatible with OutSystems 11)
Other versions available for 10
Uploaded on 11 Oct by 
 (29 ratings)

Location Plugin


When to Use it
There are two different types of situations where you can use this component. Either 1) you want to actively do something when your position change or 2) you need to get your position one time to do a specific action.

We are going to start by explaining the first case and after that, we will go through the second one.

Check if the plugin is available

First of all, you should check if the location plugin is available on your device, if it’s not you will not be able to use the other action and you would probably want to show an error message to the user, the CheckLocationPlugin is very simple. It doesn’t have inputs and just returns a boolean with the availability of the plugin and an error message if it’s not available.

Get your current location

In case you want to get your current location, you just need to drag and drop the GetLocation action into the flow. This action doesn’t have any mandatory fields, but you can define the timeout of the action, defining the maximum age (miliseconds) to use the cached location, and enable the high accuracy mode. Then you can validate if the action was successful and if it was it will return a structure with the location info.

Check if the location changes

The first thing to do is drag and drop the LocationTracker web block somewhere in your screen because it’s this web block that will handle the on location change event in order to trigger the actions that you will want to do. In this example, we just dropped it in the body of this screen, but you can put it in the Layout or LayoutBlank web blocks if you want it to do some action in the background through all the application.

So now that we have the event handler placed in your application we need to start it because it doesn’t start itself, you can start it whenever you want with the WatchPosition action for the purpose of this example we started it in the OnReady action of the screen, the inputs of this action are the same as the ones in the GetLocation action because ultimately it will be using the GetLocation action actively to keep your location updated in real time.

Besides that, the WatchPosition action also returns the WatchId that is an identifier that you can use in the ClearWatch action to stop the process of actively receiving your position. 

Now with it all set you just need to create an action to handle the event of the position changing, and assign it to the LocationTracker web block, keep in mind that the event returns you the Location structure and the WatchId.