如何在JS中的Google地图上的标记上方添加文本?

Kar*_*lak 1 javascript google-maps google-maps-api-3 google-maps-markers

我为Java 找到了完全相同的问题,但我想在JS中做到这一点。那么,如何在JS中的Google地图上的标记上方添加文本?

G.H*_*unt 5

如我的评论所述,您可以在地图标记标签上使用多个字母。

如果您label在实例化一个new google.maps.Marker类时使用该属性,则向其传递一个对象,其中包含properties之一text

var marker = new google.maps.Marker({
    position: new google.maps.LatLng(0, 0),
    icon: 'https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png',
    label: { color: '#00aaff', fontWeight: 'bold', fontSize: '14px', text: 'Your text here' }
});
Run Code Online (Sandbox Code Playgroud)

这里检查小提琴。