var map = null;
var geocoder = null;

function loadGmap() {
    if (GBrowserIsCompatible()) {
        // Init map & set controls
        map = new GMap2(document.getElementById("map_location"));
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());        
        
        // Get geocode
        // geocoder = new GClientGeocoder();
        // getLatLng("Av. de la Gare 9, Sion");

        // Set location
        var point = new GLatLng(46.228942, 7.358777);
        map.setCenter(point, 15);
        var marker = new GMarker(point);
        map.addOverlay(marker);    
                
        // GEvent.addListener(marker, "click", function() {
        //     marker.openInfoWindowHtml("");
        // });
    }
}
       
function getLatLng(address) {
    geocoder.getLatLng(
        address,
        function(point) {
            if (!point) {
                alert(address + " not found");
            } else {        
                map.setCenter(point, 13);
                var marker = new GMarker(point);
                map.addOverlay(marker);

                document.write("lat: " + point.lat() + "<br/>lng: " + point.lng());
            }
        }
    );
}
