WebDeviceLocation
From Xojo Documentation
Supported Platforms Project Types: Web Platforms: macOS, Windows, Linux |
New in 2011r2
Gives your web application access to HTML5 GeoLocation capabilities provided by the browser (if it is supported by the browser and platform).
Events | |||||||||||||||||
|
Methods | |||||||||||||
|
Notes
Some browsers, such as Safari, may require that it have a secure (HTTPS) connection to the web app in order to request the device location. |
To use a WebDeviceLocation, drag an instance of the control to a WebPage and call the RequestDeviceLocation method to get the current location. This request is then sent to the browser. If the browser has HTML5 GeoLocation capabilities, the DeviceLocation event will fire and obtain the latitude and longitude. If HTML5 GeoLocation capabilities are not supported by the browser, an Error event will fire instead. There are constants for this class for each error code.
You may also want to use the Timeout and MaximumAge properties to fine-tune the browser's handling of the request for GeoLocation information.
Note: Requesting the device location uses CPU cycles and power. Be very careful about requesting the user's location too often for mobile devices or you can cause excessive battery drain. You can use the MaximumAge property to prevent the device from requesting new information too often. If it is prohibited from requesting new information, it will simply report the most recent values instead.
Example
The MapViewer example project in the Examples folder uses a WebLocation instance to request the device's current location and pass the information to the map. The RequestDeviceLocation method obtains the new information in a Button's Action event:
The WebDeviceLocation instance calls the Webmapviewer's GoToLocation method to recenter the map: