html,
body,
#container {
width: 100%;
height: 100%;
}
椭圆的绘制和编辑利用mouseTool绘制覆盖物
绘制线段
绘制多边形
绘制矩形
绘制圆形
var map = new AMap.Map("container", {
center: [116.434381, 39.898515],
zoom: 14
});
var mouseTool = new AMap.MouseTool(map)
function drawPolyline () {
mouseTool.polyline({
strokeColor: "#3366FF",
strokeOpacity: 1,
strokeWeight: 6,
// 线样式还支持 'dashed'
strokeStyle: "solid",
// strokeStyle是dashed时有效
// strokeDasharray: [10, 5],
})
}
function drawPolygon () {
mouseTool.polygon({
strokeColor: "#FF33FF",
strokeOpacity: 1,
strokeWeight: 6,
strokeOpacity: 0.2,
fillColor: '#1791fc',
fillOpacity: 0.4,
// 线样式还支持 'dashed'
strokeStyle: "solid",
// strokeStyle是dashed时有效
// strokeDasharray: [30,10],
})
}
function drawRectangle () {
mouseTool.rectangle({
strokeColor:'red',
strokeOpacity:0.5,
strokeWeight: 6,
fillColor:'blue',
fillOpacity:0.5,
// strokeStyle还支持 solid
strokeStyle: 'solid',
// strokeDasharray: [30,10],
})
}
function drawCircle () {
mouseTool.circle({
strokeColor: "#FF33FF",
strokeOpacity: 1,
strokeWeight: 6,
strokeOpacity: 0.2,
fillColor: '#1791fc',
fillOpacity: 0.4,
strokeStyle: 'solid',
// 线样式还支持 'dashed'
// strokeDasharray: [30,10],
})
}
mouseTool.on('draw', function(event) {
// event.obj 为绘制出来的覆盖物对象
log.info('覆盖物对象绘制完成')
})