2013-07-05 17 views

回答

0

移動物體的信息在哪裏? 它是一個實時系統還是隻是一個模擬?

在任何情況下,您都可以嘗試輪詢服務器使用JS每秒獲取新座標幾次,並更新地圖上的標記位置。

編輯

下面你有工作移動物體沒有從谷歌教程(https://google-developers.appspot.com/maps/documentation/javascript/examples/full/overlay-symbol-animate)採取輪詢的例子。你需要改變的是獲得座標的方式。

var line; 

function initialize() { 
    var mapOptions = { 
    center: new google.maps.LatLng(20.291, 153.027), 
    zoom: 6, 
    mapTypeId: google.maps.MapTypeId.TERRAIN 
    }; 

    var map = new google.maps.Map(document.getElementById('map-canvas'), 
    mapOptions); 

    var lineCoordinates = [ 
    new google.maps.LatLng(22.291, 153.027), 
    new google.maps.LatLng(18.291, 153.027) 
    ]; 

    var lineSymbol = { 
    path: google.maps.SymbolPath.CIRCLE, 
    scale: 8, 
    strokeColor: '#393' 
    }; 

    line = new google.maps.Polyline({ 
    path: lineCoordinates, 
    icons: [{ 
     icon: lineSymbol, 
     offset: '100%' 
    }], 
    map: map 
    }); 

    animateCircle(); 
} 

function animateCircle() { 
    var count = 0; 
    window.setInterval(function() { 
     count = (count + 1) % 200; 

     var icons = line.get('icons'); 
     icons[0].offset = (count/2) + '%'; 
     line.set('icons', icons); 
    }, 20); 
} 

google.maps.event.addDomListener(window, 'load', initialize); 
+0

是座標數據庫,使用web服務 – Chirag

+0

那麼最簡單的方法就是所有的座標傳遞給你的JavaScript,然後遍歷的表的存儲和變化相應座標 – gawi