﻿ YMaps.jQuery(function () {
        var map = new YMaps.Map(YMaps.jQuery("#YMapsID-11")[0]);
        map.setCenter(new YMaps.GeoPoint(37.837298,55.632703), 14, YMaps.MapType.MAP);
        map.addControl(new YMaps.Zoom());
        map.addControl(new YMaps.ToolBar());
        map.addControl(new YMaps.TypeControl());

        YMaps.Styles.add("constructor#pmlbl1Placemark", {
            iconStyle : {
                href : "http://api-maps.yandex.ru/i/0.3/placemarks/pmlbl1.png",
                size : new YMaps.Point(36,41),
                offset: new YMaps.Point(-13,-40)
            }
        });


        YMaps.Styles.add("constructor#pmgnl1Placemark", {
            iconStyle : {
                href : "http://api-maps.yandex.ru/i/0.3/placemarks/pmgnl1.png",
                size : new YMaps.Point(36,41),
                offset: new YMaps.Point(-13,-40)
            }
        });


        YMaps.Styles.add("constructor#FF3732c85Polyline", {
            lineStyle : {
                strokeColor : "FF3732c8",
                strokeWidth : 5
            }
        });
       map.addOverlay(createObject("Placemark", new YMaps.GeoPoint(37.823904,55.639244), "constructor#pmlbl1Placemark", "Съезд с МКАД"));
       map.addOverlay(createObject("Placemark", new YMaps.GeoPoint(37.84955,55.626578), "constructor#pmgnl1Placemark", "Офис ПТФ \"Изол\""));
       map.addOverlay(createObject("Polyline", [new YMaps.GeoPoint(37.824206,55.63915),new YMaps.GeoPoint(37.825622,55.638652),new YMaps.GeoPoint(37.83,55.638955),new YMaps.GeoPoint(37.83796,55.639744),new YMaps.GeoPoint(37.8409,55.639635),new YMaps.GeoPoint(37.841093,55.639489),new YMaps.GeoPoint(37.841179,55.639332),new YMaps.GeoPoint(37.841372,55.639247),new YMaps.GeoPoint(37.841673,55.639125),new YMaps.GeoPoint(37.841479,55.636868),new YMaps.GeoPoint(37.848861,55.630738),new YMaps.GeoPoint(37.848775,55.630617),new YMaps.GeoPoint(37.848732,55.630507),new YMaps.GeoPoint(37.848925,55.630422),new YMaps.GeoPoint(37.849033,55.630349),new YMaps.GeoPoint(37.847316,55.626392),new YMaps.GeoPoint(37.849033,55.626161),new YMaps.GeoPoint(37.849269,55.626392),new YMaps.GeoPoint(37.849676,55.626525)], "constructor#FF3732c85Polyline", "Проезд к офису ПТФ \"Изол\""));
        
        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;
        }
    });
