Link 关于标记 windows 信息

Link on marker windows info

我有一张 google 地图,我想在标记的 windows 信息上添加一个 link。 标记是从 mysql 数据库生成的。

我试图理解我恢复的代码,但我无法在信息 window 中添加 link。

(你不能运行代码)

var infoWindow = new google.maps.InfoWindow;

          // Change this depending on the name of your PHP or XML file
          downloadUrl('xml.php', function(data) {
            var xml = data.responseXML;
            var markers = xml.documentElement.getElementsByTagName('marker');
            Array.prototype.forEach.call(markers, function(markerElem) { //loop
              var id = markerElem.getAttribute('id');                    //stock id variable
              var name = markerElem.getAttribute('name');                //stock name variable
              var address = markerElem.getAttribute('address');           //stock address variable
              var type = markerElem.getAttribute('type');                 //stock type variable
              var point = new google.maps.LatLng(              //Recovered the coordinates for the markers 
                  parseFloat(markerElem.getAttribute('lat')),
                  parseFloat(markerElem.getAttribute('lng')));

              var infowincontent = document.createElement('div');         //Displays name in strong
              var strong = document.createElement('strong');
              strong.textContent = name
              infowincontent.appendChild(strong);

              infowincontent.appendChild(document.createElement('br'));     //Back to the line

              var text = document.createElement('text');            //Displays type
              text.textContent = type
              infowincontent.appendChild(text);

              var text = document.createElement('text');     //Displays id (Irrelevant)
              text.textContent = id
              infowincontent.appendChild(text);

              infowincontent.appendChild(document.createElement('br')); //Back to the line

              var text = document.createElement('text'); //Displays address 
              text.textContent = address
              infowincontent.appendChild(text);
              
              var icon = customLabel[type] || {};  
              var marker = new google.maps.Marker({
                map: map,
                position: point,
                label: icon.label
              });
              marker.addListener('click', function() {
                infoWindow.setContent(infowincontent);
                infoWindow.open(map, marker);
              });
            });
          });
        }

结果照片:

Demonstration

我想要 strong 的文本,它显示名称是 link 到 url "bottle.php?id=" 等值变量 "id" 已经导入

我希望我表达得很好,提前谢谢你

我最终找到了解决方案,这里是 link:

          var a = document.createElement('a');
          a.textContent = "Visit this store"
          a.href = "/bottle.php?id=" + id;
          infowincontent.appendChild(a);