var map;
var geocoder = new GClientGeocoder();
function addAdr(response)
{
    //удаляем слои, если они есть
    map.clearOverlays();
    //if (!response || response.Status.code != 200)
    //{
    //    adress_not_found(address);
    //}
    //else
    {
        //создаем объект типа GLatLng
        //place = response.Placemark[0];
        //point = new GLatLng(place.Point.coordinates[1], place.Point.coordinates[0]);
        point = new GLatLng(47.997554, 37.765562);  
        map.setCenter(point, 16);

        // Создаем собственный маркер
        var marker = get_marker(point)

        // Отмечаем маркер
        map.addOverlay (marker);
        //marker.openInfoWindowHtml("\"" + "hhhhh" + "\" не найден");
    }
}

function init_map(address)
{
    if (GBrowserIsCompatible())
    {
	    geocoder.getLocations(address, function(theResponse)
        {
            //var accuracy = theResponse.Placemark[0].AddressDetails.Accuracy;
            //if (theResponse.Status.code != 200 || accuracy < 8)
            //{
            //    return;
            //}
            //else
            {
                $("#map_title, #map_canvas").show();
                //создаем объект для работы с картой
                map = new GMap2(document.getElementById("map_canvas"));
                map.setMapType(G_NORMAL_MAP);
                map.addControl(new GLargeMapControl3D());
                geocoder.getLocations(address, addAdr);
            }
        });
    }
}

function get_marker(point)
{
    var myexIcon = new GIcon();
    myexIcon.image = "/images/marker_text.png";
    myexIcon.iconSize = new GSize(189, 45);
    myexIcon.iconAnchor = new GPoint(10, 37);
    myexIcon.infoWindowAnchor = new GPoint(5, 5);
    markerOptions = {
        icon:myexIcon
    };
    var marker = new GMarker(point, markerOptions);
    return marker;
}

