
Yandex.Traffic: get coverage areas of traffic jams + alternative cork gadget

Along with trf.maps.yandex.net/trf/stat.js , Yandex.Traffic has trf.maps.yandex.net/trf/coverage.js . This script tells us which regions are covered by traffic data (well, or at least such information is supported).
YMaps.TrafficLoader.onLoad(
"coverage",
{
regions: (function(){
function p(x,y){
return new YMaps.GeoPoint(x,y);
}
function b(l,b,r,t){
return new YMaps.GeoBounds(p(l,b),p(r,t));
}
return [
{
name:"Москва и Московская область",
regionId:"1",
view:{
point:p(37.620070,55.753630),
boundedBy:b(36.61977492,55.3105725984,38.35467432,56.4313303008)
},
boundedBy:b(35.14318524,54.2560801359,40.20433848,56.9613240948)
}
];
})()
}
);
* This source code was highlighted with Source Code Highlighter.
If you make all the transformations that are performed, the following object appears at the input:
return {
regions: [
{
name:"Москва и Московская область",
regionId:"1",
view:{
point: YMaps.GeoPoint(37.620070,55.753630),
boundedBy: YMaps.GeoBounds(36.61977492,55.3105725984,38.35467432,56.4313303008)
},
boundedBy: YMaps.GeoBounds(35.14318524,54.2560801359,40.20433848,56.9613240948)
}
];
}
* This source code was highlighted with Source Code Highlighter.
YMaps.TrafficLoader is used again. The data comes in the form of an object with the regions field, which contains an array of objects. Each object has the same set of fields:
- name - the name of the region or city;
- regionId is some kind of ID. it is also present in the issuance of stat.js;
- view: viewport, view.point - an object of type YMaps.GeoPoint - the center of the region, it is convenient to use it together with YMaps.Map.setCenter (geoPoint) to go to the desired area, view.boundedBy - YMaps.GeoBounds - a rectangle that bounds the coverage area;
- boundedBy - similar to view.boundedBy.
According to the results of "research", he made Windows Sidebar Widgets with traffic jams in any city that is now supported by Yandex. Not as cool as the original, but it allows you to watch the map directly in the widget without opening the site itself.
Download widget for Windows Sidebar “Other Yandex.Traffic”