Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
320 views
in Technique[技术] by (71.8m points)

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

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...