var oH={"SN":0,"Lat":"0","Lng":"0","Zoom":0,"PicSn":0,"Title":"","Link":"","HtmlDesc":"
","SubDesc":""};
YAHOO.namespace("lemon.cx.GMapControl");
YAHOO.lemon.cx.GMapControl = function(){
var iZoom=0;
var sKey = '';
var iCurrentPointSn=0;
var aSaveMsg = new Array();
return {
setInitMap : function(){
var center = new GLatLng(0,0);
map.setCenter(center,iZoom);
YAHOO.lemon.cx.GMapControl.loadMessage(0);
this.loadMenu();
},
loadMenu:function(){
var obj=new JSONscriptRequest('http://ctb2b.hihotel.com.tw/systems/TravelMaps/getTravelPointTitles.php?act=YAHOO.lemon.cx.GMapControl.setMenu&sKey='+sKey);
obj.buildScriptTag(); // Build the script tag
obj.addScriptTag(); // Execute (add) the script tag
},
loadMessage:function(n){
if(n>0 && aSaveMsg[n]==undefined){
var obj=new JSONscriptRequest('http://ctb2b.hihotel.com.tw/systems/TravelMaps/getTravelPointHtmlDesc.php?act=YAHOO.lemon.cx.GMapControl.showMessage&n='+n+'&sKey='+sKey);
obj.buildScriptTag(); // Build the script tag
obj.addScriptTag(); // Execute (add) the script tag
}else if(typeof(aSaveMsg[n])=='object')
{YAHOO.lemon.cx.GMapControl.showMessage(aSaveMsg[n],n);}
else {YAHOO.lemon.cx.GMapControl.showMessage(oH,0);}
},
setMenu:function(aMsg){
var sHtml = '
';
sHtml += '';
for(var i in aMsg){
if(typeof(aMsg[i])!='object' || aMsg[i]['Title']==undefined)continue;
sHtml += '';
var center = new GLatLng(aMsg[i]['Lat'],aMsg[i]['Lng']);
marker = new GMarker(center, {title:aMsg[i]['Title'],draggable:false,dragCrossMove:false,clickable:true,autoPan:true});
marker.i = i;
map.addOverlay(marker);
GEvent.addListener(marker, "click", function(){/*this==marker(source)*/YAHOO.lemon.cx.GMapControl.move2Center(aMsg[this.i]['SN'],aMsg[this.i]['Lat'],aMsg[this.i]['Lng'],aMsg[this.i]['Zoom']);});
}
sHtml += '
';
document.getElementById('Gmenu').innerHTML = sHtml;
},
showMessage:function(oMsg,SN){
if(SN==undefined && oMsg == undefined)return;
if(SN!=undefined && aSaveMsg[SN]==undefined && oMsg==undefined){
oMsg = aSaveMsg[SN];
}
if(oMsg != undefined && aSaveMsg[oMsg.SN]==undefined){
aSaveMsg[oMsg.SN] = oMsg;
}
this.iCurrentPointSn = oMsg.SN;
document.getElementById('GContent').innerHTML = ''+(oMsg.Title?'
'+oMsg.Title+'
':'')+oMsg.HtmlDesc+'';
var sBody = ''+oMsg.Title+''+
(oMsg.PicSn?"
":'')
+oMsg.SubDesc+'
';
var center = new GLatLng(oMsg.Lat,oMsg.Lng);
var marker = new GMarker(center, {title:oMsg.Title,draggable:false,dragCrossMove:false,clickable:true,autoPan:true});
map.addOverlay(marker);
//map.openInfoWindowHtml(center,sBody,{maxWidth:240});
marker.openInfoWindowHtml(sBody,{maxWidth:240});
//marker.bindInfoWindowHtml(sBody,{maxWidth:240});
//marker.show();
GEvent.addListener(marker, "click", function(){marker.openInfoWindowHtml(sBody);});
this.printer();
},
move2Center:function(iSn,Lat,Lng,zoom){
var center = new GLatLng(Lat,Lng);
map.panTo(center);
map.setZoom(zoom==undefined?iZoom:zoom);
this.loadMessage(iSn);
},
printer:function(){
//Current Map display Point SN
//alert(this.iCurrentPointSn);
}
};
}();