﻿document.writeln('<script language="javascript" src="http://api.51ditu.com/js/maps.js" type="text/javascript"></script>');
function top(){}
function foot(){}
function sp1(){}
function sp2(){}
function sp3(){}
var m = document.getElementById("myMap");
function inGMap(tt){}
function inMap(tt){
//alert(document.getElementById("myMap").innerHTML);
}
var g='';
var u='http://www.nanking.cc/';
var uu='';
var x=y=0;
var pt=window.location.search.split("&");
pt[0]=pt[0].replace('?','');
function getMap(info,x,y,z){
u += 'map/';
//var maps = new LTMaps( "myMap" );
document.write('<div id="floatTips"><div id="bdd"><div id="tt"><a href="###" class="rt" onclick="javascript:hide()"><img src="./files/x.gif" alt="关闭" /></a><span class="lt">发送给朋友</span></div><div id="mb"></div></div></div>');
initFloatTips();
if(z==undefined){if(x=='zhixia'){x='beijing';}maps.cityNameAndZoom( x , y );}
else{maps.centerAndZoom ( new LTPoint( x , y ) , z );}

maps.handleKeyboard(); //键盘操作支持
//maps.handleMouseScroll();//鼠标滚轮支持
LTEvent.bind(maps,"dblclick",maps,function(){this.zoomIn()});//绑定事件，在双击的时候先执行放大操作
LTEvent.bind(maps,"lclick",maps,function(){voit_ch();});//绑定事件，在双击的时候先执行放大操作
var control = new LTStandMapControl();
maps.addControl( control );
var point = new LTPoint( x , y );//
var text = new LTMapText( point );
text.setLabel( info );
text.setOpacity(0.9);
maps.addOverLay( text );
Loc();
LTEvent.addListener(maps,"move",Loc);
var control = new LTMarkControl();
maps.addControl( control );
	var icon=new LTIcon("http://www.wuqing.cc/map/centerPoi.gif",[24,24],[12,12]);
	var marker=new LTMarker(new LTPoint(x,y),icon);
	maps.addOverLay(marker);

function getPoi(){

var poi = control.getMarkControlPoint();
show(poi.getLatitude(),poi.getLongitude(),maps.getCurrentZoom(),0);
}

LTEvent.addListener( control , "mouseup" , getPoi );
}
function getGMap(info,x,y,z){
u+='map/';
uu=u;
u+='sat.php';
document.write('<div id="floatTips"><div id="bdd"><div id="tt"><a href="###" class="rt" onclick="javascript:hide()"><img src="./files/x.gif" alt="关闭" /></a><span class="lt">发送给朋友</span></div><div id="mb"></div></div></div>');
initFloatTips();
x=x/100000;y=y/100000;
	if (GBrowserIsCompatible()) {
	map.setCenter(new GLatLng(y, x),z,G_HYBRID_MAP);
	map.addControl(new GLargeMapControl());
//	map.addControl(new GMapTypeControl());
	map.enableContinuousZoom();
	map.enableDoubleClickZoom();
	gLoc();
	GEvent.addListener(map, "move", gLoc);
//添加标注
		function Mark(){}
		Mark.prototype = new GControl();
		Mark.prototype.initialize = function(map) {
			var container = document.createElement("div");
			var MarkDiv = document.createElement("div");
			this.setButtonStyle_(MarkDiv);
			container.appendChild(MarkDiv);
			MarkDiv.appendChild(document.createTextNode("发送给朋友"));
			GEvent.addDomListener(MarkDiv, "click", function() {
			var m = document.getElementById("myMap");
			m.className="hand";
var mk=GEvent.addListener(map, "click", function(marker, point) {

	if (marker) {
		map.removeOverlay(marker);
	} else {map.clearOverlays();
		map.addOverlay(new GMarker(point));;
	}
	GEvent.removeListener(mk);
	m.className="";
	var t=point+'';
	t=t.replace('(','');
	t=t.replace(')','');
	t=t.replace(' ','');
	var a=t.split(',');
	a[0]=parseInt(a[0]*100000);
	a[1]=parseInt(a[1]*100000);
	show(a[0],a[1],map.getZoom(),1)
	});


			});
			map.getContainer().appendChild(container);
			return container;
		}
		Mark.prototype.getDefaultPosition = function() {
			return new GControlPosition(G_ANCHOR_TOP_RIGHT, new GSize(7, 7));
		}
		Mark.prototype.setButtonStyle_ = function(button) {
			button.style.textDecoration = "none";
			button.style.color = "#000000";
			button.style.backgroundColor = "white";
			button.style.font = "small Arial";
			button.style.border = "1px solid black";
			button.style.padding = "2px";
			button.style.marginBottom = "3px";
			button.style.textAlign = "center";
			button.style.width = "6em";
			button.style.cursor = "pointer";
		}
		map.addControl(new Mark());
	}
}

