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

Can anyone tell me why this kml file won't display on google maps?Im using the following code to a

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);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745093728a4610847.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信