2017-06-13 55 views
-1

我有一个基于MySQL表标记的地图与我的脚本。 该职位在表格中。 现在,我想在InfoWindow中使用HTML编写代码,因为它不会在Map上的InfoWindow中显示HTML。谷歌地图与HTML InfoWindow的MySQL地图

downloadUrl('inc/map_bridge.php', function(data) { 
     var xml = data.responseXML; 
     var markers = xml.documentElement.getElementsByTagName('marker'); 
     Array.prototype.forEach.call(markers, function(markerElem) { 
      var name = markerElem.getAttribute('name'); 
      var ide = markerElem.getAttribute('id'); 
      var desc = markerElem.getAttribute('beschreibung'); 
      var type = markerElem.getAttribute('art'); 
      var link = '<p>Klicke für weitere infos: <a href="http://link.de">Hier</a>'; 
      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 = 'ID' + ide + ': ' + name 
      infowincontent.appendChild(strong); 
      infowincontent.appendChild(document.createElement('br')); 

      var text = document.createElement('text'); 
      text.textContent = desc + link 
      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); 
      }); 
     }); 
     }); 
    } 

它仅示出这样: 示出示例图像

[1]

下面我有在MySQL-表

first line<br>second line 

回答

0

如果 'beschreibung' 是SELECT的结果SQL,原因是转义SELECT SQL结果。

(我名声不好,所以请写回答表格。)