Getting to know the Web Controls
Lesson 21 - cWebGeoLocation
In this lesson we will take a look at the WebGeoLocation control. The WebGeoLocation class can provide the user's current location through an API. Additionally, it offers the capability to track the user over extended periods and retrieve information about their speed. If you need to gather data on the whereabouts of all your users around the world, this class can be a valuable resource for acquiring that information.
DEMONSTRATION
- If we take a look at the WebOrderMobile example. There is already a view made to explain the functionality of this control.
- Note that some browsers still need to ask for location rights, also most browsers need to interact via HTTPS for security reasons.
- Upon opening it, you'll be able to observe its functionality within the views.
- When we take a closer look, the first button shows your current location.
- Let's look at the code.
- As you can see, we make an object of the WebGeoLocation class, and we have a button.
- Because the WebGeoLocation calls are async we need to write a callback just like this.
- Also, we need to make sure that the procedure is known to the client side. So, we need to publish it just like this.
- Now we can call the right procedure in the OnClick Procedure. As you can see here.
- If we take a quick look at the second webgoup and button we can see that there is a second object made of the WebGeoLocation class.
- Now the callback procedure has become an event procedure and we need to implement that.
- This procedure will be called every time your browser detects a change.
- Also, we need to use the WebGeoLocation specific start and stop procedures.
- Let's look at our button on the view.
- As you can see when we now click the “start” button it is going to track our location until we click the same button again.