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

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

问题描述

我在Google我的地图上使用Google Maps JavaScript API显示地图,这是为了让我可以轻松地将多个地图组合成一个,并创建路径/标记,而无需以编程方式进行。



以下是我正在使用的测试地图。这是一个糟糕的地图,但我希望路径和标记都显示在我的JavaScript中。



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



以下是JavaScript:
http ://jsfiddle.net/gB2YD/66/



发生的事情是我绘制的路径显示得很好,但是我不能我想出了如何让标记实际显示。

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

< body onload =display_kmlmap()>

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

...

 函数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};

//创建kmlLayer - 并完成
var kmlLayer = new google.maps.KmlLayer(kmlUrl,kmlOptions);
}

奇怪的是我可以发誓,标记在一个月前显得很好当我第一次尝试用概念证明来做这件事。

解决方案

好像有一个bug。 b
$ b



删除< color /> code>样式#图标-503-DB4436-nodesc-normal>图标样式我看到了标记。根据文档< color /> 根本不支持< 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天全站免登陆