我想实现玩家的“实时”位置数据及其在地图中显示的移动。我在下面添加了以下代码。 有人可以帮助我如何获得实时更新播放器的'GEOJson'位置数据以及使用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);
}