var gGeo;

function showAddress()
{
	var address = document.getElementById("address").value;
	if (!gGeo)
		gGeo = new GClientGeocoder();
    
	if (gGeo)
		//gGeo.getLocations(address,addressSearchResult);
		gGeo.getLatLng(address,showAddressSearchResult);
}

function addressSearchResult(result)
{
	alert(result.Status.code);
}

function showAddressSearchResult(point)
{
	var address = document.getElementById("address").value;
	if (!point)
	{
		alert(address + " is not found");
	}
	else
	{
		map.setCenter(point, 13);
		var marker = new GMarker(point);
		map.addOverlay(marker);
		marker.openInfoWindowHtml(address);
		setCoordinate(point);
	}
}


//リストボックスで選択された項目を地図に表示
function showPlace(place)
{
	map.clearOverlays();
	
	array=place.split(";");
    var markerPoint = new GLatLng(array[1], array[2]);
	//alert(array[3]);

    map.setCenter(markerPoint, parseInt(array[3]), G_SATELLITE_MAP);
	//map.setZoom(parseInt(array[3]));
	//map.setCenter(markerPoint, 17);
    var marker = new GMarker(markerPoint);
    map.addOverlay(marker);

 	document.coordinate.selected_place.value=place;
}


function move_to()
{
	map.setCenter(new GLatLng(latitude(), longitude()), zoom_level());
}

function setCoordinate(point)
{
	setLongitude( point.lng() );
	setLatitude( point.lat() );
}

//アクセッサ
function setLongitude(lng)
{
	document.coordinate.longitude.value=lng;
}
function setLatitude(lat)
{
 	document.coordinate.latitude.value=lat;
}
function setZoomLevel(zoom)
{
 	document.coordinate.zoom_level.value=zoom;
}
function longitude()
{
	return document.coordinate.longitude.value;
}
function latitude()
{
	return document.coordinate.latitude.value;
}
function zoom_level()
{
	return document.coordinate.zoom_level.value;
}