2

从 GEarth 与 Google 地图中调试 KML 花费了太多时间。有人可以给我一个提示,说明为什么下面的“实体替换”在 GE 中可以正常工作,但在 GMaps 中却失败了。

我运行了 XMLValidate 并且文件很好,但是 [CDATA] 中的标签不会被 GoogleMaps API 替换,只有在 GEarth 中。我阅读了有关BalloonStyle 实体替换的最佳实践 KML 文档,以及OGC KML 2.2 标准中令人麻木的描述,并调整和修剪了文件,但我仍然感到困惑。在以下情况下,我无法让实体替换在 GMaps API 中工作。

有任何想法吗?-谢谢

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
    <Document>
        <name>ParcelsJoinedx.kml</name>
        <Style id="outline">
            <PolyStyle>
                <color>00ff0000</color>
                <fill>1</fill>
                <outline>1</outline>
            </PolyStyle>
            <BalloonStyle>
                <bgColor>ffffffff</bgColor>
                <text>
                <![CDATA[
                    <head>
                    <title></title>
                    <STYLE TYPE="text/css">
                    <!-- TD{font-family: Arial; font-size: 9pt;} --->
                    </STYLE>
                    </head>
                    <body>
                      <table >
                      <tr><td valign='top'><font color="#aa0000">$[ParcelJoined/Location/displayName]:</font></td><td>$[ParcelJoined/Location]</td>
                      <tr><td><font color="#aa0000">$[ParcelJoined/ParcelID/displayName]:</font></td><td>$[ParcelJoined/ParcelID]</td>
                     </tr></table>
                     </body>
                     ]]>
                 </text>
            </BalloonStyle>
        </Style>
        <Schema name="ParcelJoined" id="ParcelJoinedID">
            <SimpleField type="string" name="Name"></SimpleField>
            <SimpleField type="string" name="Description"></SimpleField>
            <SimpleField type="string" name="Location">
                <displayName><![CDATA[<b>Location</b>]]></displayName>
            </SimpleField>
            <SimpleField type="string" name="ParcelID">
                <displayName><![CDATA[<b>ParcelID</b>]]></displayName>
            </SimpleField>
            <SimpleField type="string" name="Zone"></SimpleField>
            <SimpleField type="string" name="AssessArea"></SimpleField>
            <SimpleField type="string" name="Owner"></SimpleField>
            <SimpleField type="string" name="CoOwner"></SimpleField>
            <SimpleField type="string" name="Address1"></SimpleField>
            <SimpleField type="string" name="Address2"></SimpleField>
            <SimpleField type="string" name="City"></SimpleField>
            <SimpleField type="string" name="State"></SimpleField>
            <SimpleField type="string" name="ZIP"></SimpleField>
            <SimpleField type="string" name="AcctNum"></SimpleField>
            <SimpleField type="string" name="YearBuilt"></SimpleField>
            <SimpleField type="string" name="LandValue"></SimpleField>
            <SimpleField type="string" name="BldgValue"></SimpleField>
            <SimpleField type="string" name="OtherValue"></SimpleField>
            <SimpleField type="string" name="TotalValue"></SimpleField>
            <SimpleField type="string" name="MainBldgDesc"></SimpleField>
            <SimpleField type="string" name="StateCode"></SimpleField>
            <SimpleField type="string" name="SaleDate"></SimpleField>
            <SimpleField type="string" name="Rooms"></SimpleField>
            <SimpleField type="string" name="Beds"></SimpleField>
            <SimpleField type="string" name="Baths"></SimpleField>
        </Schema>
        <Folder>
            <name>ParcelJoinedFldr</name>
            <Placemark>
                <styleUrl>#outline</styleUrl>
                <ExtendedData>
                    <SchemaData schemaUrl="#ParcelJoinedID">
                        <SimpleData name="Location">68 WALCOTT AVE</SimpleData>
                        <SimpleData name="ParcelID">9-459</SimpleData>
                        <SimpleData name="Zone">R40$39</SimpleData>
                        <SimpleData name="AssessArea">3.72 AC</SimpleData>
                        <SimpleData name="Owner">CXXX, CXX R ET</SimpleData>
                        <SimpleData name="CoOwner">CXXX, GLXXA G</SimpleData>
                        <SimpleData name="Address1">32 EAST 88TH STREET</SimpleData>
                        <SimpleData name="Address2"></SimpleData>
                        <SimpleData name="City">NEW YORK</SimpleData>
                        <SimpleData name="State">NY</SimpleData>
                        <SimpleData name="ZIP">10021</SimpleData>
                        <SimpleData name="AcctNum">2421</SimpleData>
                        <SimpleData name="YearBuilt">1910</SimpleData>
                        <SimpleData name="LandValue">2036060</SimpleData>
                        <SimpleData name="BldgValue">479800</SimpleData>
                        <SimpleData name="OtherValue">1500</SimpleData>
                        <SimpleData name="TotalValue">2517360</SimpleData>
                        <SimpleData name="MainBldgDesc">CONVNTL</SimpleData>
                        <SimpleData name="StateCode">1100 - SEASONAL &amp; BEACH</SimpleData>
                        <SimpleData name="SaleDate">04/07/1995</SimpleData>
                        <SimpleData name="Rooms">0</SimpleData>
                        <SimpleData name="Beds">0</SimpleData>
                        <SimpleData name="Baths">4 Full / 0 H</SimpleData>
                    </SchemaData>
                </ExtendedData>
                <Polygon>
                    <outerBoundaryIs>
                        <LinearRing>
                            <coordinates>-71.363000752291924,41.489279023867283 -71.364928267362686,41.489246551445632 -71.364928271377551,41.48924655145035 -71.366127398895557,41.489226333780891 -71.366980322431843,41.489211945621989 -71.366980559667908,41.489218729506135 -71.366992415755973,41.489658359975031 -71.363335128398276,41.489691230204564 -71.36332242991972,41.489681182960041 -71.36320151947757,41.489583338563875 -71.363080572769988,41.489488329510586 -71.363012929798629,41.48940065703426 -71.363000855378388,41.489285011997865 -71.363000752291924,41.489279023867283</coordinates>
                        </LinearRing>
                    </outerBoundaryIs>
                </Polygon>
            </Placemark>
        </Folder>
    </Document>
