最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Why won't my KML file display on google maps? - Stack Overflow

programmeradmin2浏览0评论

Can anyone tell me why this kml file won't display on google maps?

Im using the following code to add it to the map object which seems to work fine with other kml files.

var kml = new google.maps.KmlLayer('.kml');
kml.setMap(map);

Feed validator says its valid and it isn't too big for googles servers to parse?

The map just zooms right into the ocean!

Can anyone tell me why this kml file won't display on google maps?

Im using the following code to add it to the map object which seems to work fine with other kml files.

var kml = new google.maps.KmlLayer('http://www.emotination./kml/tasman.kml');
kml.setMap(map);

Feed validator says its valid and it isn't too big for googles servers to parse?

The map just zooms right into the ocean!

Share Improve this question edited May 1, 2012 at 23:36 mmmmmm 32.7k28 gold badges91 silver badges122 bronze badges asked Feb 17, 2012 at 3:43 kmb64kmb64 1,5132 gold badges17 silver badges29 bronze badges 4
  • This should work, can you post a link to your live code, or put it in a jFiddle? – Mano Marks Commented Feb 17, 2012 at 20:01
  • It does seem to work now, I tried running it again the next day. Im still confused though because I didn't change anything. All I can think of is that it would be something to do with googles servers cacheing an older copy of the kml file – kmb64 Commented Feb 17, 2012 at 21:51
  • 2 You are correct that the kml files are cached. You can get around that problem by add a timestamp parameter to the url (so the google server will consider it as a different file). I.e. 'emotination./kml/tasman.kml?time='+new Date().getTime(); – Björn Commented Feb 19, 2012 at 16:24
  • Please post the gist of the ments as an answer and mark this question as answered. – Sean Mickey Commented May 1, 2012 at 22:53
Add a ment  | 

1 Answer 1

Reset to default 8

You need to ensure Google's servers aren't displaying a cached copy of your kml file

A good way to do this is to do what Björn suggests in his ment and just add a timestamp so the end of the url:

var kml_tasman = new google.maps.KmlLayer('http://www.emotination./kml/tasman.kml?time='+new Date().getTime());
kml_tasman.setMap(map);
发布评论

评论列表(0)

  1. 暂无评论