码迷,mamicode.com
首页 > 其他好文 > 详细

百度地图根据经纬度

时间:2019-08-05 18:38:25      阅读:113      评论:0      收藏:0      [点我收藏+]

标签:enter   rand   enables   esc   add   比例尺   over   画线   开启   

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
});

百度地图根据经纬度

标签:enter   rand   enables   esc   add   比例尺   over   画线   开启   

原文地址:https://www.cnblogs.com/ly570/p/11304723.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!