Hi,
I've been working a sample that does something similar to this (note
to self: publish soon :). In the meantime, I can definitely suggest
using Google Gear's geolocator:
http://code.google.com/apis/gears/api_geolocation.html#geolocation
and the Google Maps geolocation library:
http://code.google.com/apis/maps/documentation/
I didn't have any experience with Maps/Geo before working on my
sample, (and know only basic javascript) but I found it was very quick
to get something workable together. To find out where your user is,
the Gears code needed is (more or less):
<script type="text/javascript">
var geo = google.gears.factory.create('beta.geolocation');
var geocoder = null;
var lat = null;
var lon = null;
var map = null;
function loadresources(){
if (!
window.google || !google.gears) {
location.href = "
http://gears.google.com/?action=install&message=" +
"To%20use%20Mutiny%27s%20auto-location%20feature%2C%20you%27ll%20need%20to%20install%20gears"
+
"&return=http%3A%2F%
2F24hrsinsf.appspot.com%2F";
}
geo.watchPosition(updatePosition, handleError, {enableHighAccuracy: true});
return true;
}
function updatePosition(position) {
if(lat == null){
lat = position.latitude;
lon = position.longitude;
var current_location = new GLatLng(lat, lon);
geocoder = new GClientGeocoder();
map = new GMap2(document.getElementById("map_canvas"));
geocoder.getLocations(current_location, showAddress)
old_overlay = current_location
map.setCenter(current_location, 13);
var marker = new GMarker(current_location);
map.addOverlay(marker);
}
}
</script>
<body onload="loadresources()">
Here, using the Gears option enableHighAccuracy will not call
updatePosition until a very accurate user position can be found.
Perhaps other people on the group can suggest other methods that have
helped them!
-Marzia