【问题标题】:Add info window to placemarks将信息窗口添加到地标
【发布时间】:2013-03-06 16:54:01
【问题描述】:

我正在使用 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);
      }

【问题讨论】:

    标签: javascript parsing google-maps-api-3 infowindow marker


    【解决方案1】:

    geoxml3 在默认的 createXXX 函数中默认为地标创建 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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-06-05
      • 1970-01-01
      • 2017-09-28
      • 2017-11-14
      • 1970-01-01
      • 2014-08-29
      • 1970-01-01
      • 2013-08-22
      相关资源
      最近更新 更多