﻿function GoogleMapControlObj(containerName)
{
    this.ContainerName = containerName;
    this.Map;
    this.Geocoder;
    this.Properties = null;
    this.PropertiesLoaded = false;
    var me = this;
    
    // methods
    this.InitMap = function()
    {
        if (GBrowserIsCompatible()) {
            // map
            this.Map = new GMap2(document.getElementById(this.ContainerName));
            this.Map.setCenter(new GLatLng(50.728748, -1.847307), 8);
            //this.Map.addControl(new GLargeMapControl());
            this.Map.addControl(new GSmallMapControl());
            this.Map.enableScrollWheelZoom();
            var mapControl = new GMapTypeControl();
            this.Map.addControl(mapControl);
            // geocoder
            this.Geocoder = new GClientGeocoder();
        }
    }
    
    this.AddMarker = function(lat, lon)
    {
        this.Map.clearOverlays();
        var point = new GLatLng(lat, lon)
        var marker = new GMarker(point, { clickable: true });
        //marker.bindInfoWindowHtml(me.Properties[i][2]);
        me.Map.addOverlay(marker);
        me.Map.setCenter(point, 16);
    }

    this.InitMap();
}
