Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Mobile GPS

  1. #1
    Regular Coder
    Join Date
    Oct 2009
    Thanked 3 Times in 3 Posts

    Mobile GPS

    I am trying to get a fix on mobile devices, of course if they agree to their location to be given out.

    Just like some websites ask if my pc's location can be given out. But when I allow my pc's location it always shows a location in London, being my ISP, which must mean that the location is got using my IP address.

    Can anyone suggest how I can go about getting the exact or near exact location of mobile devices that connect to my site. Would it be using PHP and HTML or Javascript ? I have no idea where to start.

  2. #2
    Regular Coder patryk's Avatar
    Join Date
    Oct 2012
    Thanked 64 Times in 64 Posts
    check out this doc: http://dev.w3.org/geo/api/spec-source.html
    and here's nice demo with sources on github: http://html5demos.com/geo

    location is accessed via javascript obviusly. and then you do whatever you want with it

    basically it's
    <script language="javascript">
    function successCallback(data){
    	document.writeln('accuracy: ' + data.coords.accuracy + '<br />');
    	document.writeln('altitude: ' + data.coords.altitude + '<br />');
    	document.writeln('altitude accuracy: ' + data.coords.altitudeAccuracy + '<br />');
    	document.writeln('heading: ' + data.coords.heading + '<br />');
    	document.writeln('latitude: ' + data.coords.latitude + '<br />');
    	document.writeln('longitude: ' + data.coords.longitude + '<br />');
    	document.writeln('speed: ' + data.coords.speed + '<br />');
    	document.writeln('timestamp: ' + data.timestamp);
    function errorCallback(data){
    	navigator.geolocation.getCurrentPosition(successCallback, errorCallback);
    	document.writeln('not supported');
    yes it's that simple. paste it INSIDE document's body and open
    Last edited by patryk; 03-20-2013 at 03:08 AM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts