【问题标题】:Google Maps Web API - KML IconStyle color doesn't work [duplicate]Google Maps Web API - KML IconStyle 颜色不起作用[重复]
【发布时间】:2015-09-18 18:02:17
【问题描述】:

我对 KML 和 Google Maps Web API 有疑问。 如果我在 IconStyle 标签中使用颜色标签,则标记不会显示在地图上。 如果我删除颜色标签,它会显示在地图上。 我确信 KML 直到 2-3 个月前都可以正常工作。

这是我的 KML 文件:

<?xml version='1.0' encoding='UTF-8'?>
<kml xmlns='http://www.opengis.net/kml/2.2'>
    <Document>
        <name>MAP</name>
        <description><![CDATA[]]></description>
        <Folder>
            <name>MAP</name>
            <Placemark>
                <styleUrl>#icon-961-62AF44</styleUrl>
                <name>BLA BLA BLA</name>
                <description><![CDATA[DESCRIPTION BLA BLA BLA]]></description>
                <Point>
                    <coordinates>12.429284000000052,41.899191,0.0</coordinates>
                </Point>
            </Placemark>
    </Folder>
    <Style id='icon-961-62AF44'>
        <IconStyle>
            <color>ff44AF62</color>
            <scale>1.1</scale>
            <Icon>
                <href>http://www.gstatic.com/mapspro/images/stock/961-wht-square-blank.png</href>
            </Icon>
        </IconStyle>
    </Style>
    </Document>
</kml>

这是我的javascript:

   <script>
      var map;

      function initialize() {
         var mapOptions = {
           center: new google.maps.LatLng(41.7,12.6),
           zoom: 9
         };
         map = new google.maps.Map(document.getElementById("map"), mapOptions);
         var ctaLayer = new google.maps.KmlLayer('http://test.com/test.kml', {preserveViewport: true});
         ctaLayer.setMap(map);
      }

      google.maps.event.addDomListener(window, 'load', initialize);
   </script>

有什么建议吗? 谢谢。

【问题讨论】:

    标签: javascript api google-maps kml


    【解决方案1】:

    这是 Google Maps Javascript API v3 中的一个问题。

    8551: Bug: KmlLayer-Placemarks with color different to ffFFFFFF will not be displayed

    哪些步骤会重现问题?

    1. 使用 Point 创建一个 KML,并应用一个具有不同于 ffFFFFFF 的颜色值的 IconStyle
    2. 使用 KML 创建 KmlLayer

    根据 KmlLayers 中的文档,IconStyle 根本不支持颜色,应忽略(因此不应以任何方式影响图层)。

    当然可以简单地移除颜色,但是当您使用从其他应用程序导出的 KML 时,这并不总是一种选择。

    尤其是我的地图,当您想在 KmlLayer 中使用导出的 KML 时,无法使用符号(白色符号除外)

    相关的 SO 问题:Google Maps JavaScript API won't display markers from KML exported from My Maps


    感谢您的报告。我们已在内部提交,并将相应地优先处理。

    状态:已接受

    标签:Internal-24115271

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-25
      • 2019-08-25
      • 1970-01-01
      • 1970-01-01
      • 2011-12-20
      • 2013-04-28
      • 2023-03-15
      • 2016-11-17
      相关资源
      最近更新 更多