Hi Michael,

The demo page is intentionally simplistic so it doesn't cover the full
W3C geolocation API.  In particular, the demo does not pass any
PositionOptions
(http://dev.w3.org/geo/api/spec-source.html#position_options_interface)
such as "maximumAge".  Try setting "maximumAge" to something like
30000 milliseconds, otherwise some phones will reuse the last location
to save battery.

Cheers
Ben

On Sat, Sep 18, 2010 at 7:19 AM, mfitzpatrick <[email protected]> wrote:
> Hey all,
>
> I've been reading through the Google Maps API recently, and decided to
> try out the primary example given to detect a user's location:
> http://code.google.com/apis/maps/documentation/javascript/basics.html#DetectingUserLocation
> - however, I've been having some difficulties getting it to work
> properly and was wondering if there was something I might need to add
> in to solve my issue.
>
> I went to the example URL (http://code.google.com/apis/maps/
> documentation/javascript/examples/map-geolocation.html) on my iPhone,
> and the location infowindow appeared at my current location as it
> should. I then walked a half mile and refreshed the page. However, the
> infowindow still appeared in the same location as it did when I first
> opened the page to start my walk. I walked another half mile and
> refreshed the page once more - but again, the infowindow didn't
> change, it simply remained fixed at my first starting location.
>
> It was clear that however far I walked, the infowindow wasn't going to
> move from my original starting location no matter how many times I
> tried reloading the page. So I tried something new - I opened up the
> Google Maps application on my iPhone (the one that comes pre-
> installed), clicked the geolocation arrow/pointer at the bottom left
> of the screen, and of course the Google Maps application showed the
> blue dot at my current location, a mile away from my starting position
> as it should be.
>
> I then went back to the example URL (http://code.google.com/apis/maps/
> documentation/javascript/examples/map-geolocation.html), and
> interestingly enough, the infowindow now appeared in the correct
> location - the exact location as my blue dot on the Google Maps
> Application.
>
> I tested these steps a few times and came to the conclusion that the
> Google Maps API javascript code I was using would only locate to my
> current location if:
> 1) It was the first time I'd opened the page in a few hours.
> 2) I refreshed my geolocation using the pre-installed Google Maps
> iPhone App.
>
> I am interested in creating a website which utilizes the geolocation
> feature, but obviously don't want to hinder users by forcing them to
> calibrate themselves using the Google Maps iPhone App every time they
> go to the site just for their correct location to display. Is there
> some way to make this work as it should, so that simply refreshing one
> of my webpages with a Google Maps API script will always show the
> user's current location and not an old, outdated location?
>
> Any help with this would be greatly appreciated - thanks!
>
> -Michael
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Google Maps JavaScript API v3" 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-maps-js-api-v3?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" 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-maps-js-api-v3?hl=en.

Reply via email to