首页 > 解决方案 > How to use
in google map label's text:

问题描述

How can I use br in google map label's text. I tried to use like below. But not worked out. Any specific way to use this? ??

var marker = new google.maps.Marker({
    map: this.map,
    icon: 'img/background.png',
    label: {
        text: "name: " + String(account.name) + "\ncity :" + String(account.city),
        color: "#fff",
    },
    position: {
        lat: parseFloat(account.lat),
        lng: parseFloat(account.lng)
    }
});

标签: javascriptgoogle-maps

解决方案


\n像这样使用

var marker = new google.maps.Marker({
   position: myLatLng,
   map: map,
   title: 'Hello\nWorld!'
});

您可以在此处阅读有关 Google 地图标记的更多信息 简单标记


推荐阅读