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、实现结果
再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow
原文地址:https://www.cnblogs.com/odejsjhshw/p/10367099.html
时间: 2024-11-10 19:24:14