kml不显示 [英] kml is not displayed

查看:118
本文介绍了kml不显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用google API编写应用程序,该应用程序从我的本地服务器加载kml文件。
但文件未显示,地图移动到未指定的位置。
要测试这个,我只是尝试google API参考中的kml示例:

 <!DOCTYPE html> ; 
< html>
< head>
< meta name =viewportcontent =initial-scale = 1.0,user-scalable = no>
< meta charset =utf-8>

< title> Google Maps JavaScript API v3示例:KmlLayer KML< / title>
< link href =http://code.google.com/apis/maps/documentation/javascript/examples/default.css =stylesheettype =text / css/>
< script src =http://maps.googleapis.com/maps/api/js?key=AIzaSyAWcYJaMe2mN1u2NYz4ztmffINxGcEpB64&sensor=false&language=he>< / 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('http://gmaps-samples.googlecode.com/svn/trunk/ggeoxml/cta.kml');
var ctaLayer = new google.maps.KmlLayer('http://www.pgl.co.il/maps/testlyr/cta.kml');
ctaLayer.setMap(map);
}

< / script>
< / head>
< body onload =initialize()>
< div id =map_canvas>< / div>
< / body>
< / html>

当文件位于Google服务器时,它可以正常工作,但当文件位于我的服务器中时(windows,iis 5.1)HTML运行但地图不显示kml文件。
我在iis的标题部分定义了MIME类型。



有什么不对?
感谢您的帮助!

解决方案

Google服务器无法访问该文件。



如果我将代码中的网址放入Google地图,它会显示:

http://www.pgl.co.il/maps/t ....


建议:




  • 确保网址拼写正确。 li>
  • 确保文件存在。 href =http://www.feedvalidator.org/check.cgi?url=http%3A%2F%2Fwww.pgl.co.il%2Fmaps%2Ftestlyr%2Fcta.kml =nofollow> http:/ /www.feedvalidator.org :


    服务器返回超时[help]



    对不起

    尝试验证此Feed时发生错误。



    可能的原因:


    1. 地址可能不正确。确保地址拼写正确。请尝试直接在您的浏览器中加载Feed,以确保该地址存在Feed。 该Feed可能暂时不可用。服务器可能已关闭,或速度太慢。稍后再试。

    2. 验证器可能被破坏。如果Feed存在,服务器没问题,问题可以重现,请在feedvalidator-users邮件列表上告诉我们。


    您确定:


    1. 您的服务器配置为服务kml文件
    2. 该文件位于正确的位置


    I'm writing an application with the google API that loads a kml file from my local server. But the file is not displayed and the map "moves" to an unspecified location. To test this i'm just trying the kml example from the google API reference:

    <!DOCTYPE html>
    <html>
    <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    
    <title>Google Maps JavaScript API v3 Example: KmlLayer KML</title>
    <link href="http://code.google.com/apis/maps/documentation/javascript/examples/default.css" rel="stylesheet" type="text/css" />
    <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyAWcYJaMe2mN1u2NYz4ztmffINxGcEpB64&sensor=false&language=he"></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('http://gmaps-samples.googlecode.com/svn/trunk/ggeoxml/cta.kml');
        var ctaLayer = new google.maps.KmlLayer('http://www.pgl.co.il/maps/testlyr/cta.kml');
        ctaLayer.setMap(map);
    }
    
    </script>
    </head>
    <body onload="initialize()">
    <div id="map_canvas"></div>
    </body>
    </html>
    

    when the file is located in the Google server it works fine, but when the file is in my server (windows, iis 5.1) the html runs but the map does not display the kml file. I've defined the mime type in the header section of the iis.

    What's wrong? thanks for your help!

    解决方案

    The file can't be accessed by Google's servers.

    If I put the URL in your code into Google Maps, it says:

    File not found at http://www.pgl.co.il/maps/t....

    Suggestions:

    • Make sure the URL is spelled correctly.
    • Make sure the file exists.

    As does http://www.feedvalidator.org:

    Server returned timed out [help]

    Sorry

    An error occurred while trying to validate this feed.

    Possible causes:

    1. The address may be incorrect. Make sure the address is spelled correctly. Try loading the feed directly in your browser to make sure a feed exists at that address.
    2. The feed may be temporarily unavailable. The server may be down, or too slow. Try again later.
    3. The validator may be busted. If the feed exists, the server is fine, and the problem is reproducible, let us know on the feedvalidator-users mailing list.

    Are you sure that:

    1. Your server is configured to serve kml files
    2. The file is in the right place

    这篇关于kml不显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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