仅显示在地图框上的坐标,但不会淹没Google地图

时间:2019-05-15 06:53:05

标签: gps

我下面有gps跟踪代码,我能够从数据库中获取经度,我的问题是地图,因为我获取的坐标不会创建地图current status of gps

==========================

 var track = {
        map : null, // Holder for HTML map element
        delay : 100, // Delay in between each location refresh
        show : function () {
        //track.show() : //get location data from server and update map
        // Sadly, Google Maps API is not free.
        // Check out more on their website if you want to use their maps on your app.
        // https://developers.google.com/maps/documentation/

          // AJAX DATA
          var data = new FormData();
          data.append('req', 'getAll');

          // AJAX
          var xhr = new XMLHttpRequest();
          xhr.open('POST', "2c-ajax-track.php", true);
          xhr.onload = function () {
            var res = JSON.parse(this.response);
            // OK
            // @TODO - UPDATE YOUR MAP PINS OR WHATEVER CONTROLS YOU WANT
            if (res.status==1) {
              map.innerHTML = "";
              for (var rid in res.message) {
                var rider = res.message[rid];
                // rider.track_lng
                // rider.track_lat
                // rider.track_time
                var dummy = document.createElement("div");
                dummy.innerHTML = "Rider ID " + rid + " Lng " + rider.track_lng + " Lat " + rider.track_lat + " Updated " + rider.track_time;
                map.appendChild(dummy);
              }
            }
            // ERROR
            else {
              track.map.innerHTML = res.message;
            }
          };
          xhr.send(data);
        }
		
		
				
      };
      
      window.addEventListener("load", function(){
        track.map = document.getElementById("map");
        track.show();
        setInterval(track.show, track.delay);
      });
  <div id="map"></div>

var track = {         map:null,// HTML地图元素的持有人         delay:100,//每个位置刷新之间的延迟         show:function(){         //track.show()://从服务器获取位置数据并更新地图         //很遗憾,Google Maps API不是免费的。         //如果要在应用程序上使用其地图,请在其网站上查看更多信息。         // https://developers.google.com/maps/documentation/

      // AJAX DATA
      var data = new FormData();
      data.append('req', 'getAll');

      // AJAX
      var xhr = new XMLHttpRequest();
      xhr.open('POST', "2c-ajax-track.php", true);
      xhr.onload = function () {
        var res = JSON.parse(this.response);
        // OK
        // @TODO - UPDATE YOUR MAP PINS OR WHATEVER CONTROLS YOU WANT
        if (res.status==1) {
          map.innerHTML = "";
          for (var rid in res.message) {
            var rider = res.message[rid];
            // rider.track_lng
            // rider.track_lat
            // rider.track_time
            var dummy = document.createElement("div");
            dummy.innerHTML = "Rider ID " + rid + " Lng " + rider.track_lng + " Lat " + rider.track_lat + " Updated " + rider.track_time;
            map.appendChild(dummy);
          }
        }
        // ERROR
        else {
          track.map.innerHTML = res.message;
        }
      };
      xhr.send(data);
    }



  };

  window.addEventListener("load", function(){
    track.map = document.getElementById("map");
    track.show();
    setInterval(track.show, track.delay);
  });

0 个答案:

没有答案