﻿function gmap(elementId) 
{
    this.elementId = elementId;
    var map = null;
    var marker = null;    
    var bounds = bounds = new GLatLngBounds();
    
    this.generateMap = function() 
    {
        if (GBrowserIsCompatible()) 
        {
            map = new GMap2(document.getElementById(elementId));
            map.setCenter(new GLatLng(0, 0), 0);
            map.setUIToDefault();
        }
    }

    this.plotMarker = function(longtitude, latitude, number, html) 
    {
        var point = new GLatLng(longtitude, latitude);
        
        marker = new GMarker(point);
        marker.value = number;
        
        GEvent.addListener(marker, "click", function() {
            map.openInfoWindowHtml(point, html);
        });
        
        map.addOverlay(marker);
        bounds.extend(marker.getPoint());
    }

    this.centerMap = function() 
    {
        map.setZoom(map.getBoundsZoomLevel(bounds));
        map.setCenter(bounds.getCenter());
    }
    this.openBubble = function(html) {
        var point = marker.getPoint();
        map.openInfoWindowHtml(point, html);
    }
    this.setToSatelliteView = function() 
    {
        map.setMapType(G_SATELLITE_MAP);
    }
    this.setToHybridView = function() 
    {
        map.setMapType(G_HYBRID_MAP);
    }    
} 
