如何使用geoXML3从外部url获取KML?
是否有可能以某种方式从同一域的源获取 KML。我的意思是要以某种方式避免“Javascript 的同源策略”? (在我们的服务器上缓存并非如此,因为应用程序旨在与外部源一起工作)
下面的代码是我们试图完成的事情(如果是外部kml源,它会给出错误) 。
<script type="text/javascript">
var myParser = new geoXML3.parser({afterParse: useTheData});
myParser.parse('http://api.flickr.com/services/feeds/geo/?g=94823070@N00&lang=en-us&format=kml');
function useTheData(doc) {
// out callback
};
</script>
为什么要问有没有这个政策呢?自 google.maps.KmlLayer 制作这种 工作。不知道如何,或者我错过了一些东西。确实需要 geoxml3 来了解幕后的内容!
Is it possible somehow to get the KML from the source out of the same domain. I mean to avoid the "Same origin policy for Javascript" somehow? (caching on our server is not the case since the application is intended to work with external sources)
The code below is what we're trying to accomplish (it give the error in case of external kml source).
<script type="text/javascript">
var myParser = new geoXML3.parser({afterParse: useTheData});
myParser.parse('http://api.flickr.com/services/feeds/geo/?g=94823070@N00&lang=en-us&format=kml');
function useTheData(doc) {
// out callback
};
</script>
What is the reason to ask if there is that policy? Since google.maps.KmlLayer make this kind of job. Don't know how or I miss something. Really need it with geoxml3 and to understand what is under the curtain!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您正在访问公开可用的 KML,您只需将其加载为标准 google 叠加层即可。
否则,如果您确实需要使用 geoxml,则需要代理 kml 文件(使用将为您加载文件的服务器端脚本)。
If you are accessing a publicly available KML you can simply load it as a standard google overlay
Otherwise if you really need to use geoxml you will need to proxy the kml file (use a server side script that will load the file for you).