function Loc(){
	var c=maps.getCurrentZoom();
	var loc = document.getElementById('loc');
	var tmp=u+'?x='+maps.getCenterPoint().getLongitude()+'&y='+maps.getCenterPoint().getLatitude()+'&z='+c;
	loc.innerHTML=tmp;
}
function gLoc(){
	var t=map.getCenter()+'';
	t=t.replace('(','');
	t=t.replace(')','');
	t=t.replace(' ','');
	var a=t.split(',');
	var c=map.getZoom();
	var loc = document.getElementById('loc');
	a[0]=parseInt(a[0]*100000);
	a[1]=parseInt(a[1]*100000);
	var tmp=u+'?x='+a[0]+'&y='+a[1]+'&z='+c;
	loc.innerHTML=tmp;
}
function toSat(){
	var t=maps.getCenterPoint()+'';
	var c=maps.getCurrentZoom();
	var url='';
	url=u+'sat.php';
//	alert(url);
x=maps.getCenterPoint().getLongitude()-536;
y=maps.getCenterPoint().getLatitude()+191;
z=16-c;
	window.location=url+'?x='+x+'&y='+y+'&z='+z;
}
function toMap(){
	var t=map.getCenter()+'';
	t=t.replace('(','');
	t=t.replace(')','');
	t=t.replace(' ','');
	var a=t.split(',');
	var c=map.getZoom();
	a[0]=parseInt(a[0]*100000);
	a[1]=parseInt(a[1]*100000);
y=a[1]+536;
x=a[0]-191;
z=15-c;if(z<0){z=0;}
	window.location=uu+'?x='+y+'&y='+x+'&z='+z;
}

function show(x,y,z,m){
//alert(document.getElementById("myMap").innerHTML);
tips = document.getElementById('floatTips');
tips.style.top="500px";
tips.style.display="block";
var mb = document.getElementById('mb');
mb.innerHTML="纬度:" + x + " 经度:" + y;
if(m){
mb.innerHTML+='<form name="form1" id="form1" style="margin:0;padding:0;"><table width="100%" border="0"><tr><td width="20%">标题 : </td><td><input type="text" maxlength="25" style="width:66%;background:#fff" name="tt"/> <input name="open" value="1" type="checkbox" checked="checked" /> 是否公开?</td></tr><tr><td width="20%">选择图标:</td><td><input type="radio" name="icon" checked="checked" /><img src="./files/icon1.gif" /> <input type="radio" name="icon" /><img src="./files/icon2.gif" /> <input type="radio" name="icon" /><img src="./files/icon3.gif" /> <input type="radio" name="icon" /><img src="./files/icon4.gif" /> <input type="radio" name="icon" /><img src="./files/icon5.gif" /> <input type="radio" name="icon" /><img src="./files/icon6.gif" /> <input type="radio" name="icon" /><img src="./files/icon7.gif" /></td></tr><tr><td colspan="2" height="38" valign="middle"><input style="background:#fff;width:80%;height:24px;" onclick="javascript:creatlink(\'map/sat.php\','+x+','+y+','+z+')" type="button" value="生     成     链     接"/></td></tr><tr><td colspan="2" id="showlink"></td></tr></table></form>';
}else{
mb.innerHTML+='<form name="form1" id="form1" style="margin:0;padding:0;"><table width="100%" border="0"><tr><td width="20%">标题 : </td><td><input type="text" maxlength="25" style="width:66%;background:#fff" name="tt"/> <input name="open" value="1" type="checkbox" checked="checked" /> 是否公开?</td></tr><tr><td width="20%">选择图标:</td><td><input type="radio" name="icon" checked="checked" value="0" /><img src="./files/icon0.gif" width="16" height="16" /><input type="radio" name="icon" value="1" /><img src="./files/icon1.gif" /> <input type="radio" name="icon" value="2" /><img src="./files/icon2.gif" /> <input type="radio" name="icon" value="3" /><img src="./files/icon3.gif" /> <input type="radio" name="icon" value="4" /><img src="./files/icon4.gif" /> <input type="radio" name="icon" value="5" /><img src="./files/icon5.gif"/> <input type="radio" name="icon" value="6" /><img src="./files/icon6.gif" /> <input type="radio" name="icon" value="7" /><img src="./files/icon7.gif" /></td></tr><tr><td colspan="2" height="38" valign="middle"><input style="background:#fff;width:80%;height:24px;" onclick="javascript:creatlink(\'map/\','+x+','+y+','+z+')" type="button" value="生     成     链     接"/></td></tr><tr><td colspan="2" id="showlink"></td></tr></table></form>';
}

}
function creatlink(a,x,y,z){
if(document.form1.tt.value.length<2){alert('名称太短,请重新输入!');return false;}
var tu='http://'+document.domain+'/'+a+'?x='+y+'&y='+x+'&z='+z+'&t='+encodeURI(document.form1.tt.value)+'&i='+document.form1.open.value;
document.getElementById('showlink').innerHTML='<input onmouseover="javascript:this.focus()" onfocus="javascript:this.select()" style="width:400px;overflow:hidden" type="text" value="'+tu+'" />';
if(document.all){
document.getElementById('showlink').innerHTML+='<br><input type="button" onclick="window.external.addFavorite(\''+tu+'\',\''+document.form1.tt.value+'\')" value="收藏" /> <input type="button" onclick="javascript:window.clipboardData.setData(\'Text\', \''+tu+'\');document.getElementById(\'showlink\').innerHTML=\'<strong>复制完成!</strong>\';" value="复制" />';}
//alert(document.form1.tt.value);window.external.addFavorite(location.href,document.title)
}


function hide(){
tips = document.getElementById('floatTips');
tips.style.display="none";
}
var tips;
var theTop = 5/*这是默认高度,越大越往下*/;
var old = theTop;
function initFloatTips() {
tips = document.getElementById('floatTips');
moveTips();
}
function moveTips() {
var tt=200;
if (window.innerHeight){pos=window.pageYOffset;}
else if(document.documentElement && document.documentElement.scrollTop){pos=document.documentElement.scrollTop;}
else if (document.body) {pos=document.body.scrollTop;}
pos=pos-tips.offsetTop;
pos=tips.offsetTop+pos/10;
if (pos<theTop){pos=theTop};
if (pos!=old){tips.style.top=pos+"px";tt=20;}
old=pos;
setTimeout(moveTips,tt);
}
