From Xojo Documentation

Revision as of 16:03, 11 August 2017 by PLefebvre (talk | contribs) (Example)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Class (inherits from WebControl)

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).

Close Hidden MouseMove
ContextualMenuAction KeyPressed MouseUp
DeviceLocation LostFocus Open
DoubleClick MouseDown Resized
Error MouseEnter Shown
GotFocus MouseExit

ContextualMenu LockBottom Parent fa-lock-32.png
ControlID fa-lock-32.png LockHorizontal Style
Cursor LockLeft Timeout
DragOverStyle LockRight Top
Enabled LockTop VerticalCenter
Height LockVertical Visible
HelpTag MaximumAge Width
HorizontalCenter Name fa-lock-32.png Zindex
Left Page fa-lock-32.png

AcceptPictureDrop AllowTextDrag RequestDeviceLocation
AcceptRawDataDrop Close SetFocus
AcceptTextDrop ExecuteJavaScript ShowURL
AllowPictureDrag MsgBox
AllowRawDataDrag PresentContextualMenu


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.


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:

MapViewer1.GoToLocation(New WebMapLocation(Latitude, Longitude))

See Also

WebMapLocation, WebMapViewer