我正在尝试运行此示例:Openlayers 中的 KML 层在本地本地主机上不起作用。我做了一些研究,发现这个人也有类似的问题。但是他提到,如果文件在本地链接,则会发生此问题。因此,我假设如果它们没有在本地链接,我应该没问题。我曾尝试直接从 openlayers 网站的示例中使用 javascript 文件:http://openlayers.org/dev/examples/kml-layer.html ,但它不起作用。
问题是我可以看到底图,但 kml 文件不会显示在地图上。
我在 jsfiddle 上放了一个例子:http: //jsfiddle.net/Hn5pG/
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="stylesheet" href="http://openlayers.org/dev/theme/default/style.csss" type="text/css">
<link rel="stylesheet" href="http://openlayers.org/dev/examples/style.css" type="text/css">
</head>
<body>
<h1 id="title">KML Layer Example</h1>
<div id="tags">KML</div>
<p id="shortdesc">
Demonstrates loading and displaying a KML file on top of a basemap.
</p>
<div id="map" class="smallmap"></div>
<div id="docs">
<p>
A vector layer can be populated with features from a KML document
by configuring the layer with an HTTP protocol that points to the
KML document and is configured with a KML format for parsing features.
The fixed strategy is used to load all features at once.
</p>
<p>
View the <a href="kml-layer.js" target="_blank">kml-layer.js</a>
source to see how this is done.
</p>
</div>
<script src="http://openlayers.org/dev/OpenLayers.js"></script>
<script src="http://openlayers.org/dev/examples/kml-layer.js"></script>
</body>
</html>
我误解了什么吗?我只能在工作中访问 Firefox 和 Internet Explorer,并且如果可能的话,我需要能够在不托管它的情况下对其进行测试。
谢谢