为placemark添加信息窗口

Add info window to placemarks

本文关键字:信息窗 窗口 信息 添加 placemark      更新时间:2023-09-26

我使用geoxml3来解析kml文件。我的问题是我如何能够从kml文件中提取描述为每个位置标记,并将其放在一个信息窗口?

到目前为止,我的代码如下:
function displayKml() {
        initialize();
        parser = new geoXML3.parser({
            map: map,
            processStyles: true,
            createMarker: addMyMarker,
            createOverlay: addMyOverlay
        });          
        parser.parse("Uploads/" + document.getElementById('<%= text2.ClientID %>').value); 
    }
     function addMyMarker(placemark) {
        // Marker handling code goes here
         parser.createMarker(placemark);
      }
      function addMyOverlay(groundOverlay) {
        // Overlay handling code goes here
        parser.createOverlay(groundOverlay);
      }

geoxml3在默认的createXXX函数中默认为placemark创建InfoWindows。如果你要重写它们,你就必须在你的版本中创建InfoWindows。我通常首先复制默认函数中的代码,然后对其进行适当的修改。看起来你正在使用默认功能,所以我不确定你看到的是什么行为,为什么你这样做。GroundOverlays没有InfoWindows,到目前为止你发布的示例KML文件都没有包含"名称"或"描述"标签(但它们确实为我打开了InfoWindows)。

http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_linktoB.html?filename=http://www.geocodezip.com/geoxml3_test/SO_IT_info_kmlB.xml

http://www.geocodezip.com/geoxml3_test/v3_geoxml3_kmltest_linktoB.html?filename=http://www.geocodezip.com/geoxml3_test/SO_emptyKMLa.xml