/* global google */
(function (exports) {
    'use strict';

    function getJson(url, callback) {
        var xhr = new XMLHttpRequest();
        xhr.open('GET', url);
        xhr.setRequestHeader('accept', 'application/json');
        xhr.send(null);
        xhr.onreadystatechange = function () {
            if (xhr.readyState === XMLHttpRequest.DONE) {
                if (xhr.status >= 200 && xhr.status < 300) {
                    callback(JSON.parse(xhr.responseText));
                } else {
                    // An error occurred during the request.
                    console.error('Error: ' + xhr.status, xhr.responseText);
                }
            }
        };
    }


    function createLoader (map) {
        return function (coord, label) {
            return new google.maps.Marker({
                position: coord,
                map: map,
                title: label,
            });
        };
    }


    exports.initMap = function () {
        getJson('/lcp/peaks', function (data) {
            var map = new google.maps.Map(document.getElementById('map'), {
                zoom: 2,
                center: {lat: 45, lng: 0},
            });
            var loader = createLoader(map);
            for (var i = 0; i < data.peaks.length; i++) {
                var peak = data.peaks[i];
                var coordinates = {
                    lat: peak.coordinates[0],
                    lng: peak.coordinates[1],
                };
                loader(coordinates, peak.name);
            }
        });
    };

})(window);

@@ -777,143 +777,536 @@
     
-return new google.maps.Marker(%7B%0A                position: coord,%0A                map: map,%0A                title: label,%0A            %7D)
+var infowindow = new google.maps.InfoWindow(%7B%0A                content: %22%3Cspan%3E%22 + label + %22%3C/span%3E%22%0A            %7D);%0A            var marker = new google.maps.Marker(%7B%0A                position: coord,%0A                map: map,%0A            %7D);%0A            google.maps.event.addListener(marker, 'mouseover', function() %7B%0A              infowindow.open(map, marker);%0A            %7D);%0A            google.maps.event.addListener(marker, 'mouseout', function () %7B%0A              infowindow.close();%0A            %7D);%0A            return marker
 ;%0A  

Add mouseover titles to lcp