infowindws上的自定义按钮(如模态Bootstrap按钮)

时间:2015-09-27 19:58:00

标签: javascript bootstrap-modal infowindow

我在信息窗口中有一个应用程序,出现一个打开模态视图的“更多信息”按钮。代码是:

(function(marker, data) {// Attaching a click event to the current marker
     google.maps.event.addListener(marker, "click", function() {
         geocoder.geocode({'latLng': marker.position}, function(results, status) {
           if(status == google.maps.GeocoderStatus.OK) {
              if (results[0]) { //defino la direccion
                 address = results[0].formatted_address;
                 info = '<h4>' + marker.title + '</h4><h4>'+ address+'</h4>';
                 var content = document.createElement('div'),button;
                 content.innerHTML = info + '<br/>';
                 button = content.appendChild(document.createElement('input'));
                 button.type = 'button';
                 button.value = 'More info';
                     google.maps.event.addDomListener(button, 'click', function () {
                        offsetCenter(marker,data);
                      })
                  infoWindow.setContent(content);

我的问题是按钮的样式。如何添加类似模态引导按钮的样式按钮(即btn-primary class按钮)?

1 个答案:

答案 0 :(得分:1)

我使用setAttribute属性找到了简单的解决方案。 只是使用:

 button.setAttribute('class', 'btn btn-info');

我在infowindows上获得了bootsrap按钮。你可以为另一个班级改变btn-info。

希望它有所帮助。