首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Geoxml3在Google地图上加载KML图层

使用Geoxml3在Google地图上加载KML图层
EN

Stack Overflow用户
提问于 2012-12-29 02:34:29
回答 1查看 10.2K关注 0票数 0

我想使用Geoxml3在googlemap上加载一个can文件,googlemap加载了,但图层没有显示,我不知道我的代码出了什么问题,有人能帮我吗?

代码语言:javascript
复制
<script type="text/javascript">
jQuery(document).ready(function () {        
var myOptions = {
        center: new google.maps.LatLng(39.397, -100.644),
        zoom: 4,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);

    var geoXml = new geoXML3.parser({
        map: map,
        singleInfoWindow: true,
        afterParse: useTheData
    });
    geoXml.parse('KML_Samples.kml');
    });

    function useTheData(doc) {
    // Geodata handling goes here, using JSON properties of the doc object
    for (var i = 0; i < doc[0].markers.length; i++) {
        console.log(doc[0].markers[i].title);
        jQuery('#map_text').append(doc[0].markers[i].title + ', ');
    }
    };
</script>

</head>
<body >
 <form id="form1">

    <div id="map_canvas" style="width:600px;height:500px;"></div>

    <div id="map_text"></div>
    </form>
    </body>
    </html>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-12-29 04:37:56

你的代码,至少和你发布的一样多,对我来说很好。

这是一个working example

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/14074092

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档