Open GoogleCodeExporter opened 8 years ago
I agree with this. Initial accuracy on iPhone is poor and even with page
reloads it doesn't seem to have
GPS accuracy (see also issue 9 which may be classed as a duplicate?)
Original comment by maft.mor...@googlemail.com
on 10 Oct 2009 at 10:17
did you play with the parameters?
http://code.google.com/p/geo-location-javascript/wiki/JavaScriptAPI
Original comment by whoiss...@gmail.com
on 3 Nov 2009 at 7:17
thanks for your response.
I did look at the parameters here
http://dev.w3.org/geo/api/spec-source.html
and I did invoke the "enableHighAccuracy" parameter, as
if(geo_position_js.init()){
geo_position_js.getCurrentPosition(success_callback,error_callback,{enableHighAc
curacy:true});
}
which is simply described as
"the enableHighAccuracy attribute provides a hint that the application would
like to
receive the best possible results. This may result in slower response times or
increased power consumption. The user might also deny this capability, or the
device
might not be able to provide more accurate results than if the flag wasn't
specified."
but it doesn't appear to have any impact on my test device (iPhone).
Original comment by jim.blak...@geocentric.com
on 10 Nov 2009 at 12:17
this inaccuracy might be something we never can rule out with using gps since it
might just take a while for the system to get started. did you try the timeout
parameters as well, you can use them to specify how long your app can wait for a
callback.
until then the webapp somehow needs to communicate that the level of accuracy
is not
as high. for some webapps it never really important to be super high in
accuracy, but
6km sounds a lot, is that in a city environment?
Original comment by whoiss...@gmail.com
on 10 Nov 2009 at 3:22
i've got around this by repeating the javascript calls a few times:
function update()
{
num++;
if (num>iterations) // If the number of iterations has been reached then stop
the
function;
{
document.getElementById('updates').innerHTML='';
}
else
{
// locate
geo_position_js.getCurrentPosition(success_callback,error_callback,{enableHighAc
curacy:true});
<?php if($android) {?>var gaptime=5000;<?php } else {?>var gaptime=2000;<?php }
?>
setTimeout( "update();", 2000); // pause for 2 seconds
}
}
function update2()
{
// pause before trying again
setTimeout( "update();", 2000); // pause for 2 seconds
}
Android devices seem to work better with a longer gap before trying again. also
Android works well with only 3-5 iterations but iPhone gets best results from
15-20.
Original comment by maft.mor...@googlemail.com
on 27 Nov 2009 at 12:57
There is a problem with the way the iphone is implementing getCurrentPosition.
It
never returns a very accurate read the first time. Even if you set the maximum
age at
0. you can tell by pulling the accuracy. You will find the iphone always
returns a
value in the thousands first then gets down to 50 or so. You can actually see
this
in other apps too. Like google maps. Often when you open it, it will drop the
pin in
the vicinity and then move it.
I have solved this problem by implementing watchPosition. This was very quick
and
easy to do for all platforms that support it. The code will attempt to create a
tracker and if it cannot it will just return getCurrentPosition once. I think
this
is a good way to implement it because watchPosition is the format for most of
the
underlying geolocation apis. Feel free to incorporate this into the project,
or if
you would rather you could add me to the project and I'll make the patch..
either way
is ok with me.
I am pasting the patch below and also attaching as a file:
--- orig/geo.js 2009-12-03 21:25:55.000000000 -0500
+++ patch/geo.js 2009-12-03 21:36:44.000000000 -0500
@@ -43,6 +43,14 @@ var geo_position_js=function()
provider.getCurrentPosition(successCallback, errorCallback,options);
}
+ pub.watchPosition = function(successCallback,errorCallback,options){
+ // track position otherwise if we can't at least grab it once
+ if(typeof(provider.watchPosition) != "undefined")
+ provider.watchPosition(successCallback, errorCallback,options);
+ else
+ provider.getCurrentPosition(successCallback,
errorCallback,options);
+ }
+
pub.init = function()
{
try
@@ -231,4 +239,4 @@ var geo_position_js=function()
return pub;
-}();
\ No newline at end of file
+}();
Original comment by jtmask...@gmail.com
on 4 Dec 2009 at 2:42
Attachments:
I should have commented a little bit on how watchPosition works. You can read
about
it here:
http://dev.w3.org/geo/api/spec-source.html#watch-position
but basically it is identical to getCurrentPosition except your successCallback
function will fire every time the position changes.
You can use this to do realtime tracking. If you just need an accurate
position from
the iPhone at startup, I recommend setting this and then setting a timer and
calling
clearWatch ( http://dev.w3.org/geo/api/spec-source.html#clear-watch )
I actually forgot to implement clearWatch, so here is another patch with that:
--- orig/geo.js 2009-12-03 21:25:55.000000000 -0500
+++ patch/geo.js 2009-12-03 22:00:24.000000000 -0500
@@ -43,6 +43,20 @@ var geo_position_js=function()
provider.getCurrentPosition(successCallback, errorCallback,options);
}
+ pub.watchPosition = function(successCallback,errorCallback,options){
+ // track position otherwise if we can't at least grab it once
+ if(typeof(provider.watchPosition) != "undefined") {
+ provider.watchPosition(successCallback, errorCallback,options);
+ // define clearWatch
+ pub.clearWatch = function(watchId){
+ if(typeof(provider.clearWatch) != "undefined") // Should
always be
true, but just in case
+ provider.clearWatch(watchId);
+ }
+ } else {
+ provider.getCurrentPosition(successCallback,
errorCallback,options);
+ }
+ }
+
pub.init = function()
{
try
@@ -231,4 +245,4 @@ var geo_position_js=function()
return pub;
-}();
\ No newline at end of file
+}();
Original comment by jtmask...@gmail.com
on 4 Dec 2009 at 3:02
Attachments:
Thank you for your patches.
Is there any way the author of the geo-location-javascript will implement this?
I myself find problems combining the script with the google maps API 3.
When creating a new google.maps.Geocoder() object the script throws an error
with an unknown exception.
Original comment by roe...@gmail.com
on 4 Jan 2010 at 4:06
Sorry haven't gotten a chance to merge this in yet. I should get some time to
do it
today. If you want, you can email me your source and I'll take a look. This
should
absolutely work with gmaps api 3.0 because I wrote it in the process of
developing an
app using that. I wrote an agency locator app that tracks your location on a
map if
you're on an iphone.. works in other browsers too. You might be able to look
at my
source at http://fp.masker.org and see if you notice any differences. Are you
sure it
is this script throwing an error and not the google api? This script should
have
little to do with the google.maps.Geocoder() object..
Original comment by jtmask...@gmail.com
on 4 Jan 2010 at 6:57
Just submitted r63 to add watchPosition & stopWatch methods. The syntax is the
same
as the new geolocation javascript methods of the same name from w3c. I've
tested the
code, but would like users here to test. Please post feedback to this issue.
Original comment by jtmask...@gmail.com
on 4 Jan 2010 at 7:39
Thanks for this!
I think I found the problem in combination with use of Google Maps Api.
It lies in line 58 of geo.js:
-----
else if (typeof(window.google) != "undefined"
-----
Because window.google is already defined by the maps api but there's no
google.gears available on the
iPhone.
So I changed it to this:
-----
else if (typeof(window.google) != "undefined" && typeof(google.gears) !=
"undefined")
-----
instead. But there's no way right now I can test it on an Android (or gears
enabled) device if it still works.
Original comment by roe...@gmail.com
on 5 Jan 2010 at 11:49
Thanks roennn.. that makes sense. I wonder if something changed with Google's
api in
the past month or so because the script I mentioned before started experiencing
this
as well. I'll see if I can get your changes tested on an android. I guess we
could
also test in a browser with gears.
Original comment by jtmask...@gmail.com
on 11 Jan 2010 at 3:54
Little correction on the fixed line,
----
else if (typeof(google.gears) != "undefined")
----
Should also do the trick then.
I think I can check this on an Android device tomorrow, will post the results
asap.
Original comment by roe...@gmail.com
on 11 Jan 2010 at 11:17
Hey
The line is now actually:
else if (typeof(window.google) != "undefined" && typeof(window.google.gears) !=
"undefined")
http://code.google.com/p/geo-location-javascript/source/browse/trunk/js/geo.js#7
5
It first needs to check if google is not null, also it needs to test for gears
explicitly since window.google is true when you have i.e. Google Maps on the
Page.
Original comment by whoiss...@gmail.com
on 12 Jan 2010 at 12:15
You're right, that makes sense;
I thought I had an Android at hand to test it on but it doesn't run Gears, I'll
kindly ask the owner to install this.
If someone else can test this on his own Android: please do so and let us know.
Original comment by roe...@gmail.com
on 12 Jan 2010 at 2:22
Re: Comment 6 and using watchPosition
I see this has now been added in the 0.4.2 update but how exactly would I use
it?
At present I use:
if(geo_position_js.init()){
geo_position_js.getCurrentPosition(success_callback,error_callback,{enableHighAc
curacy:true});
}
but how would i do it with using the watchPosition? is it literally just a case
of
replacing getCurrentPosition with watchPosition or not? thanks in advance!
as 2 side notes: 1) this no longer works in FireFox (but does in Safari with
Gears)
2) the js files still says v0.4.1 in the header ;)
Original comment by maft.mor...@googlemail.com
on 19 Jan 2010 at 11:54
hey
i tried using it in ff3.0 with geode and gears and in ff3.5.7 with the build-in
functionality, all (OS X) works fine. can you tell me what you are running?
as for watch position, this has been added recently, but isn't ready . do you
have a
use case for it? it is not really complicated at all for the most usages,
except in
blackberry devices where it gets a bit more tricky. i would add it if you have
a use
case for it. so far i assumed that most sites just need get position.
i updated the version number:)
stan
Original comment by whoiss...@gmail.com
on 19 Jan 2010 at 1:32
Stan, it was FF 3.6rc2 Mac OSx
the reason for the watchPosition was to get around the iPhone giving
coordinates with
low accuracy on first polling ie to repeat the query a few times (as suggested
in
comment 6 and 7 " If you just need an accurate position from
the iPhone at startup, I recommend setting this and then setting a timer and
calling
clearWatch")
at present i just set a delay and rerun the normal query a bunch of times to
kick the
iPhone into giving an accurate location!
Original comment by maft.mor...@googlemail.com
on 19 Jan 2010 at 6:38
Hey,
so I got FF 3.6rc2 on Mac OS going and it prompts me if i want to share my
location,
it is kind of subtle, but it works. Give it a try, upper right corner.
Regarding watchPosition(), yes I need to add that, the question I have is if it
calls
when position accuracy improves and/or when the position changes. We shall find
it
out I guess. The only tricky part about watchPosition is to make it work for
BlackBerry & co, Android, iPhoneOS etc are easy. Will do that soon!
What website are you using it for?
Best,
Stan
Original comment by whoiss...@gmail.com
on 22 Jan 2010 at 3:13
Is there any reason to not just do something like:
RepeatThis();
function RepeatThis() {
if(geo_position_js.init()){
geo_position_js.getCurrentPosition(success_callback,error_callback,{enableHighAc
curacy:true});
} else {
//alert("Functionality not available");
}
function success_callback(p) {
// update your application
}
setTimeout("RepeatThis()", 2000);
}
I'm getting good results with this on iPhone, which was the problem that
created the
original post.
I'm doing street level directories and etc (I'm on this corner, where's the
coffeshop, where's the bus stop) so 50 feet makes a huge difference to the user
experience for what's nearby and directions.
Websites include: m.downtownboulder.com, m.goldentriangledc.com,
m.rosslynva.org,
http://m.yourhere.com/, etc.
Original comment by jim.blak...@geocentric.com
on 26 Jan 2010 at 6:20
hey jim,
yes you could do that, but it might drain the battery if you repeatedly ask for
a new
fix, that of course depends on the options you use, if you ask always for a new
GPS
coordinate rather then a cached one it consumes energy.
http://dev.w3.org/geo/api/spec-source.html#max-age
also, but i am pretty sure this is not the case, but just make sure on an
android
device that your mini thread doesn't run when the web page is not visible or
another
app started to run, you don't want to run in the background and use up energy.
i agree that accuracy matters, but i think this is just a thing that gets
better over
time.
I think what you are looking for is watchPosition which I will ready soon, it
is just
hard to do for the blackberry, especially since their emulators are so
notoriously
hard to install. i keep you posted.
does that help?
stan
Original comment by whoiss...@gmail.com
on 27 Jan 2010 at 1:56
maybe you simply do it twice in a row, rather then in a loop.
Original comment by whoiss...@gmail.com
on 27 Jan 2010 at 1:56
thanks for reply. yes, in testing I see battery life is impacted by my
approach.
Perhaps I could limit it to some period of time (30 seconds) during which
accuracy is
likely to get maxed out, similar to your approach of limiting to a set qty of
requests?
of course, if you believe watchPosition would preserve battery performance
without
negatively impacting final accuracy (or quickness of obtaining accuracy) then it
would be a very valuable addition to the script.
while many people are doing GPS apps around driving situations or broad
datasets like
Starbucks locations, my specific interest is people on foot in dense urban or
semi-urban districts, so it I'd love to see it.
Original comment by jim.blak...@geocentric.com
on 27 Jan 2010 at 2:37
May be i am missing something, but the clearWatch-function expects a watchId as
a
parameter which should be returned by watchPosition, but isn't at the moment. Is
there another way to retrive the watchId?
Original comment by claus.na...@gmail.com
on 16 Feb 2010 at 10:24
Hi all,
Any updates on this issue? I think the intention was that to implement
"watchPosition" at least for non-blackberry devices? I'm doing some iPad stuff
where
I'm really noticing the problem.
Thanks,
Jim
Original comment by jim.blak...@geocentric.com
on 10 May 2010 at 9:46
I am confused right now. A while ago I got this script and it contains the
watchPosition() functions mentioned here. It has worked for me. But today I
downloaded the script again (just to be sure to have the latest version) and
now this function is not in there. I also get an error in Safari when using the
new script. The versions of the two files are the same (0.4.3). I am attaching
my version if anyone is interested.
Original comment by r...@rlvision.com
on 8 Jun 2010 at 12:33
Attachments:
hey, sorry for not pushing that further, i can make that part of the library.
give me till the end of the week/beginning nexgt week. can you help me testing
it on devices you got? i am pretty swamped with lots of projects and would like
to implement it for all platforms, just one doesn't get us so far. would you be
willing to help with other platforms? i would do blackberry, i use the library
that frequented by a lot of blackberry devices. do you want to be committer for
the project?
Original comment by whoiss...@gmail.com
on 9 Jun 2010 at 12:29
hey, sorry for not pushing that further, i can make that part of the library.
give me till the end of the week/beginning nexgt week. can you help me testing
it on devices you got? i am pretty swamped with lots of projects and would like
to implement it for all platforms, just one doesn't get us so far. would you be
willing to help with other platforms? i would do blackberry, i use the library
that frequented by a lot of blackberry devices. do you want to be committer for
the project?
Original comment by whoiss...@gmail.com
on 9 Jun 2010 at 12:29
I'm using this for the options: {enableHighAccuracy:true, maximumAge:1,
responseTime:20}
is this the correct format? it just doesn't seem to make a difference on the
iPhone.
for example if i edit line 108/109 of geo.js to:
if(options)
{ alert('fish');
i never get an alert. to me that means that no options are being sent otherwise
it would show the alert? or have i misunderstood the code...
Original comment by maft.mor...@googlemail.com
on 18 Oct 2010 at 6:28
Original issue reported on code.google.com by
jim.blak...@geocentric.com
on 16 Aug 2009 at 5:14