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;
}
var position = new AMap.LngLat(116.397428, 39.90923);
// 创建地图实例
var map = new AMap.Map("container", {
zoom: 13,
center: position,
resizeEnable: true
});
// 点标记显示内容,HTML要素字符串
var markerContent = '' +
'
' ' +
'
'
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);
}