zoukankan      html  css  js  c++  java
  • baidu地图:实现多点连线渲染

    <script type="text/javascript">
    var points = [
    {"Lng":125.17787645967861,"Lat":46.251826748722667},
    {"Lng":125.17786646842835,"Lat":46.251826580357911}
    ];    
    </script>
    <!DOCTYPE html>
    <html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
        <style type="text/css">
            body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
        </style>
        <script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=E06eb9d756d0eafc722effb355657b4c"></script>
        <title>GPS转百度</title>
    </head>
    <body>
        <div id="allmap"></div>
    </body>
    </html>
    <script type="text/javascript">
        // 百度地图API功能
        //GPS坐标
        var x = 125.17730456267518;
        var y = 46.250142055599344;
        var ggPoint = new BMap.Point(x,y);
        //地图初始化
        var bm = new BMap.Map("allmap");
        bm.centerAndZoom(ggPoint, 25);
        //bm.addControl(new BMap.NavigationControl());
        bm.addControl(new BMap.MapTypeControl());   //添加地图类型控件  
        bm.setCurrentCity("杭州");          // 设置地图显示的城市 此项是必须设置的  
        bm.enableScrollWheelZoom(true);     //开启鼠标滚轮缩放  
    
        
        var pointsGps=[];
        for(var i=0;i<points.length;i++){
            pointsGps.push(new BMap.Point(points[i].Lng, points[i].Lat));
        }
        
        
        var polyline = new BMap.Polyline(pointsGps, {strokeColor:"red", strokeWeight:2, strokeOpacity:0.5});   //创建折线
        bm.addOverlay(polyline);   //增加折线
        
        for(var i=0;i<pointsGps.length;i++){
            //添加gps marker和label
            var markergg = new BMap.Marker(pointsGps[i]);
            bm.addOverlay(markergg); //添加GPS marker
            var labelgg = new BMap.Label(i+1,{offset:new BMap.Size(20,-10)});
            markergg.setLabel(labelgg); //添加GPS label
        }
    </script>
  • 相关阅读:
    在线添加磁盘,扩展LVM卷案例
    iOS 通过代码关闭应用程序
    hdu1443(约瑟夫环游戏的原理 用链表过的)
    Mapper映射语句高阶应用——ResultMap
    SeekBar和RatingBar
    Myeclipse中如何修改Tomcat的端口号
    新浪微博客户端开发之OAuth认证篇
    层层递进Struts1(六)自定义转换器
    CF 13E Holes 【块状链表】
    《mysql必知必会》学习_第13章
  • 原文地址:https://www.cnblogs.com/yy3b2007com/p/7163588.html
Copyright © 2011-2022 走看看