Results 1 to 2 of 2

Thread: HTML5 Geoloaction

  1. #1
    Join Date
    Mar 2010

    HTML5 Geoloaction

    HTML5 GeoLocation

    I know there's an app for this but I would like to learn how to do this.
    When I upload my code onto the server it can find where I am in realtime with geolocatin.
    But if I would like to monitor someone using the geolocation, how would I go about doing ths??
    Do you need to download a Google API or something??

    So if I am currently at location A and personXY is at location B. If I was to look at my monitor, how do I see personXY on google map in realtime.
    Any tips or advice would be greatly appreciated.

    Here's my code, that only monitors myself
    <!DOCTYPE html>
    <script src="http://maps.google.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript">
       var TIMEOUT = 300000;         
       var MAX_AGE = 1000;           
       var HIGH_ACC = true;          
       var ZOOM = 10;
       var watchID; 
       var map;                      
       var mapMarker;                
       window.onload = function (){
          if (navigator.geolocation) {
             watchID = navigator.geolocation.watchPosition(show_map, errorCheck, {
             maximumAge: MAX_AGE,
             timeout: TIMEOUT,
             enableHighAccuracy: HIGH_ACC 
          }else {
             alert("Oops, Geolocation Not Supported.");
       function stopWatch(){
          if (watchID) {
             navigator.geolocation.clearWatch (watchID);
             watchID = null;
       function errorCheck(error){      
             case error.TIMEOUT:
                alert("Geolocation Timeout");
             case error.POSITION_UNAVAILABLE:
                alert("Geolocation Position Unavailable");
             case error.PERMISSION_DENIED:
                alert("Geolocation Permission Denied");
                alert("Geolocation Error Code: " + error.code);
       function show_map(position) {
          var lat = position.coords.latitude;
          var lon = position.coords.longitude;
          var latlng = new google.maps.LatLng(lat, lon);
          if(map) {                           
          } else {                            
             var myOptions = {
                zoom: ZOOM,
                center: latlng,
                mapTypeId: google.maps.MapTypeId.ROADMAP
             map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
             mapMarker = new google.maps.Marker({
                position: latlng,
                title:"You are here.",
                clickable: true
    <div id="map_canvas"></div>

  2. #2
    Join Date
    Mar 2011
    Most websites determine geo-location by the user's IP address. There are look-up tables available online that you can use that are reasonably accurate. There are also commercial services with better accuracy. A trip to your favorite search engine should help you find them.
    Rick Trethewey
    Rainbo Design

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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