Mobile Line Of Business

Richard Jones (MVP)

  Home  |   Contact  |   Syndication    |   Login
  202 Posts | 0 Stories | 36 Comments | 0 Trackbacks

News

Welcome to the Mobile Line Of Business Blog

Tag Cloud


Archives

Post Categories

About

Both Mobile Safari (in iPhone OS 3.0) and Google Android now both support getting the location of the current user.

How cool is that.   Finally mobile web-pages can be location aware.    The user is prompted for whether they wish to enable this facility on a per site basis.

Here’s the HTML/Javascript that does it all.

 

photo

 

<html>

<head>

<script>

navigator.geolocation.getCurrentPosition(foundLocation, noLocation);

function foundLocation(position)
{
  var lat = position.coords.latitude;
  var long = position.coords.longitude;
alert('Found location: ' + lat + ', ' + long);

}
function noLocation()
{
  alert('Could not find location');
}

</script>

</head>

<body>
<h1>Location App</h1>
</body>
</html>

 
 
In the above example  when the location is found it displays current location.
I’ve posted a slightly more feature rich version at http://www.binaryrefinery.com/location.htm
 
 
 
 
posted on Friday, June 19, 2009 7:22 AM