0
我想實現玩家的「實時」位置數據及其在地圖上顯示的移動。我在下面添加了以下代碼。 有人能幫助我如何獲取更新播放器和方式的「以GeoJSON」的位置數據使用JavaScript函數在地圖中顯示定製的實時通過自定義JavaScript函數玩家的實時位置數據
enter code here
var geojson=[
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [174.83, -36.90]
},
"properties": {
"title": "John1",
"description": "Mt Wellington, Auckland",
"marker-color": "#fc4353",
"marker-size": "large"
}
}
];
L.mapbox.map('map', 'mapbox.streets')
.setView([-36.90, 174.83,], 11)
.featureLayer.setGeoJSON(geojson);
var featureLayer = L.mapbox.featureLayer()
.loadURL('geojson')
// Once this layer loads, we set a timer to load it again in a few seconds.
.on('ready', run)
.addTo(map);
function run() {
featureLayer.eachLayer(function(l) {
map.panTo(l.getLatLng());
});
window.setTimeout(function() {
featureLayer.loadURL('geojson');
}, 2000);
}