kml - “只允许一个单一的根特征标记“KML 代码错误
问题描述
我有一个有效的 KML 代码,在财产边界上显示 GPS 测量员标记,名义上与城镇线重合。现在我想做一些更高级的事情:
将整个地球视图居中于所讨论的地方。
绘制城镇线段(一条连接两个相距约 10 公里的角的直线(我必须将其更改为连接相距 200 米的点的线,以防止该线在放大时在丘陵地形中消失),自动放大到一个框架代表围绕 10 公里线高约 12 公里,视点高程为 20 公里。
暂停几秒钟。
标记 GPS 的测量标记(使用标准图标)并进一步放大到城镇线的较短部分,框住我的 GPS 标记(LookAt,3700 米范围)
从这个角度来看,让我的用户手动导航、放大单个标记图标、单击它们进行描述等等。
当我尝试重新组织我的代码以添加这些阶段时,我收到一条消息:“失败:标签中只允许一个根功能”。
我做错了什么,我应该如何编码?
代码概要:
<?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">
<name>MHT-State boundary issues</name>
<!-- icons for historic stone corner monuments -->
<Style id="P.Star">
<IconStyle>
<Icon>
<href>
http://maps.google.com/mapfiles/kml/paddle/purple-stars-lv.png
</href>
<scale>0.25</scale>
</Icon>
</IconStyle>
</Style>
<!-- define blue(boundary) line between corners -->
<Style id="BlueLine">
<LineStyle>
<color>ffff0072</color>
<width>1</width>
</LineStyle>
</Style>
<!-- locate corners -->
<Placemark>
<name>B-H-R corner</name>
<styleUrl>#P.Star</styleUrl>
<description>Blandford-Hungtington-Russell corner, coordinates per MassDOT</description>
<Point><coordinates>-72.872182,42.216453</coordinates></Point>
</Placemark>
<Placemark>
<name>B-G-R corner</name>
<styleUrl>#P.Star</styleUrl>
<description>Blandford-Granville-Russell corner, coordinates per MassDOT</description>
<Point><coordinates>-72.895662,42.123925</coordinates></Point>
</Placemark>
<!-- draw town line between them -->
<Placemark>
<name>Blandford-Russell boundary</name>
<styleUrl>#BlueLine</styleUrl>
<LineString>
<tessellate>1</tessellate>
<altitudeMode>clampToGround</altitudeMode>
<coordinates>
-72.895662,42.123925,0
-72.895622,42.124,0
... (more intermediate coordinates in straight line)
-72.872182,42.216453,0
</coordinates>
</LineString>
</Placemark>
<!-- set wide viewpoint to see boundary from Granville to Huntington corners -->
<LookAt>
<longitude>-72.884</longitude>
<latitude>42.171</latitude>
<range>20000</range>
</LookAt>
<!-- pause 5 seconds -->
<gx:Wait>
<gx:duration>5</gx:duration>
</gx:Wait>
<!-- add legend -->
<ScreenOverlay>
<name>Boundary Legend</name>
<overlayXY x="0" y="0" xunits="fraction" yunits="fraction"/>
<screenXY x="0" y="0.1" xunits="fraction" yunits="fraction"/>
<rotationXY x="0" y="0" xunits="fraction" yunits="fraction"/>
<size x="0" y="0" xunits="fraction" yunits="fraction"/>
<Icon><href>files\BndyLegend.png</href></Icon>
</ScreenOverlay>
<!-- define yellow line for first Hull/DFW boundary segment -->
<Style id="YellowLine">
<LineStyle>
<color>FF14F0FF</color>
<width>1</width>
</LineStyle>
</Style>
<!-- icon styles
purple (P.) - before 1950
red (R.) - 1950-1999
green (G.) - 2000-2013
yellow (Y.) - 2014 on
white (W.) - uncertain
star (.Star) - end monument
diamond (.Dmnd) - waypoint stone/concrete monument
circle (.Cir) - pipe set in ground, stones or concrete
square (.Sq) - blaze
blank (.blnk) - blank
-->
<!-- icons for historic waypoint stone monuments -->
<Style id="P.Dmnd">
<IconStyle>
<Icon>
<href>
http://maps.google.com/mapfiles/kml/paddle/purple-diamond-lv.png
</href>
<scale>0.25</scale>
</Icon>
</IconStyle>
</Style>
... (more styles)
<!-- pre-GPS town line marker, Route 23, #2 -->
<Placemark>
<name>2</name>
<styleUrl>#P.Dmnd</styleUrl>
<description>old town line monument by state route 23, by Garmin eTrex</description>
<Point><coordinates>-72.88422,42.17023</coordinates></Point>
</Placemark>
... (more point placemarks)
<!-- set viewpoint directly over #7, from 3700 meters up -->
<LookAt>
<longitude>-72.879562</longitude>
<latitude>42.1872075</latitude>
<range>3700</range>
</LookAt>
</Document>
</kml>
怎么了:
地球的初始视图,没有旋转或缩放出现,然后这个窗口弹出:
“打开文件“C:\Users\DTM\Documents\MHT\abutting state parcel\boundary KML\Boundary GPS.kml”失败:标签内只允许一个根特征”
解决方案
您缺少<Document>
文件顶部附近的标签。您已经有</Document>
接近结尾的结束标签,但似乎缺少开始标签,它应该位于<kml...>
标签和第一个<name>
标签之间。所以你的文件应该有这样的结构:
<?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">
<Document>
<name>MHT-State boundary issues</name>
...
</Document>
</kml>
<kml>...</kml>
对于背景,每个 KML 必须在标签内仅包含一个顶级元素。这可以是一个功能(如地标等),也可以是一个“容器”:文档或文件夹。因此,如果您的 KML 将包含多个功能(或样式等),那么您需要将所有内容包装在至少一层文档或文件夹中。
推荐阅读
- xaml - Stacklayout里面的Stackedlayout绑定IsVisible
- apache-spark - 无法正确按日期排序
- android - 使用 Futures 的 Volley 请求超时
- php - 如何让 Wordpress 后置过滤器(misha_filter_function)过滤标签关联的 CPT 类别
- mysql - 获取给定组的每种产品的最低价格
- delete-file - 如何知道文件来自android的内部或外部存储?
- python - 如何替换python中的所有字符串元素?
- c# - 错误:“参数无效”,将字节 [] 转换为图像时
- angular - 如何在浮动菜单上编辑隐藏列 - Aggrid
- mysql - 关于case函数的问题是mysql: split value from one field to two