最近因为工作需要,学习了一些关于地图的知识,最后还是打算采用51地图,毕竟大家都是中国人啊。呵呵
还是看看源代码吧
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html xmlns:v="urn:schemeas-microsoft-com:vml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>JavaScript Maps API</title>
<style type="text/css">
v/:*{ behavior: url(#default#VML); }
</style>
<script language="javascript" src=" http://api.51ditu.com/js/maps.js "></script>
</head>
<body>
<div id="myMap" style="position: relative; width: 640px; height: 480px;">
</div>
<script language="javascript" type="text/javascript">
var maps = new LTMaps("myMap");
maps.cityNameAndZoom("beijing", 5);
var points = new Array();
points.push(new LTPoint(11629376, 3995776));
points.push(new LTPoint(11642688, 3988608));
points.push(new LTPoint(11641152, 3992640));
var polyLine = new LTPolyLine(points); //连线
maps.addOverLay(polyLine);
//添加标记
var marker1 = new LTMarker(points[0]);
maps.addOverLay(marker1);
var d = LTFunction.getPointsDistance(points[0], points[1]); //计算2点之间的距离
var text = new LTMapText(points[1]);
text.setLabel(d);
maps.addOverLay(text);
d = LTFunction.getPointsDistance(points[1], points[2]); //计算2点之间的距离
text = new LTMapText(points[2]);
text.setLabel(d);
maps.addOverLay(text);
//
var control = new LTStandMapControl(); //缩放控件
maps.addControl(control);
maps.handleKeyboard(); //键盘操作支持
maps.handleMouseScroll(); //鼠标滚轮支持
function addPoint(point1X, point1Y, point2X, point2Y) {
var point1 = new LTPoint(point1X, point1Y);
var point2 = new LTPoint(point2X, point2Y);
var tempPoints = new Array();
tempPoints.push(point1);
tempPoints.push(point2);
polyLine = new LTPolyLine(tempPoints);
maps.addOverLay(polyLine);
d = LTFunction.getPointsDistance(point1, point2); //计算2点之间的距离
text = new LTMapText(point2);
text.setLabel(d);
maps.addOverLay(text);
}
</script>
<input type="button" οnclick="addPoint(11641152,3992640,11661152,3990640);" value="Submit" />
</body>
</html>
大家可以在http://api.51ditu.com/docs/mapone.html找到学习资料啊