谷歌地图指针在10秒后每隔一段时间移动更新的mysql数据

时间:2017-11-30 08:59:32

标签: php jquery mysql

  

这是获取数据latlong

<?php
      $queryForRiders = 'SELECT R.RiderName , AR.CurrentLatitude, 
                        AR.CurrentLongitude, C.CityName, 
                        AR.LastUpdateDateTime, V.VehicleRegisteration , 
                        AR.RiderDevice_Id
                    FROM `call_dakaar`.`activeriders` AR

            LEFT JOIN `call_dakaar`.`rider` R ON AR.Rider_Id = R.Rider_Id
            LEFT JOIN `call_dakaar`.`city` C ON AR.City_Id = C.City_Id
            LEFT JOIN `call_dakaar`.`vehicle` V ON AR.Vehicle_Id = V.Vehicle_Id';

      $activeRiders = $pdo->query($queryForRiders);
      //$data  = $activeRiders->fetch(PDO::FETCH_ASSOC);
      while ($row  = $activeRiders->fetch(PDO::FETCH_ASSOC)){


          $rider_name = $row['RiderName'];
          $longitude  = $row['CurrentLongitude'];
          $latitude = $row['CurrentLatitude'];
          $locations[]=array( $rider_name, $latitude, $longitude );

      }
      $markers = json_encode( $locations );

?>
  

JQuery函数

    $(document).ready(function() {
        $('#map').height($('.page-container').height());
        $( window ).resize(function() {
            $('#map').height($('.page-container').height());
        });
        <?php
        echo "var markers=$markers;\n";
        ?>
  

初始化地图

        map = new GMaps({
            el: '#map',
            lat: 24.8615,
            lng: 67.0099,
            zoom: 12,
            zoomControl : true,
            zoomControlOpt: {
                style : 'SMALL',
                position: 'TOP_LEFT'
            },
            circleOptions: {
                fillColor: '#ffff00',
                fillOpacity: 1,
                strokeWeight: 5,
                clickable: false,
                editable: true,
                zIndex: 1
            },
            panControl : false,
            streetViewControl : false,
            mapTypeControl: false,
            overviewMapControl: false,
    var i = 0;
        setInterval( function(){
            map.addMarker({
                lat: markers[i][1],
                lng: markers[i][2],
                icon: 'http://calldakaar.com/dashboard/assets/images/admin/bike.png',
                animation: google.maps.Animation.DROP,
                draggable:true,
                title: markers[i][0]
            });
            i += 1;
        },100);

0 个答案:

没有答案