/* 
 * Standard gzo google.map 
 *
 * var map = gzo.standardMap(
 *     document.getElementById("map"), 
 *     {zoom:5, center:new google.maps.LatLng(41.640, 12.436)}
 * );
 *
 * Opts:
 *     center: LatLng 
 *     zoom: int
 *     nswe: NSEW digital lat/lon that must appear on map 
 *         {N:northlat, S:southlat, E:eastlong, W:westlong}
 */
gzo.standardMap = function(Container, Opts)
{
    /* extract options */ 
    var opts = Opts || {};
    opts.type = opts.type || google.maps.NORMAL_MAP;
    /* default zoom level, not exceeding maximum */
    opts.zoom = Math.min(opts.zoom || 12, opts.type.getMaximumResolution());
    opts.nsew = opts.nsew || false; /* if set, the map must contain these points */
    opts.center = opts.center || false;

    var map = new google.maps.Map2(Container);

    if (opts.nsew) {
        // if there are bounds then position the map to fit them 
        var bounds = new google.maps.LatLngBounds(
            new google.maps.LatLng(opts.nsew.S,opts.nsew.W),
            new google.maps.LatLng(opts.nsew.N,opts.nsew.E)
        );
        map.setCenter(bounds.getCenter(), map.getBoundsZoomLevel(bounds), opts.type);
    } else if (opts.center) {
        /* or if there is a center use that */
        map.setCenter(opts.center, opts.zoom, opts.type);
    }

    map.savePosition();
    map.addControl(new google.maps.LargeMapControl());
    map.addMapType(google.maps.PHYSICAL_MAP);
    map.addControl(new google.maps.MapTypeControl());
    map.addControl(new google.maps.ScaleControl());
    map.addControl(new google.maps.OverviewMapControl());

    return map;
};

