Google Maps JavaScript API won't display markers from KML exported from My Maps

徘徊边缘 提交于 2019-11-26 10:00:27

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/32323674/google-maps-javascript-api-wont-display-markers-from-kml-exported-from-my-maps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!