您在正确的轨道上为您的图钉指定 typeName 属性。您可能已经知道,指定 typeNamepushpinStyle
将导致创建的 Pushpin 具有pushpinStyle
. 如果您在地图上检查您的 Pushpin 生成的 html,您将看到 Pushpin 文本由<div>
Pushpin 内的绝对定位子项实现<div>
。因此,合乎逻辑的做法是使用 css 进一步设置 Pushpin 文本的样式<div>
。例如,您可以执行以下操作:
.pushpinStyle div{
color: black !important; /*Make Pushpin text black*/
left: 5px !important; /*Since Pushpin text is absolutely positioned, this will cause the text to be 5 pixels from the left instead of 0 pixels */
text-shadow: 1px 0px white, -1px 0px white, 0px -1px white, 0px 1px white; /*Give the text all around white text shadow so it looks nice on browsers that support it*/
font: 12px arial,sans-serif; !important // override default fonts
}
这将导致图钉文本<div>
具有上述样式。当然,您可以添加自己的样式以适合您的应用程序。