• 百度地图根据经纬度


    var map = new BMap.Map("map");
    var point = new BMap.Point(116.404, 39.915);
    map.centerAndZoom(point, 15);
    map.enableScrollWheelZoom(); // 开启鼠标滚轮缩放
    map.addControl(new BMap.ScaleControl()); // 添加比例尺控件

    var pointStr = "104.038748,30.641821,104.047789,30.648128,104.063959,30.655336,104.067264,30.660307,104.067264,30.664438,104.064008,30.665316".split(",");
    var pointArr = [];

    for (var k = 0; k < pointStr.length; k += 2) {
    pointArr.push({
    lng: pointStr[k],
    lat: pointStr[k + 1]
    });
    }

    // 生成坐标点
    var trackPoint = [];
    for (var i = 0, j = pointArr.length; i < j; i++) {
    trackPoint.push(new BMap.Point(pointArr[i].lng, pointArr[i].lat));
    }

    map.centerAndZoom(trackPoint[0], 15);

    // 画线
    var polyline = new BMap.Polyline(trackPoint, {
    strokeColor: "#1869AD",
    strokeWeight: 3,
    strokeOpacity: 1
    });
    map.addOverlay(polyline);

    // 配置图片
    var size = new BMap.Size(26, 26);
    var offset = new BMap.Size(0, -13);
    var imageSize = new BMap.Size(26, 26);
    var icon = new BMap.Icon("./express-position.png", size, {
    imageSize: imageSize
    });

  • 相关阅读:
    微信小程序支付
    python中 try、except、finally执行顺序
    磁盘设备在 Linux 下的表示方法
    sanic中间件和监听器
    sed命令详解
    awk命令详解
    gd库
    php中计算二维数组中某一元素之和
    Linux SVN 命令详解
    PHP array 操作函数
  • 原文地址:https://www.cnblogs.com/ly570/p/11304723.html
Copyright © 2020-2023  润新知