var map = null;
var geocoder = null;
var marker2 = null;

function createMarker(point, html, icon){
	var marker = new GMarker(point, icon);
	GEvent.addListener(marker, "mouseover", function() {
		marker.openInfoWindowHtml(html);
		});
	return marker;
	}

function load() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));
		map.addControl(new GLargeMapControl());
		map.addControl(new GScaleControl());
		map.addControl(new GMapTypeControl());
		map.enableContinuousZoom();
		map.enableDoubleClickZoom();

	// GClientGeocoderを初期化
	geocoder = new GClientGeocoder();
	
	var center = new GLatLng(34.251464, 133.85406);
	map.setCenter(center, 10);

	icon = new GIcon();
	icon.image = '../img/marker.gif';
	icon.iconSize = new GSize( 25, 33 );	// 画像の大きさ
	icon.shadow = '../img/marker_shadow.png';
	icon.shadowSize = new GSize( 45, 29 );	// 影画像の大きさ
	icon.iconAnchor = new GPoint( 12, 32 );	// 画像の「基準点」
	icon.infoWindowAnchor = new GPoint( 12, 32 );	// 情報ウィンドウの基準点	
	var html; 
	var point;


	point = new GLatLng(34.247844,133.93006);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/suki/" target="_blank">主基産業（株）</a></p><p class="gMapAdd">綾歌郡綾川町萱原７９１-１</p><p class="gMapTel">087（876）1151</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.291353,133.814615);
	html = '<p class="gMapCom"><a href="http://www.honesty-homes.co.jp/" target="_blank">（株）大澤工務店</a></p><p class="gMapAdd">丸亀市土器町東３－５３１</p><p class="gMapTel">0877（58）1228</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.317401,134.08147);
	html = '<p class="gMapCom"><a href="http://www.e-house.co.jp/daiwa-kenzai/" target="_blank">（株）大和建材</a></p><p class="gMapAdd">高松市元山町６６８-３</p><p class="gMapTel">087（867）3647</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.309016,134.058733);
	html = '<p class="gMapCom"><a href="http://www.atom47.com/" target="_blank">（株）アトムアソート</a></p><p class="gMapAdd">高松市伏石町２１１９-５</p><p class="gMapTel">087（815）3777</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.298436,133.844909);
	html = '<p class="gMapCom"><a href="http://www.fukeproduct.co.jp/" target="_blank">（株）フケプロダクト</a></p><p class="gMapAdd">坂出市川津町３８２９-２</p><p class="gMapTel">0877（44）2233</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.215441,133.679005);
	html = '<p class="gMapCom"><a href="http://www.kita-kenzai.com/" target="_blank">（株）喜田建材</a></p><p class="gMapAdd">三豊市詫間町詫間８９０-１</p><p class="gMapTel">0875（83）3669</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.124106,133.677569);
	html = '<p class="gMapCom"><a href="http://www.k3kyo.co.jp/" target="_blank">（株）三協</a></p><p class="gMapAdd">観音寺市植田町１７１３－１</p><p class="gMapTel">0875（23）2388</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.302685,133.813862);
	html = '<p class="gMapCom"><a href="http://www.taiyouh.co.jp/" target="_blank">（株）大洋ハウジング</a></p><p class="gMapAdd">丸亀市土器町東９丁目１２２-１５-１F</p><p class="gMapTel">0877（43）2033</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.268144,133.772898);
	html = '<p class="gMapCom"><a href="http://www.arigato-yamakura.com/" target="_blank">（株）山倉建設</a></p><p class="gMapAdd">仲多度郡多度津町南鴨４－３</p><p class="gMapTel">0877（32）6600</p>';
	map.addOverlay(createMarker(point, html, icon));

	point = new GLatLng(34.26402,133.813924);
	html = '<p class="gMapCom"><a href="http://www.okurahouse.co.jp/" target="_blank">（株）オークラハウス</a></p><p class="gMapAdd">丸亀市郡家町３５２９-１</p><p class="gMapTel">0877(56)1133</p>';
	map.addOverlay(createMarker(point, html, icon));


	}
}


function showAddress(address) {
	if (geocoder) {
		geocoder.getLatLng(
		address,
			function(point) {
				if (!point) {
				alert(address + " not found");
				} else {
					if(marker2 != null){
					map.removeOverlay(marker2);
					}
				var icon = new GIcon();
				icon.image = "../img/aicon_map.gif";  //アイコン画
				icon.shadow = "../img/aicon_map.gif"; //影の画
				icon.iconSize = new GSize(36, 36);    //アイコンサイズ
				icon.shadowSize = new GSize(36, 36); //影のサイズ
				icon.iconAnchor = new GPoint(18, 36);
				icon.infoWindowAnchor = new GPoint(18, 0);
				var markeropts = new Object();
				markeropts.icon = icon;
				map.setCenter(point, 13);
				marker2 = new GMarker(point, icon);
				map.addOverlay(marker2);
				marker2.openInfoWindowHtml(address);
				}
			}
		);
	}
}

