qq.maps.MarkerDecoration类
用来定义Marker的覆盖内容
构造函数
创建MarkerDecoration类的语法:
new qq.maps.MarkerDecoration(content, offset);
参数:
content : {String | DOM Element}
(必填)内容,可以是字符串(数字会转换为字符串),也可以是DOM元素
offset : {Point}
(可选)偏移量,覆盖内容的位置相对于Marker中心点的偏移矢量,默认为(0, 0)
实例
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>设置MarkerDecoration</title>
<style type="text/css">
* {
margin: 0px;
padding: 0px;
}
body,
button,
input,
select,
textarea {
font: 12px/16px Verdana, Helvetica, Arial, sans-serif;
}
p {
width: 603px;
padding-top: 3px;
margin-top: 10px;
overflow: hidden;
}
.btn {
width: 112px;
}
</style>
<script charset="utf-8" src="https://map.qq.com/api/js?v=2.exp&key=OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77"></script>
</head>
<body onLoad="init()">
<script>
function init() {
var marker;
var center = new qq.maps.LatLng(39.90923, 116.397428);
var map = new qq.maps.Map(document.getElementById('container'),{
center: center,
zoom: 12
});
// 创建MarkerDecoration
var content = "<span style='color:#996633;'>A</span>";
var decoration = new qq.maps.MarkerDecoration(content, new qq.maps.Point(0, -5));
marker = new qq.maps.Marker({
position: center,
map: map,
decoration: decoration // 初始化Marker的decoration属性
});
}
</script>
<div style="width:603px;height:300px" id="container"></div>
</body>
</html>
这篇文章对您解决问题是否有帮助?
已解决
未解决