我正在寻找一种更好的方法来使用 jQuery 盲效果显示或隐藏 Google 地图 iframe。就目前而言,随着盲效应的发生,地图会多次跳跃、闪烁并重新调整大小。是否有任何建议可以规避此问题并消除该功能?
这是一个演示:http:
//jsfiddle.net/hmMRs/
HTML 标记:
<button class="button" value="Show map">Show map</button>
<div class="map" hidden>
<iframe width="280" height="280" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=Google+Headquarters,+1600+Amphitheatre+Parkway,+Mountain+View,+CA&aq=0&oq=google&sll=37.418436,-122.075443&sspn=0.093391,0.133381&t=m&ie=UTF8&hq=Google+Headquarters,+1600+Amphitheatre+Parkway,+Mountain+View,+CA&ll=37.422151,-122.083983&spn=0.009543,0.011973&z=15&iwloc=&output=embed"></iframe>
<br /><small><a href="https://maps.google.com/maps?f=q&source=embed&hl=en&geocode=&q=Google+Headquarters,+1600+Amphitheatre+Parkway,+Mountain+View,+CA&aq=0&oq=google&sll=37.418436,-122.075443&sspn=0.093391,0.133381&t=m&ie=UTF8&hq=Google+Headquarters,+1600+Amphitheatre+Parkway,+Mountain+View,+CA&ll=37.422151,-122.083983&spn=0.009543,0.011973&z=15&iwloc=A" style="color:#0000FF;text-align:left">View Larger Map</a></small>
</div>
脚本:
$(".button").click(function () {
$(".map").toggle("blind", 1000);
$(this).text($(this).text() == "Hide map" ? "Show map" : "Hide map");
});
我对 jQuery 比较陌生,因此欢迎任何其他关于如何改进我的方法的评论。谢谢!