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('覆寫物對象繪制完成')
})