amostajo / geo-location-javascript

Automatically exported from code.google.com/p/geo-location-javascript
0 stars 0 forks source link

Is geo.js library also intented to work in desktop browsers? #32

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
... If so then it's not working in the current stable Chrome (8.05....).
Using geo.js in Chrome simply does nothing, no errors are thrown.

I changed a few lines as smooth as possible so that it also works in Chrome.
I've added a tar.gz file tested in Firefox 3.6, Opera and Chrome.
(Safari doesn't seem to have Geolocation API implemeted completely yet, but I 
don't know for sure.)

Don't know if this change affects gears based phones. I'm mainly interested in 
a reliable library for desktop browsers.

... If not not then you take this as a request.

Original issue reported on code.google.com by wolfpil@gmail.com on 11 Jan 2011 at 5:49

Attachments:

GoogleCodeExporter commented 9 years ago
http://www.merkwelt.com/people/stan/geo_js/sample.html

I am using Chrome 8.0 and Firefox 3.6 without problems. Can you verify that the 
above URL is not working.

Original comment by whoiss...@gmail.com on 11 Jan 2011 at 1:50

GoogleCodeExporter commented 9 years ago
I can confirm: Your example is in fact working in my copy of Chrome.

I downloaded geo.js v0.4.3 again and tried it again with the same.result: 
nothing happens, whereas my modified geo.js works without problems - locally 
and on my server.

Made a diff between those versions
This 'else if' statement seems to have changed

old: else if(typeof(window.google)!="undefined")

new: else if(typeof(window.google)!="undefined" && 
typeof(google.gears)!="undefined")

This causes (although only in your example) Chrome to overwrite the previous 
'else if', nameley

else if (typeof(navigator.geolocation)!="undefined")

that will also be executed in Chrome.

But sorry, I don't know the reason why my copy of Chrome seems to like your 
example on the server but not when I try it in different environments.

Original comment by wolfpil@gmail.com on 11 Jan 2011 at 3:11

GoogleCodeExporter commented 9 years ago
Tried again with the same results.
Anyhow, I think this library is a good idea. I'd like ti thank you for 
initializing this project and for your work so far.

Thanks.

Original comment by wolfpil@gmail.com on 11 Jan 2011 at 3:43

GoogleCodeExporter commented 9 years ago
hey, I updated the code, should be all fine now. Can you verify? Latest build 
is attached, also includes a minified version from now on. And a method to open 
a map with lat,lon which works differently on blackberry browsers.

Original comment by whoiss...@gmail.com on 11 Jan 2011 at 8:16

Attachments:

GoogleCodeExporter commented 9 years ago
Tried it locally. Firefox and Opera are fine, Chrome does nothing.
I believe Chrome stops here

92 else if (typeof(navigator.geolocation)!=u)

the next-but-one 'else if' is never called

146 else if(typeof(window.google)!=u && typeof(google.gears)!=u)

Original comment by wolfpil@gmail.com on 12 Jan 2011 at 7:21

GoogleCodeExporter commented 9 years ago
in my chrome 8.0.552.231 it responds indeed to:

"else if (typeof(navigator.geolocation)!=u)"

since this is supported by chrome. so are you saying it enters that condition 
but then fails? no 100% sure if i understand the issue.

Original comment by whoiss...@gmail.com on 12 Jan 2011 at 1:15

GoogleCodeExporter commented 9 years ago
Yes, navigator.geolocation is available and known by Chrome but it has no 
effect due to the fact that Chrome doesn't support the standards completely yet.

And because a 'else if' statement is used no other 'else if' block will be 
executed.

Hope this funny gears game with Chrome will be finished the sooner the better. 
Gears was proprietary, so it was a good decision to deprecate it and support 
the full standards instead.

"Other facets of Gears, such as the LocalServer API and Geolocation, are also 
represented by similar APIs in new standards and will be included in Google 
Chrome shortly."

Source: http://gearsblog.blogspot.com/2010/02/hello-html5.html

In Jan. 2011 it is still necessary to initialize Gears in Chrome, so this post 
from Feb. 2010 was a bit ahead of the reality.

Original comment by wolfpil@gmail.com on 12 Jan 2011 at 1:35

GoogleCodeExporter commented 9 years ago
Now I understand what you mean by "no other 'else if' block will be executed." 
That is supposed to be like that. I tried on both windows and OS X with chrome 
8 without any problem. It brings up the permission dialog under the URL bar and 
once I confirm it works just fine. Would it be possible for you to see where it 
actually goes wrong? Or how would I detect a faulty chrome. 

Original comment by whoiss...@gmail.com on 12 Jan 2011 at 3:10

GoogleCodeExporter commented 9 years ago
Hmm, now it's me who do not understand.
Difficult to say where Chrome goes wrong because no error is reported, simply 
nothing in Chrome.

When I call

  else if(typeof(window.google)!=u && typeof(google.gears)!=u)
  {
  provider=google.gears.factory.create('beta.geolocation');
  }

before

else if (typeof(navigator.geolocation)!=u) ...

I get the location in Firefox, Opera and also in Chrome.

In Google's Gears Geolocation Demo 

http://code.google.com/apis/gears/samples/hello_world_geolocation.html

getCurrentPosition() refers to google.gears.factory.create('beta.geolocation');

not to navigator.geolocation.

But maybe I'm missing something.

Original comment by wolfpil@gmail.com on 13 Jan 2011 at 2:30