Geolocation
Contents
The Geolocation component gives you awareness of user’s geolocation.
You can use it to request the location of the device, and if the user allows it, you will be able to get the data and keep track of any change on the location, speed, heading, and more.
For example, you can build applications that display different content depending on the country where the user currently is, display their location on a map, or even implement a web-based navigation system.
Usage
The Geolocation component requests the client’s geolocation data to the web browser. This call produces one of two results:
- If the data is retrieved successfully, the OnChange event is triggered.
- If an error occurs, the OnError event is triggered instead.
If the component’s Enabled property is set to true
, the component will request the current location right after the page is loaded. If you set Repeat to true
, the component will also retireve location updates whenever the position of the user agent’s device changes. Once the page is loaded, you can also control the component manually with the client-side functions it provides.
Client-side Features
Client-side Events
- Documented in the RPCL Reference.
Client-side Functions
Note: In order to call these functions, prefix them with
ComponentName
. For example:Geolocation1FunctionName();
.
Activate
Requests the current geolocation data and watches for position changes.
Deactivate
Disables the watching of the position changes.
Retrieve
Performs a single request for the current position.
Server-side Features
Properties, Methods and Events
- Documented in the RPCL Reference.
Help Resources
Video Tutorials
Sample Applications
On the HTML5 folder inside the sample applications directory you will find a form showcasing the Geolocation component:
- GeolocationHideAndSeek.php. Displays your location on a map, as long as you let the application know it. You can play around, “hide”, “show up” and move around, and the application will be able to react to these actions.
Documentation
- Geolocation on the Mozilla Developer Network’s wiki.
- HTML5 Geolocation on W3Schools.
See Also
- Alternatives: MGeolocation (mobile applications).
- Geolocation on Wikipedia.