Hexagon Geospatial
MENU

Developers Knowledge Base

WebGIS enables powerful geospatial web applications and services that securely share your organization’s rich geospatial data, and provides tools to deeply examine spatial data and create value added products, on demand.
Showing results for 
Search instead for 
Do you mean 

Capture GPS coordinates on mobile devices

by Technical Evangelist on ‎09-09-2015 04:05 AM - edited on ‎04-11-2017 04:18 AM by Technical Evangelist (763 Views)

Description

The Where am I button on Mobile.aspx doesn’t work on some Android devices. The problem are delays in retrieving GPS coordinates. To solve this problem increase the timeout. The same code works on iOS devices.

Source code

var timeout = 5000000;  
if (navigator.geolocation) {
 
    navigator.geolocation.getCurrentPosition(
         function (position) {
            alert(position.coords.latitude, position.coords.longitude);
         },
         function (error) {
            alert(error.message);
         }, {
            enableHighAccuracy: true
            , timeout: timeout
         }
     );
 
} else {
   alert("no support for geolocation");
}
Overview