<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>JavaScript Maps API</title>
<script language="javascript" src=" http://api.51ditu.com/js/maps.js "></script>
</head>
<body>
<!--你可以更改iframe的width,height尺寸来决定要显示的地图大小-->
<iframe src="http://my.51ditu.com/my/single/final/webmap.html?lng=10890788&lat=3423587&zoom=0&txt=山木培训高新分校" width="500" height="450" ></iframe>
<div id="myMap" style="position:relative; width:400px; height:300px;"></div>
<script language="javascript">
var maps = new LTMaps( "myMap" );
maps.cityNameAndZoom( "xian" , 5 );
//添加标准缩放控件
//var control = new LTStandMapControl();
//maps.addControl( control );
//添加简易缩放控件
//var control = new LTSmallMapControl();
//maps.addControl( control );
//添加拉框放大控件
//var control = new LTZoomInControl();
//maps.addControl( control );
//使用拉框查找功能
/*
var control = new LTZoomSearchControl();
maps.addControl( control );
function doit(){
var bounds = control.getBoundsLatLng();
var xmax = bounds.getXmax();
var ymax = bounds.getYmax();
var xmin = bounds.getXmin();
var ymin = bounds.getYmin();
alert( "Max-X:"+xmax+"/nMax-Y:"+ymax+"/nMin-X:"+xmin+"/nMin-Y:"+ymin );
}
LTEvent.addListener( control , "mouseup" , doit );
*/
//添加标注控件
/*
var control = new LTMarkControl();
maps.addControl( control );
function getPoi(){
var poi = control.getMarkControlPoint();
alert( "纬度:" + poi.getLatitude() + "/n经度:" + poi.getLongitude() );
}
LTEvent.addListener( control , "mouseup" , getPoi );
*/
//JavaScript代码实现地图平移 有用
setTimeout( "maps.moveToCenter( new LTPoint( 10890772,3423589))" , 10 );
//在地图上添加个性化的标记
//var marker1 = new LTMarker(new LTPoint(10890772,3423589));
//var marker2 = new LTMarker( new LTPoint(11641152,3992640));
//maps.addOverLay( marker1 );
//maps.addOverLay( marker2 );
//修改我的标记的图标和大小, 有用
var icon = new LTIcon();
icon.setImageUrl( "0.gif" );
icon.setWidth( 24 );
icon.setHeight( 24 );
var marker1 = new LTMarker( new LTPoint( 10890772,3423589 ) , icon );
//LTMarker.setInfoWinWidth( 100 );
//LTMarker.setInfoWinHeight( 40 );
maps.addOverLay( marker1 );
LTEvent.addListener( marker1 , "click" , function(){ marker1.openInfoWinHtml( "<a href=http://www.100class.com target=_blank>山木培训高新分校</a></br>乘车路线" ) } );
//双击放大功能
var moveLsitener;
function onDblClick()//定义在双击的时候执行的函数
{
moveLsitener=LTEvent.addListener(maps,"moveend",onMoveEnd);
//因为系统默认双击的时候会将地图定位到中心,因此,只需要定义地图在定位到中心完成之后放大地图即可
}
function onMoveEnd()//定义地图在定位到中心完成之后执行的函数
{
LTEvent.removeListener(moveLsitener);//删除事件注册
maps.zoomIn();//放大地图
}
LTEvent.addListener(maps,"dblclick",onDblClick);//绑定事件注册
var infoWin = new LTInfoWindow( marker1 );
infoWin.setLabel( "<a href=http://www.100class.com target=_blank>山木培训高新分校</a></br>乘车路线" );
maps.addOverLay( infoWin );
/* 增加多个标注
var points = new Array(0);
points.push( new LTPoint( 11641088 , 3992704 ) );
points.push( new LTPoint( 11636160 , 3991104 ) );
points.push( new LTPoint( 11642688 , 3988608 ) );
points.push( new LTPoint( 11634688 , 3987136 ) );
function addInfoWin( obj , num ){
var info = new LTInfoWindow( obj );
function doit(){
info.setLabel( "这是第 " + num + "个标记!" );
maps.addOverLay( info );
}
LTEvent.addListener( obj , "mouseover" , doit );
}
for( var i=0;i<points.length;i++ ){
var marker = new LTMarker( points[i]);
addInfoWin( marker , i );
maps.addOverLay( marker );
}
*/
maps.handleKeyboard(); //键盘操作支持
maps.handleMouseScroll();//鼠标滚轮支持
maps.handleDoubleclick();
</script>
</body>
</html>