﻿var map = null;
var geocoder = null;
var prevMarker = null;


	var icon = new GIcon();
	icon.shadow = "images/shadow.png";
	icon.iconSize = new GSize(24, 16);
	icon.shadowSize = new GSize(59, 24);
	//icon.iconAnchor = new GPoint(16, 16);
	//icon.infoWindowAnchor = new GPoint(16, 1);
	icon.iconAnchor = new GPoint(0, 24);
	icon.infoWindowAnchor = new GPoint(0, 1);

//var map = new GMap2(document.getElementById("my_map"));
//map.setCenter(new GLatLng(25.08532, 121.561498), 11);
var myIcon = new GIcon();
//Icon 圖片 (必要)
myIcon.image = "images/google_map/qart_icon.png";
//Icon 左上角相對於 (必要)
myIcon.iconAnchor = new GPoint(40, 0);
//訊息視窗相對於 Icon 左上角位置 (必要)
myIcon.infoWindowAnchor = new GPoint(40, 0);
//Icon 尺寸
myIcon.iconSize = new GSize(80, 49);
//陰影圖片
myIcon.shadow = "images/google_map/qart_shadow.png";
//陰影尺寸
myIcon.shadowSize = new GSize(80, 49);
//拖拽標記時視覺上垂直「上升」的距離離
myIcon.maxHeight = 20;
//var myMarker = new GMarker( new GLatLng(25.08532, 121.561498), {icon:myIcon, draggable:true} );
//map.addOverlay( myMarker );


function initialize() {
	if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("google_map"));
		//map.setCenter(new GLatLng(24.240206, 120.632082), 12);
        map.setUIToDefault();
		geocoder = new GClientGeocoder();
	}
}

//======================================
//  1.指標跳到地址所在位置
//  2.將新位置的(x,y)座標值填入表格
//======================================
//*
function showAddress(text, address, not_found_ol) {
	if (geocoder) {
		geocoder.getLatLng(
			address,
			function(point) {
				if (!point) {
					alert("「" + address + "」" + not_found_ol + "!!");
				} else {
					map.setCenter(point, 12);
					var marker = new GMarker(point, {icon: myIcon});
                    //var marker = new GMarker(point);
                    //*
					GEvent.addListener(marker, "click", function() {
						//document.getElementById("google_map_message").innerHTML = address;
                        marker.openInfoWindowHtml(text);
					});
                    //*/
                    map.clearOverlays();
                    map.addOverlay(marker);
                    marker.openInfoWindowHtml(text);
					if(prevMarker != null) {
						map.removeOverlay(prevMarker);
					}
					prevMarker = marker;
				}
			}
		);
	}
}
//*/
