
//<![CDATA[

//文字コードが。。。

var map = null;
var geocoder = null;
var nowmaker = null;

var now_x = 38.169;
var now_y = 139.516;
var now_zoom = 5;

var now_point = null;

function onMapLoad() {
	if (document.getElementById("map"))mapload();
}

function onMapUnload(){
	if(map != null)GUnload();
}

function mapload() {

  if (GBrowserIsCompatible()) {

	// GClientGeocoderを初期化
	geocoder = new GClientGeocoder();

    map = new GMap2(document.getElementById("map"));
	map.addControl(new GLargeMapControl());
	map.addControl(new GScaleControl());
	map.addControl(new GMapTypeControl());
	//map.addControl(new GOverviewMapControl());
	
	map.setCenter(new GLatLng(now_x, now_y), now_zoom);
	
	showAddress();

	/*if(document.getElementById("mapx").value > 0 && document.getElementById("mapy").value > 0){
		var tmppoint = new GLatLng(document.getElementById("mapy").value, document.getElementById("mapx").value);
		now_zoom = 14;
		map.setCenter(tmppoint, now_zoom);
		setMarker(tmppoint);
	}*/
  }
}

// 「移動する」ボタンを押されると実行されます
function showAddress() {
  var address = document.getElementById('address').value;
  if (geocoder) {
    geocoder.getLatLng(
      address,
      function(point) {
      	now_zoom = 14;
		map.setCenter(point, now_zoom);
		setMarker(point);
      }
    );
  }
}

function setMarker(point) {
	
	var icon = new GIcon();
	
	icon.image = "/hall/cms/icon.png";
	icon.iconSize = new GSize(40, 50);
	icon.iconAnchor = new GPoint(20, 50);

	nowmaker = new GMarker(point,icon);
	map.addOverlay(nowmaker);
}

//]]>

