详细代码可参考:直接编辑运行可测试
折线的绘制和编辑-矢量图形-示例中心-JS API 示例 | 高德地图API
展示坐标点和道路线:直接作为http服务的结果返回即可前端展示了
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<style>
html,
body,
#container {
width: 100%;
height: 100%;
}
</style>
<title>压路服务结果查看</title>
<link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css" />
<script src="https://webapi.amap.com/maps?v=1.4.15&key=你申请的key&plugin=AMap.PolyEditor"></script>
<script src="https://a.amap.com/jsapi_demos/static/demo-center/js/demoutils.js"></script>
</head>
<body>
<div id="container"></div>
<div class="input-card" style="width: 120px">
</div>
<script type="text/javascript">
var map = new AMap.Map("container", {
center: [116.666193,39.877667],
zoom: 14
});
var path = [[116.66615,39.87746],[116.66626,39.8779]];
var polyline = new AMap.Polyline({
path: path,
isOutline: true,
outlineColor: '#ffeeff',
borderWeight: 1,
strokeColor: "#3366FF",
strokeOpacity: 1,
strokeWeight: 2,
// 折线样式还支持 'dashed'
strokeStyle: "solid",
// strokeStyle是dashed时有效
strokeDasharray: [10, 5],
lineJoin: 'round',
lineCap: 'round',
zIndex: 50,
})
polyline.setMap(map)
// 缩放地图到合适的视野级别
var circle = new AMap.Circle({
center: [116.666193,39.877667],
radius: 1, //半径
borderWeight: 4,
strokeColor: "#FF00FF",
strokeOpacity: 1,
strokeWeight: 2,
strokeOpacity: 2,
fillOpacity: 1,
strokeStyle: 'dashed',
strokeDasharray: [10, 10],
// 线样式还支持 'dashed'
fillColor: '#FF00FF',
zIndex: 50,
})
circle.setMap(map)
map.setFitView([ polyline ])
map.setFitView([ circle ])
</script>
</body>
</html>