1、问题背景
高德地图中,设置选中位置,并自定义图标和文字提示
2、实现源码
<!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="http://cache.amap.com/lbs/static/main1119.css"/>
<script src="http://webapi.amap.com/maps?v=1.3&key=c2eb520334ddc5ab2bb70a3afe6a58cc"></script>
<script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
</head>
<body>
<div id="container"></div>
<script>
var map = new AMap.Map("container",{
resizeEnable: true,
center: [115.397428, 41.90923],
zoom: 19
});
var marker = new AMap.Marker({
position: map.getCenter()
});
marker.setMap(map);
//设置鼠标划过点标记显示的文字提示
marker.setTitle("设置位置");
marker.setLabel({
offset: new AMap.Pixel(15, 15),
content: "定位名称"
});
</script>
</body>
</html>
3、实现结果