﻿google.load("maps", "2.x");

function initialize() {
    var text = "<div class='mapInfo' id='mapInfo'>" +
            "<p><strong>DEHLER &amp; NIELSEN</strong><br />" +
            "Adresse:<br />" +
            "Herman Bangs Vej 8<br />" +
            "8700 Horsens</p>" +
            "<p><a href='http://maps.google.dk/maps?f=q&source=s_q&hl=da&geocode=&q=DEHLER+%26+NIELSEN+I%2FS&sll=55.856507,9.86243&sspn=0.034252,0.111494&ie=UTF8&ll=55.863223,9.862461&spn=0.034246,0.111494&z=14&iwloc=A'>Klik her får at gå til Google Maps</a></p>" +
            "</div>";

    if (document.getElementById("map")) {
        var map = new google.maps.Map2(document.getElementById("map"));
        map.setCenter(new google.maps.LatLng(55.856507, 9.86243), 13);

        var geocoder = new GClientGeocoder();
        geocoder.getLatLng("Herman Bangs Vej 8, 8700, Horsens",
                function(point) {
                    var marker = new GMarker(point);
                    map.addOverlay(marker);
                    marker.openInfoWindowHtml(text);

                    GEvent.addListener(marker, "click",
                        function() {
                            marker.openInfoWindowHtml(text);
                        }
                    );
                }
            );
    }
}
google.setOnLoadCallback(initialize);