51地图开发

最近因为工作需要,学习了一些关于地图的知识,最后还是打算采用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找到学习资料啊

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值