谷歌地图窗口中的链接代码显示为html

时间:2018-09-13 13:04:07

标签: javascript html google-maps

我按照google API网站上的说明构建了google地图。

该地图正确显示了引脚,但是信息窗口显示了我为每个标记创建的链接的html,而不是链接。

有人可以告诉我我做错了什么吗?

这是xml中标记的示例:

<marker id="1" name="&amp;lt;a target=&amp;quot;_blank&amp;quot; href=&amp;quot;https://www.google.com/maps/place/123+N+Main+St,+Shelby,+NC+28152/@35.2519982,-81.6692009,17z/data=!3m1!4b1!4m5!3m4!1s0x88571840d0638f6b:0x66ad879686bcd63f!8m2!3d35.2519982!4d-81.6670069&amp;quot;&amp;gt;Click here directions &amp;lt;/a&amp;gt;" address="123 North Main St, Shelby NC 28152" lat="35.2519982" lng="-81.6692009" type="circlek" info="&lt;a target=&quot;_blank&quot; href=&quot;https://www.google.com/maps/place/123+N+Main+St,+Shelby,+NC+28152/@35.2519982,-81.6692009,17z/data=!3m1!4b1!4m5!3m4!1s0x88571840d0638f6b:0x66ad879686bcd63f!8m2!3d35.2519982!4d-81.6670069&quot;&gt;Click here directions &lt;/a&gt;" />

这是我在地图脚本中的代码:

Array.prototype.forEach.call(markers, function(markerElem) {
          var id = markerElem.getAttribute('id');
          var name = markerElem.getAttribute('name');
          var address = markerElem.getAttribute('address');
          var type = markerElem.getAttribute('type');
          var info = markerElem.getAttribute('info');
          var point = new google.maps.LatLng(
              parseFloat(markerElem.getAttribute('lat')),
              parseFloat(markerElem.getAttribute('lng')));

          var infowincontent = document.createElement('div');
          var strong = document.createElement('strong');
          strong.textContent = info
          infowincontent.appendChild(strong);
          infowincontent.appendChild(document.createElement('br'));

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

0 个答案:

没有答案