Getting Location in Mobile UI

greg54
Tera Expert

Is there a way to get a users location when using the browser based mobile UI?

I put the "current_location" attribute on a field and was able to get the users location when using the actual Android SN Mobile app but this attribute does not affect the field when viewing in the browser mobile UI. Is there any way to get the users location when using the mobile browser?

Thanks!

1 ACCEPTED SOLUTION

greg54
Tera Expert

I figured this out for anybody who is interested in the solution. I used HTML5's built in geolocation capability with an onLoad Client Script.



if (navigator.geolocation) {


  navigator.geolocation.getCurrentPosition(UserLocation);


} else {


  alert('Geolocation is not supported by this browser');


}




// Callback function for asynchronous call to HTML5 geolocation


function UserLocation(position) {


  var latitude = position.coords.latitude;


  var longitude = position.coords.longitude;


  alert(latitude + ',' + longitude);


}


View solution in original post

6 REPLIES 6

Ratul Arora1
Kilo Contributor

create any string type variable in your form.

In the dictionary of that variable add attribute "Enable current location input helper" true... now when u access from your mobile you will get the current location.

Hello Ratul,

I clicked on the link, but I can't view the resource that you are linking.  It takes me to a developer instance (https://dev44975.service-now.com/navpage.do) and asks me to login.

 

Is there any chance that you could copy/paste in the information you linked into a reply on this thread?

 

Thanks in advance!