</kml>
4

2 回答 2

1

我认为如果你使用简单的<ExtendedData><Data>元素来提供数据,它可能会起作用,以及或而不是<Schema><SchemaData>元素。

看它,你甚至需要模式数据吗?您是否在需要将数据作为类型字符串的其他应用程序中使用 KML?

谷歌地球和谷歌地图忽略了类型数据,所以如果它对你没有其他用途,它只会让你的 kml 膨胀。

您链接到的文档的前半部分涉及此问题。

于 2012-12-05T21:49:50.803 回答
1

回答你关于为什么这在谷歌地图中不起作用的问题:谷歌地图 API 正式不支持<Schema>两者。完全支持和部分支持(参考)。<SchemaData><Data><ExtendedData>

该参考提供了一个表格,详细说明了 API 支持的 KML 功能。以下是相关行:

+----------------+-----------------------+----------------------------+
|  KML element   | Supported in the API? |         Comment            |
+----------------+-----------------------+----------------------------+
| <BalloonStyle> | partially             | only <text> is supported   |
| <Data>         | yes                   |                            |
| <ExtendedData> | partially             | untyped <Data> only, no    |
|                |                       | <SimpleData> or <Schema>,  |
|                |                       | and entity replacements of |
|                |                       | the form $[dataName] are   |
|                |                       | not supported.             |
| <Schema>       | no                    |                            |
| <SchemaData>   | no                    |                            |
+----------------+-----------------------+----------------------------+

如果链接断开,请参阅 Google Maps JavaScript API 开发人员文档中“KML 和 GeoRSS”指南的“支持的 KML 元素”部分。

于 2016-03-22T23:21:19.260 回答