﻿var SetGmaps = {
	
	mark: [
		{
			latlng: [35.008587, 135.767727],
			iconsrc: '../img/gmap_icon.png',
			html: '<strong>JEUGIA(ジュージヤ)三条本店</strong><br />京都府京都市中京区石橋町三条通寺町東入11'
		}, {
			latlng: [35.008713, 135.766342],
			iconsrc: '../img/gmap_parking_icon.png',
			html: '<strong>三条パーキング</strong><br />御幸町三条・入庫は御池通からの南向き一方通行になります'
		}, {
			latlng: [35.007235, 135.764601],
			iconsrc: '../img/gmap_parking_icon.png',
			html: '<strong>駐輪所</strong><br />京都市中京区六角通柳馬場東入る大黒町81'
		}, {
			page: 'shijo_index',
			latlng: [35.003836, 135.760972],
			iconsrc: '../img/gmap_icon.png',
			html: '<strong>JEUGIA 四条店</strong><br />京都市下京区四条通東洞院長刀鉾町33 京都フコク生命四条烏丸ビル 1F/BF'
		}, {
			page: 'hana',
			latlng: [34.9973923, 135.7272749],
			iconsrc: '../img/gmap_icon.png',
			html: '<strong>JEUGIA イオンモール京都五条店</strong><br />京都市右京区西院追分町25-1-092 イオンモール京都五条ハナ3F'
		}, {
			page: 'ibaraki',
			latlng: [34.811011, 135.558436],
			iconsrc: '../img/gmap_icon.png',
			html: '<strong>JEUGIA イオン茨木店</strong><br />茨木市松ヶ本町86-4 イオン茨木ビブレ3F'
		}, {
			page: 'kitaoji',
			latlng: [35.0448053, 135.7583767],
			iconsrc: '../img/gmap_icon.png',
			html: '<strong>JEUGIA 北大路ビブレ店</strong><br />京都市北区小山北上総町49-1 北大路ビブレ4F'
		}, {
			page: 'kumiyama',
			latlng: [34.8935733, 135.7455392],
			iconsrc: '../img/gmap_icon.png',
			html: '<strong>JEUGIA イオン久御山店</strong><br />京都府久世郡久御山町森南大内156-1 イオン久御山ショッピングセンター2F'
		}, {
			page: 'kusatsu',
			latlng: [35.0243852, 135.9596051],
			iconsrc: '../img/gmap_icon.png',
			html: '<strong>JEUGIA 草津A･SQUARE（エイ・スクエア）店</strong><br />滋賀県草津市西渋川1-23-23 A･SQUARE SARA専門店棟 2F'
		}, {
			page: 'minamikusatsu',
			latlng: [35.0038659, 135.9511037],
			iconsrc: '../img/gmap_icon.png',
			html: '<strong>JEUGIA 南草津店</strong><br />滋賀県草津市野路1丁目1-1'
		}, {
			page: 'momoyama',
			latlng: [34.9369276, 135.7948761],
			iconsrc: '../img/gmap_icon.png',
			html: '<strong>JEUGIA 近鉄桃山店</strong><br />京都市伏見区桃山町山ノ下32 ショッピングセンターMOMO内近鉄百貨店桃山店2F'
		}, {
			page: 'nara',
			latlng: [34.6951079, 135.7853294],
			iconsrc: '../img/gmap_icon.png',
			html: '<strong>JEUGIA 奈良近鉄店</strong><br />近鉄（大和）西大寺駅 下車すぐ　近鉄百貨店奈良店5F'
		}, {
			page: 'nishiotsu',
			latlng: [35.0244783, 135.8602623],
			iconsrc: '../img/gmap_icon.png',
			html: '<strong>JEUGIA ジャスコシティ西大津店</strong><br />大津市皇子が丘3-11-1 ジャスコシティ西大津4F'
		}, {
			page: 'omi',
			latlng: [35.1208426, 136.1036921],
			iconsrc: '../img/gmap_icon.png',
			html: '<strong>JEUGIA マイカル近江八幡店</strong><br />近江八幡市鷹飼町500-3 マイカル近江八幡4F'
		}, {
			page: 'porta',
			latlng: [34.9858776, 135.7588331],
			iconsrc: '../img/gmap_icon.png',
			html: '<strong>JEUGIA ポルタ店</strong><br />京都市下京区烏丸通塩小路下東塩小路 京都ステーションセンターポルタ内'
		}, {
			page: 'rakunan',
			latlng: [34.9754668, 135.736499],
			iconsrc: '../img/gmap_icon.png',
			html: '<strong>JEUGIA ジャスコ洛南店</strong><br />京都市南区吉祥院御池町31 ジャスコ洛南ショッピングセンター2F'
		}, {
			page: 'uehonmachi',
			latlng: [34.6654325, 135.5196755],
			iconsrc: '../img/gmap_icon.png',
			html: '<strong>JEUGIA 上本町近鉄店</strong><br />大阪市天王寺区上本町6-1-55 近鉄百貨店上本町店11F'
		}, {
			page: 'uji',
			latlng: [34.8766475, 135.7787958],
			iconsrc: '../img/gmap_icon.png',
			html: '<strong>JEUGIA 宇治大久保店</strong><br />宇治市広野町西裏43-1'
		}
	],
	
	init: function(c) {
		
		var gmap = new GMap2(document.getElementById('gmaps'));
		var center = this.getCenter(c);
		
		// gmap.setCenter(new GLatLng(this.mark[0].latlng[0], this.mark[0].latlng[1]), 17);
		// gmap.setCenter(new GLatLng(35.009058, 135.767337), 17);
		gmap.setCenter(new GLatLng(center[0], center[1]), 16);
		
		// gmap.addControl(new GMapTypeControl());
		gmap.addControl(new GSmallMapControl());
		
		for (var i = 0, l = this.mark.length; i < l; i++) {
			
			gmap.addOverlay(this.createGmarker(gmap, i));
			
		}
		
		// 住所から緯度、経度を求める
		// this.getGeoCoder(gmap, '京都市下京区四条通');
	},

	createGmarker: function(g, i) {
		
		var m = this.mark[i];
		// Icon
		var markerOpt = { icon: this.createGIcon(m.iconsrc) };
		
		var marker = new GMarker(new GLatLng(m.latlng[0], m.latlng[1]), markerOpt);
		// infoWindow 幅の指定
		var infoWindowOpt = g.getInfoWindow();
		infoWindowOpt.maxWidth = 130;
		
		GEvent.addListener(marker, 'click', function() { marker.openInfoWindowHtml(m.html, infoWindowOpt); });
		
		return marker;
		
	},

	createGIcon: function(src) {
		
		var icon = new GIcon(G_DEFAULT_ICON);
		icon.image = src;
		icon.shadow = './img/gmap_shadow.png';
		icon.iconSize = new GSize(25, 32);
		icon.shadowSize = new GSize(25, 38);
		icon.iconAnchor = new GPoint(13, 32);
		
		return icon;
		
	},
	
	getGeoCoder: function(g, address) {
		
		var geocoder = new GClientGeocoder();
		geocoder.getLatLng(address, function(e) {
			if (e != null) {
				prompt(address, e);
				g.panTo(e);
			} else {
				alert('指定した住所はありません\n' + address);
			}
		});
		
	},
	
	getCenter: function(c) {
		
		var bodyClassName = c.split(' ')[1];
		var m = this.mark;
		
		for (var i = 0, l = m.length; i < l; i++) {
			if (m[i].page == bodyClassName) return m[i].latlng;
		}
		
	}
	
};


