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
On Fri, Jan 30, 2009 at 11:23 AM, theillustratedlife
<[email protected]> wrote:
>
> I'm interested in adding geolocation to my app. Specifically, I'd
> like to find the city/metro area a user is in to serve localized
> results.
>
> I've done some brief research, and this pattern is emerging:
>
> 1) Serve a location-untargeted html file.
>
> 2) Include some JavaScript in that file that searches for a location
> API (e.g. Gears, Google AJAX APIs, Mozilla Geode), parses the city the
> user is in, and sends it back to a handler on my app.
>
> 3) My app would then find the relevant data and send it back for the
> JavaScript to inject into the page.
>
>
> Ideally, I'd have a rough idea of the user's location the first time
> (IP targeting). Any tips?
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google App Engine" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/google-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---