Zaloguj | Zarejestruj | FAQ

HTML5 Geoloaction

+ Odpowiedz

Posty: 3 Strona 1 z 1

HTML5 Geoloaction

przez hiyatran » N paź 28, 2012 1:47 am

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
Kod: Zaznacz cały
<!DOCTYPE html>
<script src=""></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>

Avatar użytkownika


  • Posty: 6
  • Dołączył(a): Cz cze 07, 2012 2:22 am

Re: HTML5 Geoloaction

przez XainPro » Pn paź 29, 2012 5:18 pm

well sorry i have no experienced for such thing but it seems interesting let me Google it :)
and if you find the solution please also share the solution on forums...
Avatar użytkownika


  • Posty: 3933
  • Dołączył(a): Pt lut 17, 2012 8:10 pm

Re: HTML5 Geoloaction

przez muratsal » Pn lis 05, 2012 10:03 pm

you can post the geo location to server with ajax and get the locations from server .
Avatar użytkownika


  • Posty: 47
  • Dołączył(a): Śr paź 17, 2012 12:51 pm
my map applications

+ Odpowiedz

Strona 1 z 1