将天气图层打开/关闭以及其他选择 [英] Turning weather layer on/off combined with other selections

查看:154
本文介绍了将天气图层打开/关闭以及其他选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在我的页面上实现此代码(http://stackoverflow.com/questions/10318316/how-to-hide-or-display-a-google-maps-layer/),将天气/云朵开/关我的地图,
,但不知何故,它干扰我目前的代码。我尝试了上述链接中提供的两个选项,但也许我做了错误的事,或者干扰了已经在我的地图中的Fusion Tables选项?

有人可以帮我用正确的代码片段吗?
我的页面在这里 http://www.strahlen.org/map/mapplusweather.htm
(de)选择按钮已经在右下角。



预先感谢,
Frank



ps:尽管管理员删除了您的帖子,感谢Alexander Farber先前的帮助!

ps 2:我当然有天气层的工作,请参阅 http://www.strahlen.org/map/mapweather.htm ,但我无法开启/关闭它。

*最终编辑*
防止链接腐烂:我现在在我的生产版本中使用了代码 - > http://www.strahlen.org/map/

解决方案

I已经看过您的网站,我相信您只需对现有代码进行一些基本更改即可。首先,在你的 initialize()函数中添加两个新变量:

 函数initialize(){
var tableId = 3167783;
var cloudDisplayIsOn = false;
var weatherDisplayIsOn = false;

然后,在您现有的 / code>监听器代码,进行以下更改:

  google.maps.event.addDomListener(document.getElementById('云'),
'click',function(){
if(cloudDisplayIsOn){
cloudLayer.setMap(null);
cloudDisplayIsOn = false;
}
else {
cloudLayer.setMap(map);
cloudDisplayIsOn = true;
}
});

最后,在您现有的天气 中点击侦听器代码,做出非常类似的更改:

  google.maps.event.addDomListener(document.getElementById ('weather'),
'click',function(){
if(weatherDisplayIsOn){
weatherLayer.setMap(null);
weatherDisplayIsOn = false;
}
else {
weatherLayer.setMap(map);
weatherDisplayIsOn = true;
}
});

现在您可能需要进行一些小调试,但我相信这会在/关闭您需要的 cloudLayer weatherLayer 的代码。


I tried to implement this code (http://stackoverflow.com/questions/10318316/how-to-hide-or-display-a-google-maps-layer/) on my page, to put the weather/clouds on/off my map, but somehow it interferes with my current code. I tried the two options that were presented in the above link already, but perhaps I did something wrong, or it interferes with the Fusion Tables selections that are already in my map?

Could someone please help me with the right snippet of code? My page is here http://www.strahlen.org/map/mapplusweather.htm. The (de)select buttons are already in the bottom right corner.

Thanks in advance, Frank

ps: although an admin deleted your posting, thanks to Alexander Farber for your previous help!

ps 2: I of course have the weather layer working, see http://www.strahlen.org/map/mapweather.htm, but I cannot toggle it on/off

* final edit * to prevent link-rot: I used the code here in my "production-version" now -> http://www.strahlen.org/map/

解决方案

I've taken a look at your site and I believe you just have to make some basic changes to your existing code. First, add two new vars within you initialize() function:

function initialize() {
    var tableId = 3167783;
    var cloudDisplayIsOn = false;
    var weatherDisplayIsOn = false;

Then, in your existing cloud click listener code, make these changes:

google.maps.event.addDomListener(document.getElementById('cloud'),
    'click', function() {
        if ( cloudDisplayIsOn ) {
            cloudLayer.setMap( null );
            cloudDisplayIsOn = false;
        }
        else {              
            cloudLayer.setMap( map );
            cloudDisplayIsOn = true;
        }
    });

And finally, in your existing weather click listener code, make very similar changes:

google.maps.event.addDomListener(document.getElementById('weather'),
    'click', function() {
        if ( weatherDisplayIsOn ) {
            weatherLayer.setMap( null );
            weatherDisplayIsOn = false;
        }
        else {
            weatherLayer.setMap( map );
            weatherDisplayIsOn = true;
        }
    });

Now you may have to do a little minor debugging, but I believe this will add the display on/off code for the cloudLayer and the weatherLayer that you need.

这篇关于将天气图层打开/关闭以及其他选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