Skip to main content

Real time GPS Tracker on JUST HTML / JS and Google Maps to be run on a mobile phone

Most browsers in the latest smart phones have implemented the W3C Geo location:
The Geolocation API defines a high-level interface to location information associated only with the device hosting the implementation, such as latitude and longitude. The API itself is agnostic of the underlying location information sources. Common sources of location information include Global Positioning System (GPS) and location inferred from network signals such as IP address, RFID, WiFi and Bluetooth MAC addresses, and GSM/CDMA cell IDs, as well as user input. No guarantee is given that the API returns the device's actual location.
The API is designed to enable both "one-shot" position requests and repeated position updates, as well as the ability to explicitly query the cached positions.

Using the Geolocation API to plot a point on Google Maps, will look something like this:

   
if (navigator.geolocation) { 
  navigator.geolocation.getCurrentPosition(function(position) {  

    var point = new google.maps.LatLng(position.coords.latitude, 
                                       position.coords.longitude);

    // Initialize the Google Maps API v3
    var map = new google.maps.Map(document.getElementById('map'), {
       zoom: 15,
      center: point,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    // Place a marker
    new google.maps.Marker({
      position: point,
      map: map
    });
  }); 
} 
else {
  alert('W3C Geolocation API is not available');
} 
 
 The above will only gather the position once, and will not auto update 
when you start moving. To handle that, you would need to keep a 
reference to your marker, periodically call the getCurrentPosition() method,
 and move the marker to the new coordinates. The code might look something 
like this:
 // Initialize the Google Maps API v3
var map = new google.maps.Map(document.getElementById('map'), {
  zoom: 15,
  mapTypeId: google.maps.MapTypeId.ROADMAP
});

var marker = null;

function autoUpdate() {
  navigator.geolocation.getCurrentPosition(function(position) {  
    var newPoint = new google.maps.LatLng(position.coords.latitude, 
                                          position.coords.longitude);

    if (marker) {
      // Marker already created - Move it
      marker.setPosition(newPoint);
    }
    else {
      // Marker does not exist - Create it
      marker = new google.maps.Marker({
        position: newPoint,
        map: map
      });
    }

    // Center the map on the new position
    map.setCenter(newPoint);
  }); 

  // Call the autoUpdate() function every 5 seconds
  setTimeout(autoUpdate, 5000);
}

autoUpdate();
 
Now if by tracking you mean that you should also store this information 
on a server (so that someone else could see you moving from a remote 
location), then you'd have to send the points to a server-side script 
using AJAX. 
 

Comments

Unknown said…
complete good information provide your blog rfid gps tracking

Your blog is really very interesting information regarding real estate.

Bhartiya City Nikoo Homes
Mantri Serenity
Anonymous said…
Nice blog..! I really loved reading through this article. Thanks for sharing such an amazing post with us and keep blogging...Well written article Thank You for Sharing with Us | project management training in chennai | project management certification online | project management course online |
ibtdubai said…
I like the topic which has been discuss by you,i want to say thanks to you for sharing informative info. Alternatively specially create a great blog for CompIT.

IT Support Services Dubai
Madhan kumar said…
Hey, Wow all the posts are very informative for the people who visit this site. Good work! We also have a Website. Please feel free to visit our site. Thank you for sharing.
Be Your Own Boss! If you're looking for a change in your work prospects, then let's prepare for your career from here!!!
Self Employment | Women Development | Information Technology | Engineering Courses

Popular posts from this blog

CCNA3 v4.0 Final Exam Answers Updated 2013 100%

1. Refer to the exhibit. A network administrator needs to add IP phones to the network. To which devices should the IP phones connect? AS1 and AS2 DS1 and DS2 DS1, DS2, and CS1 AS1, AS2, DS1, and DS2 2. Which CLI mode allows users to access all device commands, such as those used for configuration, management, and troubleshooting? user EXEC mode privileged EXEC mode global configuration mode interface configuration mode 3. Refer to the exhibit. Which Spanning Tree Protocol version is in effect? Per VLAN Spanning Tree (PVST) Per VLAN Spanning Tree + (PVST+) Common Spanning Tree (CST) Rapid Spanning Tree Protocol (RSTP) Multiple Spanning Tree Protocol (MSTP) 4. Refer to the exhibit. A network administrator has segmented the network into two VLANs and configured Router1 for inter-VLAN routing. A test of the network, however, shows that hosts on each VLAN can only access local resources and not resources on the other VLAN. What is the most likely cause of this pr

CCNA 2 EROUTING version 4 2013 FINAL EXAM ANSWERS 100%

CCNA 2 Final Exam 2013 v 4   1. Refer to the exhibit. A network engineer removes a new router from the shipping container and powers on the router to ensure it passes POST. Which port would the engineer use to perform the initial configuration? AUX console FE0/0 FE0/1 2. What is the purpose of the TTL field within an IP packet header? clears an unreachable route from the routing table after the invalid timer expires prevents regular update messages from inappropriately reinstating a route that may have gone bad removes an unreachable route from the routing table after the flush timer expires limits the period of time or number of hops a packet can traverse through the network before it should be discarded used to mark the route as unreachable in a routing update that is sent to other routers 3. When would the network administrator use the ip bandwidth-percent eigrp as-number percent command? when there is a low bandwidth connection when the connec

PIC PROGRAMMER

PIC Programmer Circuit diagram Following uJDM PIC programmer  circuit is a circuit which is suitable to do simple pic16f84, pic16f84A, 16c84, 16f628 group programmer. PARTS LIST R1 10KΩ R2 3.3KΩ R3 15KΩ C1 100µF 16V D1 LED Z1 5.1V Zener Q1 BC547 PIC PIC16F84,PIC16F84A, 16C84, 16F628 Rs232 RS232 Femail Connector IC Base 18 pin ic base for PIC BC547  Transistor Pin Configuration ·                  Using IC base for PIC ·                  Connect the PIC programmer to 1st or 2nd COM PORT of computer by using RS232 wire. ·                  USE MPLAB AND IC-PROG (or any ic programming software) to program PIC with this PIC Programmer. PIC16F84A Micro Controller PIC PROGRAMMER PIC 16F84A Programmer Bootloading There is one other way of programing a pic device and this is using a piece of software called a bootloader. This method is only usable on the newer devices that can re-program parts of their own FLASH mem