﻿//<![CDATA[
	window.onload = function() {
		map = new GMap(document.getElementById("gmap"));
		httpObj = GXmlHttp.create();
		httpObj.open("get", "BeatlesMap.xml");
		httpObj.onreadystatechange = function() {
			if (httpObj.readyState == 4) {
				var xmlData = GXml.parse(httpObj.responseText);
				var place = xmlData.getElementsByTagName("title");
				var addr = xmlData.getElementsByTagName("address");
				var lat = xmlData.getElementsByTagName("緯度");
				var lng = xmlData.getElementsByTagName("経度");
				for (var i=0; i<place.length; i++) {
					gpObj = new GPoint(lng[i].firstChild.nodeValue,lat[i].firstChild.nodeValue);
					if( i == 0 )
						map.centerAndZoom(gpObj, 1);
					marker = new GMarker(gpObj,{title : place[i].firstChild.nodeValue});
					marker.title=addr[i].firstChild.nodeValue;
			 		map.addOverlay(marker);
				}
			}
		}
		httpObj.send(null);
	
		GEvent.addListener(map, "click", function(marker){
			marker.openInfoWindowHtml("<span style='white-space:nowrap'>"+marker.title+"</span>");
		} );
		map.addControl(new GMapTypeControl());
		gGeo = new GClientGeocoder();
		ctrlObj = new GLargeMapControl();
		map.addControl(ctrlObj);
		GEvent.addListener(map, "move", function(){
			var x = (map.getCenterLatLng()).x;
			var y = (map.getCenterLatLng()).y;
			document.getElementById("point").innerHTML = "経度："+x+"<br>緯度："+y+"<br>"+location.href.split("/")[5];
		} );
	}
	function searchPoint() {
		document.getElementById("result").innerHTML = "検索中です...";
		var address = document.getElementById("geoName").value;
		gGeo.getLatLng(address, checkGeo);
	}
	function checkGeo(point) {
		if (point) {
			map.setCenter(point, 6);
			document.getElementById("result").innerHTML = "中央が該当地点です";
		}else{
			document.getElementById("result").innerHTML = "見つかりませんでした";
		}
	}
//]]>
