﻿
    //<![CDATA[

    // ===== アイコン指示 =====
	var icon = Array();

	icon[0] = new GIcon();
	icon[0].image = "/map/tamura.gif";
	icon[0].iconSize = new GSize(55,23);
	icon[0].iconAnchor = new GLatLng(10,10);
	icon[0].infoWindowAnchor = new GLatLng(10,10);

	icon[1] = new GIcon();
	icon[1].image = "/map/icon/ski.gif";
	icon[1].iconSize = new GSize(25,25);
	icon[1].iconAnchor = new GLatLng(10,10);
	icon[1].infoWindowAnchor = new GLatLng(10,10);

	icon[2] = new GIcon();
	icon[2].image = "/map/icon/outdoor.gif";
	icon[2].iconSize = new GSize(30,30);
	icon[2].iconAnchor = new GLatLng(10,10);
	icon[2].infoWindowAnchor = new GLatLng(10,10);

	icon[3] = new GIcon();
	icon[3].image = "/map/icon/golf.gif";
	icon[3].iconSize = new GSize(20,20);
	icon[3].iconAnchor = new GLatLng(10,10);
	icon[3].infoWindowAnchor = new GLatLng(10,10);

	icon[4] = new GIcon();
	icon[4].image = "/map/icon/history.gif";
	icon[4].iconSize = new GSize(20,20);
	icon[4].iconAnchor = new GLatLng(10,10);
	icon[4].infoWindowAnchor = new GLatLng(10,10);

	icon[5] = new GIcon();
	icon[5].image = "/map/icon/nature.gif";
	icon[5].iconSize = new GSize(20,20);
	icon[5].iconAnchor = new GLatLng(10,10);
	icon[5].infoWindowAnchor = new GLatLng(10,10);

	icon[6] = new GIcon();
	icon[6].image = "/map/icon/sight.gif";
	icon[6].iconSize = new GSize(20,20);
	icon[6].iconAnchor = new GLatLng(10,10);
	icon[6].infoWindowAnchor = new GLatLng(10,10);

	icon[7] = new GIcon();
	icon[7].image = "/map/icon/shop.gif";
	icon[7].iconSize = new GSize(20,20);
	icon[7].iconAnchor = new GLatLng(10,10);
	icon[7].infoWindowAnchor = new GLatLng(10,10);

	icon[20] = new GIcon();
	icon[20].image = "/map/gs/idemitu.gif";
	icon[20].iconSize = new GSize(24,24);
	icon[20].iconAnchor = new GLatLng(10,10);
	icon[20].infoWindowAnchor = new GLatLng(10,10);

	icon[21] = new GIcon();
	icon[21].image = "/map/gs/jomo.gif";
	icon[21].iconSize = new GSize(24,24);
	icon[21].iconAnchor = new GLatLng(10,10);
	icon[21].infoWindowAnchor = new GLatLng(10,10);

	icon[22] = new GIcon();
	icon[22].image = "/map/gs/mobil.gif";
	icon[22].iconSize = new GSize(24,24);
	icon[22].iconAnchor = new GLatLng(10,10);
	icon[22].infoWindowAnchor = new GLatLng(10,10);

	icon[23] = new GIcon();
	icon[23].image = "/map/gs/ja.gif";
	icon[23].iconSize = new GSize(24,24);
	icon[23].iconAnchor = new GLatLng(10,10);
	icon[23].infoWindowAnchor = new GLatLng(10,10);

	icon[24] = new GIcon();
	icon[24].image = "/map/gs/eneos.gif";
	icon[24].iconSize = new GSize(24,24);
	icon[24].iconAnchor = new GLatLng(10,10);
	icon[24].infoWindowAnchor = new GLatLng(10,10);

	icon[25] = new GIcon();
	icon[25].image = "/map/gs/shell.gif";
	icon[25].iconSize = new GSize(24,24);
	icon[25].iconAnchor = new GLatLng(10,10);
	icon[25].infoWindowAnchor = new GLatLng(10,10);

	icon[26] = new GIcon();
	icon[26].image = "/map/gs/cosmo.gif";
	icon[26].iconSize = new GSize(24,24);
	icon[26].iconAnchor = new GLatLng(10,10);
	icon[26].infoWindowAnchor = new GLatLng(10,10);

	icon[30] = new GIcon();
	icon[30].image = "/map/icon/train.gif";
	icon[30].iconSize = new GSize(24,24);
	icon[30].iconAnchor = new GLatLng(10,10);
	icon[30].infoWindowAnchor = new GLatLng(10,10);


	icon[31] = new GIcon();
	icon[31].image = "/map/icon/car.gif";
	icon[31].iconSize = new GSize(24,24);
	icon[31].iconAnchor = new GLatLng(10,10);
	icon[31].infoWindowAnchor = new GLatLng(10,10);

	icon[40] = new GIcon();
	icon[40].image = "/map/combini/seven.gif";
	icon[40].iconSize = new GSize(24,24);
	icon[40].iconAnchor = new GLatLng(10,10);
	icon[40].infoWindowAnchor = new GLatLng(10,10);

	icon[41] = new GIcon();
	icon[41].image = "/map/combini/lawson.gif";
	icon[41].iconSize = new GSize(24,24);
	icon[41].iconAnchor = new GLatLng(10,10);
	icon[41].infoWindowAnchor = new GLatLng(10,10);

	icon[42] = new GIcon();
	icon[42].image = "/map/combini/family.gif";
	icon[42].iconSize = new GSize(24,24);
	icon[42].iconAnchor = new GLatLng(10,10);
	icon[42].infoWindowAnchor = new GLatLng(10,10);

    // ===== 以上アイコン指示 =====

    if (GBrowserIsCompatible()) { 
    var sidebar_html = "";
    var gmarkers = [];
    var htmls = [];
    var i = 0;
    var hp = [];

	// ===== 基礎部分、setCenterで中心座標を指定 =====
      var map = new GMap2(document.getElementById("map"));
      map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(36.872605, 139.087354), 12);

      function createMarker(point, name, html, n) { // ★ n がアイコン指示
        var marker = new GMarker(point,icon[n]);
        GEvent.addListener(marker, "click", function() { marker.openInfoWindowHtml('<div class="infowindow">' + html + '</div>'); });
        gmarkers[i] = marker;
        htmls[i] = html;
        sidebar_html += '<a href="javascript:myclick(' + i + ')">' + name + '<\/a><br />';
        i++;
        return marker;
      }

      function myclick(i) {
        gmarkers[i].openInfoWindowHtml('<div class="infowindow">' + htmls[i] + '</div>');
      }

    // ===== XML呼出 =====
      function readMap(url) {
        var request = GXmlHttp.create();
        request.open("GET", url, true);
        request.onreadystatechange = function() {
          if (request.readyState == 4) {
            var xmlDoc = request.responseXML;
            var markers = xmlDoc.documentElement.getElementsByTagName("marker");
            map.getInfoWindow().hide();
            map.clearOverlays();
            gmarkers = [];
            sidebar_html="";
            for (var i = 0; i < markers.length; i++) {
              var lat = parseFloat(markers[i].getAttribute("lat"));
              var lng = parseFloat(markers[i].getAttribute("lng"));
              var point = new GLatLng(lat,lng);
              var html = markers[i].getAttribute("html");
              var label = markers[i].getAttribute("label");
              var n = markers[i].getAttribute("n"); // ★ n がアイコン指示
              var marker = createMarker(point,label,html,n); // ★ n がアイコン指示
              map.addOverlay(marker);
            }
            document.getElementById("sidebar").innerHTML = sidebar_html;

          // ===== Poluline描画 =====
          var lines = xmlDoc.documentElement.getElementsByTagName("line");
          for (var a = 0; a < lines.length; a++) {
            var color = lines[a].getAttribute("color");
            var width  = parseFloat(lines[a].getAttribute("width"));
            var opacity  = parseFloat(lines[a].getAttribute("opacity"));
            var points = lines[a].getElementsByTagName("point");
            var pts = [];
            for (var i = 0; i < points.length; i++) {
               pts[i] = new GLatLng(parseFloat(points[i].getAttribute("lat")), parseFloat(points[i].getAttribute("lng")));
            }
            map.addOverlay(new GPolyline(pts, color, width, opacity)); // ★ 順に座標、色、幅、透過度
          }
          // ===== 以上Poluline描画 =====

          }
        }
        request.send(null);
      }
      readMap("xml/map.xml");
    // ===== 以上XML呼出 =====
      }
    //]]>
