google maps kml layer refresh problem
I have a kml layer on my google maps app. I tried to refresh the kml layer by generating a new google.maps.KmlLayer object every 10s. The kml file contains customized icons. It works fine for the first several times of refreshing. However after a few minutes, the kml layer disappears (the icons disappear but they are still clickable). Any ideas why the kml layer disappears?
Here is the snippet of my code:
function initialize() {
var p = new google.maps.LatLng(36.668419,-119.267578);
var mapOptions = {
zoom: 5,
center: p,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
map = new google.maps.Map(document.getElementById("map_canvas"),
mapOptions);
var kmllayer = new google.maps.KmlLayer('http://api.flickr.com/services/feeds/geo/?g=322338@N20&lang=en-us&format=feed-georss'
+ '?key='
+ Math.ra开发者_JAVA技巧ndom(),
({'preserveViewport': true}));
geotaggingLayer.setMap(map);
setInterval(refresh, 10000, kmllayer);
}
function refresh(layer) {
var newkmllayer = new google.maps.KmlLayer('http://api.flickr.com/services/feeds/geo/?g=322338@N20&lang=en-us&format=feed-georss'
+ '?key='
+ Math.random(),
({'preserveViewport': true}));
layer.setMap(null);
newkmllayer.setMap(map);
}
Thank you.
精彩评论