Jump to content

[SOLVED] gps location of a mobile browser

- - - - -

  • This topic is locked This topic is locked
6 replies to this topic

#1
jerrywickey

jerrywickey

    Learning Programmer

  • Members
  • PipPipPip
  • 39 posts
Anyone know a clean way to retrieve the gps location from a gps equipped mobile browser using javascript?

#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
If the browser is designed properly, it will be impossible. If it's possible, the first thing I'll want to do is get a better browser.

With that said, the IP address will generally tell you at least the county, which should be enough for most purposes.

The real question is: why the heck would you want to do this? What's the real goal?
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
jerrywickey

jerrywickey

    Learning Programmer

  • Members
  • PipPipPip
  • 39 posts
I am writing chat software for a fishing tournament.

We live in the Florida Keys. During a fishing tournament, the competitors work together and need to know where the nearest bait boats and the catch boats are.

Now they use the radio, but want to just look at phones, chat online and incorporate some other fishing specific info.

I am not sure why you gravitated toward something nefarious so quickly. No one wants to get the infor without permission.

I understand this works on iPhone, but I have not tried it. Anyone know a more general way for other browsers?

navigator.geolocation.getCurrentPosition( function(loc){

    var lat = loc.coords.latitude;

    var lon = loc.coords.longitude;

    doSomethingWith( lat, lon ); // your function    

});



#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
I would create an app for the smart phones, rather than a website. Apps can access the GPS information with no problem.

I drifted to nefarious because paranoia keeps viruses and malware off my computer :)
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#5
jerrywickey

jerrywickey

    Learning Programmer

  • Members
  • PipPipPip
  • 39 posts
Yeah i know. An app would make it much eeasier, but i don't think even two of the participants have the same phone and installation becomes a hassle without going through the app submission process.

I don't want to write two,three or four apps when most of it is just bouncing text messages and other info back and forth through a server. The gps locations just one thing but it is the most important.


So does anyone know a way?

#6
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
  • Location:Upstate, South Carolina
  • Programming Language:C, C++, PL/SQL, Delphi/Object Pascal, Pascal, Transact-SQL, Others
  • Learning:Java, C#, PHP, JavaScript, Lisp, Fortran, Haskell, Others
Disturbingly, it appears to be possible on Android. javascript android gps at DuckDuckGo

In general, you're going to have to research this for EACH operating system you want to support.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#7
jerrywickey

jerrywickey

    Learning Programmer

  • Members
  • PipPipPip
  • 39 posts
Got it.

Works great thanks to google and Stan Wiechers MIT licensed gps library

Thank you

Jerry

<script src="http://code.google.com/apis/gears/gears_init.js" type="text/javascript"></script>

<script src="http://www.merkwelt.com/people/stan/geo_js/js/geo.js?id=1" type="text/javascript"></script>

<script>

geo_position_js.getCurrentPosition(success_callback, error_callback);

</script>





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users