/* standard script to initialize the Google Maps API. More information on:
 * http://code.google.com/intl/nl-NL/apis/maps/documentation/javascript/tutorial.html
 * 
 * the address used is stored in the address variable;
 */

dL.googleMapsAPI = (function namespace() {       
    
    var map, geocoder;    
    var address = " Van der Duijnstraat 5, Utrecht, The Netherlands";
    
    var callback = function (results, status) {
        if (status === google.maps.GeocoderStatus.OK) {
            var location = results[0].geometry.location;
            map.setCenter(location);
            var marker = new google.maps.Marker({
                map: map,
                position: location
            });
        } else 
            console.debug("geocoder failed to retrieve location with address: " + address)
    }
    
    var calculateAddressCoordinates = function () {
        geocoder.geocode({"address" : address}, callback);
    }
    
    return {
        initialize : function () {            
            geocoder = new google.maps.Geocoder();
            var mapOptions = {
              zoom: 15,              
              mapTypeId: google.maps.MapTypeId.ROADMAP
            };     
            calculateAddressCoordinates();
            map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
            
        }
    };
}())

dL.addEventListener("load", window, dL.googleMapsAPI.initialize);
