我需要使用 OpenLayers 查看 KMZ 文件。
我正在使用的 KMZ 位于 https://github.com/eric-g-97477-so/wash_kmz/blob/main/wash.kmz
KMZ(zip)文件的结构是:
wash/
files/
wash-dc.png
wash-dc.kml
wash-dc.png 是:
kml文件的内容是:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Folder>
<GroundOverlay>
<Icon>
<href>files/wash-dc.png</href>
</Icon>
<LatLonBox>
<north>38.9098629826801456</north>
<south>38.8880073821501711</south>
<east>-77.0497762322933539</east>
<west>-77.0120905091252439</west>
<rotation>0</rotation>
</LatLonBox>
</GroundOverlay>
</Folder>
</kml>
如果我双击 kmz 文件,我在本地计算机上安装的 Google 地球应用程序将启动并成功显示 KMZ:
我在 https://openlayers.org/en/latest/examples/drag-and-drop-custom-kmz.html
找到了 OpenLayers 示例但是,当我尝试将 KMZ 文件拖放到其上时,它不起作用。控制台中没有错误。 DC的景色是:
需要如何更改此示例代码才能查看我的 KMZ? (或者,我的KMZ有问题吗?)
目前,OpenLayers 中的 KML 解析器不支持 GroundOverlays。
参见(旧的,但仍然相关):