Thursday, August 27, 2009

Geo location in web applications

'Hello, world' example for getting locations in web application. Check out the following page from iPhone (or FireFox 3.5) Can you see the map? It is a basic example uses the following code:

<script type="text/javascript">

function handler(location) {

var map = document.getElementById("map");
var lat = location.coords.latitude;
var lng = location.coords.longitude;
var acc = location.coords.accuracy;

var s ="<img src='"+lat+","+lng+"&size=300x200&maptype=mobile&zoom=16&key=your_google_map_key' />"
+"<p>Latitude: " + lat + "</p>"
+"<p>Longitude: " + lng + "</p>"
+"<p>Accuracy: " + acc + "</p>";

map.innerHTML = s;

if (navigator.geolocation)



UPD. And here is a practical example: share your location via email on iPhone

UPD1. More examples - check out this from iPhone: bird's eye view

1 comment:

Anonymous said...

works in FF