Fra*_*ank 4 google-maps weather-api google-maps-api-3
我试图在我的页面上实现此代码(http://stackoverflow.com/questions/10318316/how-to-hide-or-display-a-google-maps-layer/),以便将天气/云置于/离开我的地图,但不知何故它干扰了我当前的代码.我已经尝试了上面链接中提供的两个选项,但也许我做错了,或者它干扰了我的地图中已有的Fusion Tables选项?
有人可以用正确的代码片段帮助我吗?我的页面在这里http://www.strahlen.org/map/mapplusweather.htm.(de)选择按钮已位于右下角.
先谢谢你,弗兰克
ps:虽然管理员删除了你的帖子,感谢Alexander Farber为你以前的帮助!
ps 2:我当然有天气层工作,请参阅http://www.strahlen.org/map/mapweather.htm,但我无法打开/关闭它
*最终编辑* 以防止链接腐烂:我现在在我的"生产版本"中使用了代码 - > http://www.strahlen.org/map/
我已经查看了您的网站,我相信您只需对现有代码进行一些基本更改.首先,在您的initialize()函数中添加两个新变量:
function initialize() {
var tableId = 3167783;
var cloudDisplayIsOn = false;
var weatherDisplayIsOn = false;
Run Code Online (Sandbox Code Playgroud)
然后,在您现有的云 click侦听器代码中,进行以下更改:
google.maps.event.addDomListener(document.getElementById('cloud'),
'click', function() {
if ( cloudDisplayIsOn ) {
cloudLayer.setMap( null );
cloudDisplayIsOn = false;
}
else {
cloudLayer.setMap( map );
cloudDisplayIsOn = true;
}
});
Run Code Online (Sandbox Code Playgroud)
最后,在您现有的天气 click监听器代码中,进行非常相似的更改:
google.maps.event.addDomListener(document.getElementById('weather'),
'click', function() {
if ( weatherDisplayIsOn ) {
weatherLayer.setMap( null );
weatherDisplayIsOn = false;
}
else {
weatherLayer.setMap( map );
weatherDisplayIsOn = true;
}
});
Run Code Online (Sandbox Code Playgroud)
现在,你可能必须做一些轻微的调试,但我相信,这将增加对通/断码显示屏cloudLayer和weatherLayer你需要的.
| 归档时间: |
|
| 查看次数: |
4968 次 |
| 最近记录: |