﻿YMaps.jQuery(function() {
    var map = new YMaps.Map(YMaps.jQuery("#YMapsID-755")[0]);
    map.setCenter(new YMaps.GeoPoint(30.522641, 50.452317), 16, YMaps.MapType.MAP);
    map.addControl(new YMaps.Zoom());
    map.addControl(new YMaps.ToolBar());
    map.addControl(new YMaps.TypeControl());

    YMaps.Styles.add("constructor#pmrdlPlacemark", {
        iconStyle: {
            href: "http://api-maps.yandex.ru/i/0.3/placemarks/pmrdl.png",
            size: new YMaps.Point(36, 41),
            offset: new YMaps.Point(-13, -40)
        }
    });


    YMaps.Styles.add("constructor#pmdblPlacemark", {
        iconStyle: {
            href: "http://api-maps.yandex.ru/i/0.3/placemarks/pmdbl.png",
            size: new YMaps.Point(36, 41),
            offset: new YMaps.Point(-13, -40)
        }
    });


    YMaps.Styles.add("constructor#FF3732885Polyline", {
        lineStyle: {
            strokeColor: "FF373288",
            strokeWidth: 5
        }
    });
    map.addOverlay(createObject("Placemark", new YMaps.GeoPoint(30.522437, 50.454105), "constructor#pmrdlPlacemark", "Офис \"АртПодарок\""));
    map.addOverlay(createObject("Placemark", new YMaps.GeoPoint(30.524035, 50.450234), "constructor#pmdblPlacemark", "Выход из метро"));
    map.addOverlay(createObject("Polyline", [new YMaps.GeoPoint(30.524121, 50.450227), new YMaps.GeoPoint(30.524282, 50.450337), new YMaps.GeoPoint(30.522598, 50.451234), new YMaps.GeoPoint(30.522727, 50.451358), new YMaps.GeoPoint(30.522587, 50.45146), new YMaps.GeoPoint(30.522072, 50.452974), new YMaps.GeoPoint(30.52189, 50.453406), new YMaps.GeoPoint(30.521321, 50.454166), new YMaps.GeoPoint(30.521761, 50.454317), new YMaps.GeoPoint(30.521836, 50.454248), new YMaps.GeoPoint(30.522244, 50.454351), new YMaps.GeoPoint(30.522448, 50.454098)], "constructor#FF3732885Polyline", "Дорога от метро к нам в офис"));

    function createObject(type, point, style, description) {
        var allowObjects = ["Placemark", "Polyline", "Polygon"],
                index = YMaps.jQuery.inArray(type, allowObjects),
                constructor = allowObjects[(index == -1) ? 0 : index];
        description = description || "";

        var object = new YMaps[constructor](point, { style: style, hasBalloon: !!description });
        object.description = description;

        return object;
    }
});
