我从谷歌地球获取我的KML文件,地址是http://myaddress.com:8080
在KML文件中,我为每个图标定义了几种样式的HREF。在这个HREF中,我有图标的名称,我希望Google Earth将隐式地从相同的服务器地址获取该文件,即在示例中的http://myaddress.com:8080/aircraft.png,除非指定了另一个地址。
这似乎不起作用。我认为它被解释为本地文件。
我现在不得不告诉我的KML服务器它在哪个地址上发布自己的广告,并使用该地址为它生成的每个KML文件中的每个图标创建一个绝对HREF。
如何防止将KML中的服务器地址用于HREF-ed图标?
示例KML文件:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:xal="urn:oasis:names:tc:ciq:xsdschema:xAL:2.0">
<Document>
<name>GE View</name>
<open>1</open>
<Style id="style8">
<IconStyle>
<scale>1.0</scale>
<heading>0.0</heading>
<Icon>
<href>aircraft.png</href>
<refreshInterval>0.0</refreshInterval>
<viewRefreshTime>0.0</viewRefreshTime>
<viewBoundScale>0.0</viewBoundScale>
</Icon>
</IconStyle>
</Style>
<Folder>
<name>Entities</name>
<open>1</open>
<Placemark>
<name>HLAobjectRoot.BaseEntity.PhysicalEntity.Platform.Aircraft101</name>
<visibility>1</visibility>
<open>0</open>
<description>HLAobjectRoot.BaseEntity.PhysicalEntity.Platform.Aircraft101: EntityType=1.2.0.-103.57.0.0</description>
<styleUrl>style8</styleUrl>
<Point>
<extrude>1</extrude>
<altitudeMode>relativeToGround</altitudeMode>
<coordinates>-18.00000000000001,53.999999999219824,1000.0000635553151</coordinates>
</Point>
</Placemark>
</Folder>
</Document>
</kml>
发布于 2016-04-15 21:56:06
KML可以处理对文件的相对引用,但如果从web浏览器从web服务器访问,则KML文件将保存到临时/下载文件夹中,并由Google Earth本地访问。此时,指向web服务器上文件的相对链接将丢失。这是一个web浏览器和Google Earth作为KML文件的外部处理程序的交互问题。但是,如果KML是从本地文件(例如file:// URL)在Google Earth中打开的,则本地相对引用将按预期工作。
如果在KMZ文件中包含图标和图像,则可以在KML中使用相对URL引用这些URL。
以下是带有图标或图像的KMZ文件的结构:
+doc.kml
+aircraft.png
具有相对引用的KML:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2">
<Document>
<name>GE View</name>
<open>1</open>
<Style id="style8">
<IconStyle>
<Icon>
<href>aircraft.png</href>
</Icon>
</IconStyle>
</Style>
...
这是一个KMZ文件的example,其中嵌入了一个地面覆盖图像,引用为相对URL。
关于KMZ中的URLS的一些其他详细信息可以在here中找到。
https://stackoverflow.com/questions/36635815
复制相似问题