InfoWindow在谷歌地图中使用Html

use*_*656 4 javascript google-maps google-maps-api-3

我使用以下代码为地图中的标记创建信息窗口.在消息变量中,我发送一个带有Html的字符串.当我在信息框内运行我的应用程序时,我得到的字符串没有Html样式.例如,在盒子里面,我看到等等等等......有谁知道如何在内部使用html样式获取信息框?

 function attachSecretMessage(marker, number) {

         var infowindow  = new google.maps.InfoWindow(
      { content: message[number],
          size: new google.maps.Size(50, 50)
      });
            google.maps.event.addListener(marker, 'click', function() {
                infowindow.open(map1, marker);
      });
Run Code Online (Sandbox Code Playgroud)

tho*_*buj 10

将所有自定义html代码放在变量中,并将值赋给"内容"!

    var contentString = 
                '<div id="content" style="width:400px; background-color:red;">' +
                'My Text comes here' + 
                '</div>';

   var infowindow = new google.maps.InfoWindow({
            content: contentString,
            maxWidth: 400
        });
Run Code Online (Sandbox Code Playgroud)