JSFiddle - React, Tailwind, and code Playground

by liyuanqiu

HTML

<!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">
    <title>鼠标绘制点线面</title>
    <link rel="stylesheet" href="https://cache.amap.com/lbs/static/main1119.css"/>
    <script src="https://webapi.amap.com/maps?v=1.4.8&key=c054a692dcc10900883978137bc9fc01&plugin=AMap.MouseTool"></script>
    <script type="text/javascript" src="https://cache.amap.com/lbs/static/addToolbar.js"></script>
</head>
<body>
<div id="container"></div>
<div class="button-group">
    <input type="button" class="button" value="鼠标绘制点" id="point"/>
    <input type="button" class="button" value="鼠标绘制线" id="line"/>
    <input type="button" class="button" value="鼠标绘制面" id="polygon"/>
</div>
<script>
    var map = new AMap.Map("container", {
        resizeEnable: true
    });	
    //在地图中添加MouseTool插件
    var mouseTool = new AMap.MouseTool(map);
    console.log(mouseTool);
    AMap.event.addDomListener(document.getElementById('point'), 'click', function() {
        mouseTool.marker({offset:new AMap.Pixel(-14,-11)});
    }, false);
    AMap.event.addDomListener(document.getElementById('line'), 'click', function() {
        mouseTool.polyline();
    }, false);
    AMap.event.addDomListener(document.getElementById('polygon'), 'click', function() {
        mouseTool.rectangle();
    }, false);
</script>
</body>
</html>