Google Maps JavaScript API 不会显示从“我的地图"导出的 KML 中的标记 [英] Google Maps JavaScript API won't display markers from KML exported from My Maps

查看:27
本文介绍了Google Maps JavaScript API 不会显示从“我的地图"导出的 KML 中的标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Google 我的地图上有一张地图,我想使用 Google Maps JavaScript API 显示它;这样我就可以轻松地将多个地图组合成一个并创建路径/标记,而无需以编程方式进行.

这是我正在使用的测试地图.这是一张简陋的地图,但我希望路径和标记都显示在我的 JavaScript 中.

https://www.google.com/地图/d/edit?mid=z_Tk3EyXNpN8.k743LUvJRr1U&usp=sharing

这是 JavaScript:http://jsfiddle.net/gB2YD/66/

发生的情况是我绘制的路径显示得很好,但我一生都无法弄清楚如何让标记实际显示.

Google Maps API v3:KML 图层<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"><body onload="display_kmlmap()"><div id="map_canvas" style="width:500px; height:400px; float:left">

...

function display_kmlmap(){//https://www.google.com/maps/d/edit?mid=z_Tk3EyXNpN8.k743LUvJRr1U&usp=sharingvar map_options = { };var map = new google.maps.Map(document.getElementById("map_canvas"),map_options);var kmlUrl = 'https://rawgit.com/Ravenstine/a3b18c71942a812b5b11/raw/dafd404a0410bfbc7c4ef77ef1c6437b313e8cf0/testmap.kml';var kmlOptions = { 地图:地图};//创建 kmlLayer - 你就完成了var kmlLayer = new google.maps.KmlLayer(kmlUrl, kmlOptions);}

奇怪的是,我可以发誓一个月前当我第一次尝试通过概念验证来做到这一点时,标记看起来还不错.

解决方案

似乎有一个错误.

当我从

中删除

Style#icon-503-DB4436-nodesc-normal>IconStyle 我看到了标记.

根据文档 根本不支持 并且将被忽略,所以它不应该影响渲染.

相关:问题跟踪器中的问题 8551

I have a map on Google My Maps that I want to display using the Google Maps JavaScript API; this is so that I can easily combine multiple maps into one and create paths/markers without having to do it programmatically.

Here is the test map that I'm using. It's a cruddy map but I expect both the path and the marker to show up in my JavaScript.

https://www.google.com/maps/d/edit?mid=z_Tk3EyXNpN8.k743LUvJRr1U&usp=sharing

And here's the JavaScript: http://jsfiddle.net/gB2YD/66/

What happens is the path I drew displays just fine, but I can't for the life of me figure out how to get the marker(s) to actually display.

<title>Google Maps API v3 : KML Layer</title>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">
</script>

<body onload="display_kmlmap()">

<div id="map_canvas" style="width:500px; height:400px; float:left">
</div>
</body>

...

function display_kmlmap()
{
    // https://www.google.com/maps/d/edit?mid=z_Tk3EyXNpN8.k743LUvJRr1U&usp=sharing
    var map_options = { };  
    var map = new google.maps.Map(document.getElementById("map_canvas"),map_options);

    var kmlUrl = 'https://rawgit.com/Ravenstine/a3b18c71942a812b5b11/raw/dafd404a0410bfbc7c4ef77ef1c6437b313e8cf0/testmap.kml';
   var kmlOptions = { map: map};

    // Create the kmlLayer - and you are done
    var kmlLayer = new google.maps.KmlLayer(kmlUrl, kmlOptions);
}

What's strange is I could swear that the markers were appearing just fine a month ago when I first attempted to do this with a proof of concept.

解决方案

There seems to be a bug.

When I remove the <color/> from

Style#icon-503-DB4436-nodesc-normal>IconStyle I see the marker.

According to the documentation <color/> isn't supported at all for <IconStyle/> and will be ignored, so it shouldn't affect the rendering.

Related: Issue 8551 in the issue tracker

这篇关于Google Maps JavaScript API 不会显示从“我的地图"导出的 KML 中的标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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