直接上干货
<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;}
</style>
<script type="text/javascript" src="http://api./api?v=2.0&ak=输入你在百度地图的key值"></script>
<title>route</title>
</head>
<body>
<div id="allmap"></div>
</body>
</html>
<script type="text/javascript">
var map = new BMap.Map("allmap");
var point = new BMap.Point(108.994930,34.90988);
map.centerAndZoom(point, 15);
var polyline = new BMap.Polyline([
new BMap.Point(108.996396,34.91025),
new BMap.Point(109.004944,34.91393),
new BMap.Point(109.009347,34.91780),
new BMap.Point(109.021358,34.91580),
new BMap.Point(109.035063,34.91875),
new BMap.Point(109.037626,34.91972),
new BMap.Point(109.039798,34.91973),
new BMap.Point(109.039818,34.91976),
new BMap.Point(109.040039,34.91969),
new BMap.Point(109.040039,34.91969),
new BMap.Point(109.040039,34.91969),
new BMap.Point(109.040053,34.91968)
], {strokeColor:"blue", strokeWeight:6, strokeOpacity:0.5});
map.addOverlay(polyline);
</script>
代码改动的地方
1.var point = new BMap.Point(108.994930,34.90988);这个是你起始的经纬度
下面的就是一些你运行期间的经纬度
key值是要在百度地图上注册开发者之后才可以获取到的
/apiconsole/key
填完信息之后会在你所填的邮箱里,给发送一份文件,打开邮箱,点击链接
进行操作
完事之后,点击我的应用 如图:
在访问应用中有一个复制标,复制到代码标红处
写完之后保存,把文本的.txt后缀改为.html后缀
直接点开就可获得你想要的运行轨迹