为什么不不谷歌地图查看kml布局? [英] Why not doesn't Google maps view the kml layout?

查看:115
本文介绍了为什么不不谷歌地图查看kml布局?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我执行本教程。我从这里复制了源代码。

 < script src =https://maps.googleapis.com/maps /api/js?v=3.exp&sensor=false\"></script> 
< script>
函数initialize(){
var chicago = new google.maps.LatLng(41.875696,-87.624207);
var mapOptions = {
zoom:11,
center:chicago,
mapTypeId:google.maps.MapTypeId.ROADMAP
}

var map = new google.maps.Map(document.getElementById('map-canvas'),mapOptions);

var ctaLayer = new google.maps.KmlLayer({
url:'https://de-ik-kml.googlecode.com/svn/trunk/cta.kml'
});
ctaLayer.setMap(map);
}

google.maps.event.addDomListener(window,'load',initialize);

< / script>

但是,当我想使用我的网址时,Google地图不会加载或查看。 kml文件。我不明白为什么不这样做。



Chrome的开发者工具不会显示任何错误。所以我无法调试是什么问题。我没有找到。
我尝试将' https '替换为' http ',但这并不是解决方案我的问题。
我只更改了代码中的 url javascript变量的值。

这是我在线的.kml文件

解决方案

来自SVN的文件在标题中的内容类型错误:

  Content-Type:·text / plain 

请参阅 issue and 关于SO的这个问题以获得更多细节。



对于KML, mime-type 需要为 application / vnd.google-earth.kml + xml



这也可能有帮助


设置mime类型的所有应用程序/ vnd.google-earth.kml + xml使用svn
propset svn:mime-type'application / vnd.google-earth.kml + xml'* .kml(感谢
http://manjeetdahiya.com/2010 / 09/29 / serving-html-documentation-from-google-code-
svn /提示)。



I do this tutorial. I copied the source code from here. I use the similar .kml file too!

<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false"></script>
    <script>
        function initialize() {
            var chicago = new google.maps.LatLng(41.875696, -87.624207);
            var mapOptions = {
                zoom: 11,
                center: chicago,
                mapTypeId: google.maps.MapTypeId.ROADMAP
            }

            var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions);

            var ctaLayer = new google.maps.KmlLayer({
                url: 'https://de-ik-kml.googlecode.com/svn/trunk/cta.kml'
            });
            ctaLayer.setMap(map);
        }

        google.maps.event.addDomListener(window, 'load', initialize);

    </script>

But when I would like to use my url, the google maps doesn't load or view the .kml file. I don't understand why don't.

The Developer tool of Chrome doesn't show any errors. So I can't debug what is the problem. I don't find. I tried that I replace the 'https' to 'http', but this isn't solve my problem. I just changed only the url javascript variable's value in my code.

Here is my .kml file online

解决方案

Your file from SVN has the wrong content type in the headers:

Content-Type:·text/plain

See this issue and this question on SO for more details.

The mime-type for KML needs to be application/vnd.google-earth.kml+xml

This may also be helpful

Set the mime type of all to be application/vnd.google-earth.kml+xml using svn propset svn:mime-type 'application/vnd.google-earth.kml+xml' *.kml (thanks to http://manjeetdahiya.com/2010/09/29/serving-html-documentation-from-google-code- svn/ for the tip).

这篇关于为什么不不谷歌地图查看kml布局?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