有没有办法在Google Maps JavaScript API中刷新天气图层?我们有一个应用程序,它在浏览器中保持打开状态,并每隔几分钟更新地图上的一些信息。我们允许用户在地图上打开天气图层,但天气只在创建图层时加载一次。过了一会儿,它就过时了,我们希望它保持最新状态。我尝试了从重新创建图层和将地图设置为null,然后回到当前地图的所有方法,但温度永远不会重新加载。请问有什么建议吗?谢谢!更新:一些代码片段展示了我如何尝试重新加载天气图层。
//Global variable for the weather layer
var weatherLayer = null;
//When user clicks the weather button on the map
weatherLayer = new google.maps.weather.WeatherLayer({..});
weatherLayer.setMap(myMap);
//When I try to refresh the layer
weatherLayer.setMap(null); //This successfully hides it
weatherLayer = new google.maps.weather.WeatherLayer({...});
weatherLayer.setMap(myMap); //This doesnt' reload the data.
//Tried resetting the options before and after recreating the layer to see if that would help, but it didn't
weatherLayer.setOptions({..new option set..});