
window.onload = function() {
    initialize();

}
function initialize() {
    var zooms = 12;
    var paramsList = $('.adress-map');
    zooms = paramsList.data('zoom');

    if (paramsList.attr('data-start-lat') && paramsList.attr('data-start-lng')) {
        var start_position = new google.maps.LatLng(paramsList.attr('data-start-lat'), paramsList.attr('data-start-lng'));
    } else {
        var start_position = new google.maps.LatLng('50.435', '30.60');
    }

    var styles=[ {
        "featureType":"administrative", "elementType":"labels.text.fill", "stylers":[ {
            "color": "#444444"
        }
        ]
    }
        , {
            "featureType":"landscape", "elementType":"all", "stylers":[ {
                "color": "#f2f2f2"
            }
            ]
        }
        , {
            "featureType":"poi", "elementType":"all", "stylers":[ {
                "visibility": "off"
            }
            ]
        }
        , {
            "featureType":"road", "elementType":"all", "stylers":[ {
                "saturation": -100
            }
                , {
                    "lightness": 45
                }
            ]
        }
        , {
            "featureType":"road.highway", "elementType":"all", "stylers":[ {
                "visibility": "simplified"
            }
            ]
        }
        , {
            "featureType":"road.arterial", "elementType":"labels.icon", "stylers":[ {
                "visibility": "off"
            }
            ]
        }
        , {
            "featureType":"transit", "elementType":"all", "stylers":[ {
                "visibility": "off"
            }
            ]
        }
        , {
            "featureType":"water", "elementType":"all", "stylers":[ {
                "color": "#46bcec"
            }
                , {
                    "visibility": "on"
                }
            ]
        }
    ];
    var settings= {
            styles:styles, zoom:zooms, scrollwheel:false, center:start_position, mapTypeControl:true, mapTypeControlOptions: {
                style: google.maps.MapTypeControlStyle.DROPDOWN_MENU
            }
            , navigationControl:false, navigationControlOptions: {
                style: google.maps.NavigationControlStyle.SMALL
            }
            , scaleControl:true, streetViewControl:true, rotateControl:true, zoomControl:true, mapTypeId:google.maps.MapTypeId.ROADMAP
        }
    ;
    var map = new google.maps.Map(document.getElementById("map_canvas"), settings);
    var image1 = new google.maps.MarkerImage('/images/markers/marker-we-1-new.png', new google.maps.Size(68, 80), new google.maps.Point(0, 0), new google.maps.Point(16, 35));
    var markers = [];
    $('.adress-map span')
        .each(function() {
            var newLat = $(this)
                .data('lat');
            var newLng = $(this)
                .data('lng');
            var newName = $(this)
                .text();
            var marker = new google.maps.Marker({
                position: new google.maps.LatLng(newLat, newLng),
                map: map,
                title: newName,
                icon: image1
            });
            markers.push(marker);
        });
    var clusterStyles = [
        {
            url: 'images/markers/clasters.png',
            height: 36,
            width: 36
        }
    ];
    markerClusterer = new MarkerClusterer(map, markers, {
        maxZoom: 10,
        gridSize: 100,
        styles: clusterStyles
    });
}
