Map Index - regional lighting



  • I'm writing vba macaros with a map display.

        YMaps.jQuery(function () {
            var map = new YMaps.Map(YMaps.jQuery("#YMapsID")[0]);
            map.setCenter(new YMaps.GeoPoint(37.617671,55.752283), 6);
            YMaps.Regions.load("ru", function (state, response) {
                if (state == YMaps.State.SUCCESS) {
                    var regionVba = response.filter(function (obj) {
                        return obj.name == "Московская область";
                    })[0];
                    regionVba.setStyle({
                        polygonStyle : {
                            fillColor : "b00c0c55",
                            strokeColor : "b00c0c"
                        },
                        hasHint : true
                    });
                    map.addOverlay(regionVba);
                } else {
                    alert("Error: " + response.error.message)
                }
            });
        })
    

    What do you need to change in the code so that the area can be lit at all times, not just when it's done?

    Examples https://tech.yandex.ru/maps/doc/jsapi/1.x/mod/concepts/regions-docpage/



  • If you really want to stay with the old code, you can do that:

    ...
    if (state == YMaps.State.SUCCESS) {
        var regionVba = response.filter(function (obj) {
            return obj.name == "Московская область";
        })[0];
        // Отличия начинаются тут
        // Берем фигуры регионов
        var shapes = regionVba.metaDataProperty.encodedShapes;
        var polygon;
        // Перебираем фигуры
        for (var ix = shapes.length; ix--; ) {
            // Создаем полигон
            polygon = YMaps.Polygon.fromEncodedPoints(
                shapes[ix].coords, 
                shapes[ix].levels
            );
            // Указываем цвета
            polygon.setStyle({
                polygonStyle: {
                    fillColor: "b00c0c55",
                    strokeColor: "b00c0c"
                }
            });
            // Помещаем полученный полигон на карту
            map.addOverlay(polygon);
        }
    } else {
    ...
    

    Less of https://ru.stackoverflow.com/a/462531/177613 in the very low precision of the regions, however, the default.

    See also https://tech.yandex.ru/maps/doc/jsapi/1.x/ref/reference/regions.regionhotspot-docpage/#metaDataProperty ♪ https://tech.yandex.ru/maps/doc/jsapi/1.x/ref/reference/polygon-docpage/#.fromEncodedPoints




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2