我尝试在我的页面上实现此代码(http://stackoverflow.com/questions/10318316/how-to-hide-or-display-a-google-maps-layer/),以将天气/云放在/从我的地图上消失,
但不知何故它干扰了我当前的代码。我已经尝试了上面链接中提供的两个选项,但也许我做错了什么,或者它干扰了我的地图中已有的 Fusion Tables 选择?
有人可以帮我提供正确的代码片段吗?
我的页面在这里http://www.strahlen.org/map/mapplusweather.htm http://www.strahlen.org/map/mapplusweather.htm。
(取消)选择按钮已经位于右下角。
提前致谢,
坦率
ps:虽然管理员删除了您的帖子,但感谢 Alexander Farber 之前的帮助!
ps 2:我当然有天气层工作,请参阅http://www.strahlen.org/map/mapweather.htm http://www.strahlen.org/map/mapweather.htm,但我无法打开/关闭它
*最终编辑*为了防止链接腐烂:我现在在我的“生产版本”中使用了这里的代码->http://www.strahlen.org/map/ http://www.strahlen.org/map/
我查看了您的网站,我相信您只需对现有代码进行一些基本更改即可。首先,在你内部添加两个新的变量initialize()
功能:
function initialize() {
var tableId = 3167783;
var cloudDisplayIsOn = false;
var weatherDisplayIsOn = false;
然后,在你现有的cloud click
监听器代码,进行以下更改:
google.maps.event.addDomListener(document.getElementById('cloud'),
'click', function() {
if ( cloudDisplayIsOn ) {
cloudLayer.setMap( null );
cloudDisplayIsOn = false;
}
else {
cloudLayer.setMap( map );
cloudDisplayIsOn = true;
}
});
最后,在你现有的weather click
监听器代码,进行非常类似的更改:
google.maps.event.addDomListener(document.getElementById('weather'),
'click', function() {
if ( weatherDisplayIsOn ) {
weatherLayer.setMap( null );
weatherDisplayIsOn = false;
}
else {
weatherLayer.setMap( map );
weatherDisplayIsOn = true;
}
});
现在您可能需要进行一些小的调试,但我相信这将为cloudLayer
和weatherLayer
你需要的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)