我尝试使用 yandex 地图在特定时间和地点获取交通数据。我看这个页面(yandex 地图的 api)。我可以在自己的地图上显示交通数据。使用地理编码,我从 yandex 地图中提取了一些数据(地名、坐标等)。但我不知道如何只提取交通数据。我该怎么做?yandex map api上有什么功能吗?
我在地图上显示交通数据的简单代码如下
ymaps.ready(init);
var myMap,
myPlacemark;
function init(){
myMap = new ymaps.Map ("mapId", {
center: [28.968484, 41.01771],
zoom: 7
});
myPlacemark = new ymaps.Placemark([28.968484, 41.01771], {
content: 'Moscow!',
balloonContent: 'Capital of Russia'
});
// This page should show traffic and the "search on map" tool
ymaps.load(['package.traffic', 'package.search'], addControls);
myMap.geoObjects.add(myPlacemark);
}
function addControls(map) {
myMap.controls.add('trafficControl').add('searchControl');
var trafficControl = new ymaps.control.TrafficControl({shown: true});
map.controls.add(trafficControl);
function updateProvider () {
trafficControl.getProvider('traffic#actual').update();
}
// We will send a request to update data every 4 minutes.
window.setInterval(updateProvider, 1 * 60 * 1000);
}