<!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://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css"/>
    <style>
        html, body, #container {
            height: 100%;
            width: 100%;
        }
        .custom-content-marker {
            position: relative;
            width: 25px;
            height: 34px;
        }
        .custom-content-marker img {
            width: 100%;
            height: 100%;
        }
        .custom-content-marker .close-btn {
            position: absolute;
            top: -6px;
            right: -8px;
            width: 15px;
            height: 15px;
            font-size: 12px;
            background: #ccc;
            border-radius: 50%;
            color: #fff;
            text-align: center;
            line-height: 15px;
            box-shadow: -1px 1px 1px rgba(10, 10, 10, .2);
        }
        .custom-content-marker .close-btn:hover{
            background: #666;
        }
    </style>
</head>
<body>
<div id="container"></div>
<script type="text/javascript"
        src="https://webapi.amap.com/maps?v=1.4.15&key=您申请的key值"></script>
<script type="text/javascript">
    var position = new AMap.LngLat(116.397428, 39.90923);
    // 创建地图实例
    var map = new AMap.Map("container", {
        zoom: 13,
        center: position,
        resizeEnable: true
    });
    // 点标记显示内容,HTML要素字符串
    var markerContent = '' +
        '<div class="custom-content-marker">' +
        '   <img src="https://myxmkj.com//a.amap.com/jsapi_demos/static/demo-center/icons/dir-via-marker.png">' +
        '   <div class="close-btn" onclick="clearMarker()">X</div>' +
        '</div>';
    var marker = new AMap.Marker({
        position: position,
        // 将 html 传给 content
        content: markerContent,
        // 以 icon 的 [center bottom] 为原点
        offset: new AMap.Pixel(-13, -30)
    });
    // 将 markers 添加到地图
    map.add(marker);
    // 清除 marker
    function clearMarker() {
        map.remove(marker);
    }
</script>
</body>
</html>