﻿//<![CDATA[

function load() {
  var fac = window.location.search;
	fac = fac.split("=");
	if (fac[1] != null) {
		alert(fac[1]);
		alert(gmarkers.length);
		for (var i=0; i<gmarkers.length; i++) {
			if (gmarkers[i].id == fac[1]) {
				alert("あたり");
				map.setCenter(new GLatLng(gmarkers[i].lat, gmarkers[i].lng), parseInt(gmarkers[i].zoom)); // 中央座標を施設を中心にしリセット
			}
		}
	}
if (GBrowserIsCompatible()) {
  var gmarkers = [];
  var gicons = [];
  gicons["Ar"] = new GIcon(); // 宿泊
  gicons["Ar"].image = "/gmp/icon/ar.png";
  gicons["Ar"].iconSize = new GSize(13,14);
  gicons["Ar"].iconAnchor = new GLatLng(7,7);
  gicons["Ar"].infoWindowAnchor = new GLatLng(6,8);
	
  gicons["Ah"] = new GIcon(); // 宿泊
  gicons["Ah"].image = "/gmp/icon/ah.png";
  gicons["Ah"].iconSize = new GSize(13,14);
  gicons["Ah"].iconAnchor = new GLatLng(7,7);
  gicons["Ah"].infoWindowAnchor = new GLatLng(4,10);
	
  gicons["Dj"] = new GIcon(); // 食事
  gicons["Dj"].image = "/gmp/icon/dj.png";
  gicons["Dj"].iconSize = new GSize(13,13);
  gicons["Dj"].iconAnchor = new GLatLng(6,6);
  gicons["Dj"].infoWindowAnchor = new GLatLng(2,10);
	
  gicons["Df"] = new GIcon(); // 食事
  gicons["Df"].image = "/gmp/icon/df.png";
  gicons["Df"].iconSize = new GSize(13,13);
  gicons["Df"].iconAnchor = new GLatLng(7,7);
  gicons["Df"].infoWindowAnchor = new GLatLng(4,9);
	
  gicons["Ds"] = new GIcon(); // 食事
  gicons["Ds"].image = "/gmp/icon/ds.png";
  gicons["Ds"].iconSize = new GSize(13,13);
  gicons["Ds"].iconAnchor = new GLatLng(7,7);
  gicons["Ds"].infoWindowAnchor = new GLatLng(4,9);
	
  gicons["Di"] = new GIcon(); // 食事
  gicons["Di"].image = "/gmp/icon/di.png";
  gicons["Di"].iconSize = new GSize(13,13);
  gicons["Di"].iconAnchor = new GLatLng(7,7);
  gicons["Di"].infoWindowAnchor = new GLatLng(4,9);
	
  gicons["Dc"] = new GIcon(); // 食事
  gicons["Dc"].image = "/gmp/icon/dc.png";
  gicons["Dc"].iconSize = new GSize(13,13);
  gicons["Dc"].iconAnchor = new GLatLng(7,7);
  gicons["Dc"].infoWindowAnchor = new GLatLng(4,9);
	
  gicons["Db"] = new GIcon(); // 食事
  gicons["Db"].image = "/gmp/icon/db.png";
  gicons["Db"].iconSize = new GSize(13,13);
  gicons["Db"].iconAnchor = new GLatLng(7,7);
  gicons["Db"].infoWindowAnchor = new GLatLng(4,9);
	
  gicons["Sa"] = new GIcon(); // ショップ
  gicons["Sa"].image = "/gmp/icon/sa.png";
  gicons["Sa"].iconSize = new GSize(13,13);
  gicons["Sa"].iconAnchor = new GLatLng(7,7);
  gicons["Sa"].infoWindowAnchor = new GLatLng(4,9);
	
  gicons["Sso"] = new GIcon(); // ショップ
  gicons["Sso"].image = "/gmp/icon/sso.png";
  gicons["Sso"].iconSize = new GSize(13,13);
  gicons["Sso"].iconAnchor = new GLatLng(7,7);
  gicons["Sso"].infoWindowAnchor = new GLatLng(4,9);
	
  gicons["Ssp"] = new GIcon(); // ショップ
  gicons["Ssp"].image = "/gmp/icon/ssp.png";
  gicons["Ssp"].iconSize = new GSize(13,13);
  gicons["Ssp"].iconAnchor = new GLatLng(7,7);
  gicons["Ssp"].infoWindowAnchor = new GLatLng(4,9);
	
  gicons["Sf"] = new GIcon(); // ショップ
  gicons["Sf"].image = "/gmp/icon/sf.png";
  gicons["Sf"].iconSize = new GSize(13,13);
  gicons["Sf"].iconAnchor = new GLatLng(7,7);
  gicons["Sf"].infoWindowAnchor = new GLatLng(4,9);
	
  gicons["Se"] = new GIcon(); // ショップ
  gicons["Se"].image = "/gmp/icon/se.png";
  gicons["Se"].iconSize = new GSize(13,13);
  gicons["Se"].iconAnchor = new GLatLng(7,7);
  gicons["Se"].infoWindowAnchor = new GLatLng(4,9);
	
  gicons["Sse"] = new GIcon(); // ショップ
  gicons["Sse"].image = "/gmp/icon/sse.png";
  gicons["Sse"].iconSize = new GSize(13,13);
  gicons["Sse"].iconAnchor = new GLatLng(7,7);
  gicons["Sse"].infoWindowAnchor = new GLatLng(4,9);
	
  gicons["St"] = new GIcon(); // 観光地
  gicons["St"].image = "/gmp/icon/st.png";
  gicons["St"].iconSize = new GSize(12,12);
  gicons["St"].iconAnchor = new GLatLng(6,6);
  gicons["St"].infoWindowAnchor = new GLatLng(4,8);
	
  gicons["Ss"] = new GIcon(); // 観光地
  gicons["Ss"].image = "/gmp/icon/ss.png";
  gicons["Ss"].iconSize = new GSize(13,12);
  gicons["Ss"].iconAnchor = new GLatLng(7,6);
  gicons["Ss"].infoWindowAnchor = new GLatLng(4,8);
	
  gicons["So"] = new GIcon(); // 観光地
  gicons["So"].image = "/gmp/icon/so.png";
  gicons["So"].iconSize = new GSize(13,12);
  gicons["So"].iconAnchor = new GLatLng(7,6);
  gicons["So"].infoWindowAnchor = new GLatLng(4,8);
	
  gicons["Smt"] = new GIcon(); // 観光地
  gicons["Smt"].image = "/gmp/icon/smt.png";
  gicons["Smt"].iconSize = new GSize(13,12);
  gicons["Smt"].iconAnchor = new GLatLng(7,6);
  gicons["Smt"].infoWindowAnchor = new GLatLng(4,8);
	
  gicons["Rt"] = new GIcon(); // リソース
  gicons["Rt"].image = "/gmp/icon/rt.png";
  gicons["Rt"].iconSize = new GSize(13,13);
  gicons["Rt"].iconAnchor = new GLatLng(7,7);
  gicons["Rt"].infoWindowAnchor = new GLatLng(4,9);
	
  gicons["Lr"] = new GIcon(); // リビング
  gicons["Lr"].image = "/gmp/icon/lr.png";
  gicons["Lr"].iconSize = new GSize(13,13);
  gicons["Lr"].iconAnchor = new GLatLng(7,7);
  gicons["Lr"].infoWindowAnchor = new GLatLng(4,9);
	
  gicons["ctp"] = new GIcon(); // CTP
  gicons["ctp"].image = "/gmp/icon/ctp.png";
  gicons["ctp"].iconSize = new GSize(1,1);
  gicons["ctp"].iconAnchor = new GLatLng(1,1);
  gicons["ctp"].infoWindowAnchor = new GLatLng(1,1);
	
  gicons["cen"] = new GIcon(); // central
  gicons["cen"].image = "/gmp/icon/central.png";
  gicons["cen"].iconSize = new GSize(84,33);
  gicons["cen"].iconAnchor = new GLatLng(8,34);
  gicons["cen"].infoWindowAnchor = new GLatLng(2,10);
	
  gicons["nor"] = new GIcon(); // north
  gicons["nor"].image = "/gmp/icon/north.png";
  gicons["nor"].iconSize = new GSize(68,33);
  gicons["nor"].iconAnchor = new GLatLng(0,24);
  gicons["nor"].infoWindowAnchor = new GLatLng(2,10);
	
  gicons["eas"] = new GIcon(); // east
  gicons["eas"].image = "/gmp/icon/east.png";
  gicons["eas"].iconSize = new GSize(53,33);
  gicons["eas"].iconAnchor = new GLatLng(8,35);
  gicons["eas"].infoWindowAnchor = new GLatLng(2,10);
	
  gicons["wes"] = new GIcon(); // west
  gicons["wes"].image = "/gmp/icon/west.png";
  gicons["wes"].iconSize = new GSize(60,33);
  gicons["wes"].iconAnchor = new GLatLng(8,0);
  gicons["wes"].infoWindowAnchor = new GLatLng(2,10);
	
  gicons["sou"] = new GIcon(); // south
  gicons["sou"].image = "/gmp/icon/south.png";
  gicons["sou"].iconSize = new GSize(69,33);
  gicons["sou"].iconAnchor = new GLatLng(25,24);
  gicons["sou"].infoWindowAnchor = new GLatLng(2,10);
	
  gicons["sta"] = new GIcon(); // sta
  gicons["sta"].image = "/gmp/icon/sta.png";
  gicons["sta"].iconSize = new GSize(54,27);
  gicons["sta"].iconAnchor = new GLatLng(-2,20);
  gicons["sta"].infoWindowAnchor = new GLatLng(2,10);
  
  function createMarker(id, category, type, name, lat, lng, point, zoom, url, src, addr, tel) {
	var marker = new GMarker(point, gicons[category]);
	marker.mycategory = category;
	marker.myid = id;
	marker.mylat = lat;
	marker.mylng = lng;
	marker.myzoom = zoom;
	marker.myname = name;
	var html = "<div class='balloon'><img src='"+src+"' width='120' height='90'><br>"+type+"<br>"+name+"<br>"+addr+"<br>"+tel+"<br>"+"<a href='"+url+"'>Details >><\/a><\/div>";
	GEvent.addListener(marker, "click", function() {
		if (marker.mycategory != "cen" && marker.mycategory != "nor" && marker.mycategory != "eas" && marker.mycategory != "wes" && marker.mycategory != "sou" && marker.mycategory != "sta") {
	  	marker.openInfoWindowHtml(html);
		}
	});
	gmarkers.push(marker);
	return marker;
  }
  function show(id) {
	for (var i=0; i<gmarkers.length; i++) {
	  if (gmarkers[i].myid == id) {
		gmarkers[i].show();
		map.setCenter(new GLatLng(gmarkers[i].mylat, gmarkers[i].mylng), parseInt(gmarkers[i].myzoom)); // 中央座標を施設を中心にしリセット
	  }else{
		gmarkers[i].hide();
	  }
	}
  }
  function myclick(i) {
	GEvent.trigger(gmarkers[i],"click");
  }
  var map = new GMap2(document.getElementById("map"));
  map.addControl(new GLargeMapControl());
  map.addControl(new GScaleControl());
  map.addControl(new GMapTypeControl(true));
  map.setCenter(new GLatLng(35.004000,135.760500), 13); // 初期表示の中央座標
	
	//var tilelayer = new GTileLayer(new GCopyrightCollection(), 0, 17);
	//tilelayer.getTileUrl = function(tile, zoom){
	//	return "/gmp/icon/white.png";
	//};
	//tilelayer.getOpacity = function () { return 0.0; };
	//map.addOverlay(new GTileLayerOverlay (tilelayer));
	
	map.setMapType(G_SATELLITE_MAP);
  GDownloadUrl("/gmp/data.xml", function(doc) { // XML 引っ張る
	var xmlDoc = GXml.parse(doc);
	var Institution = xmlDoc.documentElement.getElementsByTagName("marker");
	for (var i = 0; i < Institution.length; i++) {
	  var id = Institution[i].getAttribute("id"); // ID
	  var category = Institution[i].getAttribute("category"); // カテゴリー
	  var type = Institution[i].getAttribute("type"); // 業種
	  var name = Institution[i].getAttribute("name"); // 施設名
	  var lat = parseFloat(Institution[i].getAttribute("lat")); // 緯度
	  var lng = parseFloat(Institution[i].getAttribute("lng")); // 経度
	  var point = new GLatLng(lat,lng);
	  var zoom = Institution[i].getAttribute("zoom"); // 拡大率
	  var url = Institution[i].getAttribute("url"); // リンクURL
	  var src = Institution[i].getAttribute("src"); // 画像SRC
	  var addr = Institution[i].getAttribute("addr"); // 住所
	  var tel = Institution[i].getAttribute("tel"); // 電話番号
	  var marker = createMarker(id, category, type, name, lat, lng, point, zoom, url, src, addr, tel);
	  map.addOverlay(marker);
	}
	if (document.URL.substr(0,40) == "http://www.kyotokyoto.jp/accommodations/") {
	  accommodationID = document.URL.substr(65,2); //Accommodation専用
	}
	else if (document.URL.substr(0,36) == "http://kyotokyoto.jp/accommodations/") {
	  accommodationID = document.URL.substr(61,2); //Accommodation専用
	}
	show(accommodationID); // 初期表示で見せる。それ以外は隠す
	if (document.URL.substr(0,37) == "http://www.kyotokyoto.jp/sightseeing/") {
	  sightseeingID = document.URL.substr(37,5); //Sightseeing専用
	}
	else if (document.URL.substr(0,33) == "http://kyotokyoto.jp/sightseeing/") {
	  sightseeingID = document.URL.substr(33,5); //Sightseeing専用
	}
	else if (document.URL.substr(0,42) == "http://www.kyotokyoto.jp/test/sightseeing/") {
	  sightseeingID = document.URL.substr(42,5); //Sightseeing専用
	}
	else if (document.URL.substr(0,38) == "http://kyotokyoto.jp/test/sightseeing/") {
	  sightseeingID = document.URL.substr(38,5); //Sightseeing専用
	}
	show(sightseeingID); // 初期表示で見せる。それ以外は隠す
	if (document.URL.substr(0,37) == "http://www.kyotokyoto.jp/dining_cafe/") {
	  diningID = document.URL.substr(37,5); //Dining専用
	}
	else if (document.URL.substr(0,33) == "http://kyotokyoto.jp/dining_cafe/") {
	  diningID = document.URL.substr(33,5); //Dining専用
	}
	else if (document.URL.substr(0,42) == "http://www.kyotokyoto.jp/test/dining_cafe/") {
	  diningID = document.URL.substr(42,5); //Dining専用
	}
	else if (document.URL.substr(0,38) == "http://kyotokyoto.jp/test/dining_cafe/") {
	  diningID = document.URL.substr(38,5); //Dining専用
	}
	show(diningID); // 初期表示で見せる。それ以外は隠す
	if (document.URL.substr(0,30) == "http://www.kyotokyoto.jp/shop/") {
	  shopID = document.URL.substr(30,5); //Shop専用
	}
	else if (document.URL.substr(0,26) == "http://kyotokyoto.jp/shop/") {
	  shopID = document.URL.substr(26,5); //Shop専用
	}
	else if (document.URL.substr(0,35) == "http://www.kyotokyoto.jp/test/shop/") {
	  shopID = document.URL.substr(35,5); //Shop専用
	}
	else if (document.URL.substr(0,31) == "http://kyotokyoto.jp/test/shop/") {
	  shopID = document.URL.substr(31,5); //Shop専用
	}
	show(shopID); // 初期表示で見せる。それ以外は隠す
	if (document.URL.substr(0,35) == "http://www.kyotokyoto.jp/resources/") {
	  resourcesID = document.URL.substr(35,5); //Resources専用
	}
	else if (document.URL.substr(0,31) == "http://kyotokyoto.jp/resources/") {
	  resourcesID = document.URL.substr(31,5); //Resources専用
	}
	else if (document.URL.substr(0,40) == "http://www.kyotokyoto.jp/test/resources/") {
	  resourcesID = document.URL.substr(40,5); //Resources専用
	}
	else if (document.URL.substr(0,36) == "http://kyotokyoto.jp/test/resources/") {
	  resourcesID = document.URL.substr(36,5); //Resources専用
	}
	show(resourcesID); // 初期表示で見せる。それ以外は隠す
	if (document.URL.substr(0,30) == "http://www.kyotokyoto.jp/live/") {
	  livingID = document.URL.substr(30,5); //Living専用
	}
	else if (document.URL.substr(0,26) == "http://kyotokyoto.jp/live/") {
	  livingID = document.URL.substr(26,5); //Living専用
	}
	else if (document.URL.substr(0,35) == "http://www.kyotokyoto.jp/test/live/") {
	  livingID = document.URL.substr(35,5); //Living専用
	}
	else if (document.URL.substr(0,31) == "http://kyotokyoto.jp/test/live/") {
	  livingID = document.URL.substr(31,5); //Living専用
	}
	show(livingID); // 初期表示で見せる。それ以外は隠す
  });
	var points1 = [];
      points1[0] = new GLatLng(34.989295,135.76727);
      points1[1] = new GLatLng(34.995667,135.768002);
      points1[2] = new GLatLng(35.003816,135.771545);
      points1[3] = new GLatLng(35.009063,135.771886);
      points1[4] = new GLatLng(35.017553,135.771733);
      points1[5] = new GLatLng(35.017366,135.751796);
      points1[6] = new GLatLng(34.993309,135.752563);
      points1[7] = new GLatLng(34.992808,135.753003);
      points1[8] = new GLatLng(34.989231,135.753078);
      points1[9] = new GLatLng(34.989295,135.76727);
      var polyline1 = new GPolyline(points1, "#FF0000", 2, 1);
      map.addOverlay(polyline1);
	var points2 = [];
      points2[0] = new GLatLng(34.989231,135.753078);
      points2[1] = new GLatLng(34.906808,135.656589);
      var polyline2 = new GPolyline(points2, "#FF0000", 2, 1);
      map.addOverlay(polyline2);
	var points3 = [];
      points3[0] = new GLatLng(34.989295,135.76727);
      points3[1] = new GLatLng(34.90612,135.866131);
      var polyline3 = new GPolyline(points3, "#FF0000", 2, 1);
      map.addOverlay(polyline3);
	var points4 = [];
      points4[0] = new GLatLng(35.017553,135.771733);
      points4[1] = new GLatLng(35.09442,135.865678);
      var polyline4 = new GPolyline(points4, "#FF0000", 2, 1);
      map.addOverlay(polyline4);
	var points5 = [];
      points5[0] = new GLatLng(35.017366,135.751796);
      points5[1] = new GLatLng(35.09625,135.658042);
      var polyline5 = new GPolyline(points5, "#FF0000", 2, 1);
      map.addOverlay(polyline5);
}
}

//]]>