谷歌地图API V3 + jQuery的冲突? [英] Google Maps v3 API + jQuery conflict?
问题描述
去过这个网站的一个诡计的读者了。希望你们/加尔斯能帮助我与亟待解决的问题。
Been a reader of this site for a wile now. Hoping you guys/gals can help me with an urgent problem.
我想开发一个商店定位器(使用谷歌地图API第3版),这是位于一个可扩展的DIV。但是,地图没有显示正确(见下面的链接)。我是一个新手,jQuery的一般,所以这一切都有点新的给我。
I'm trying to develop a Store Locator (using Google Maps v3 API), that's located in an EXPANDABLE DIV. However, the map is not showing up properly (see link below). I'm a newbie to jQuery in general, so this is all a bit new to me.
我当然知道有,虽然冲突。当我删除的扩展DIV就绪功能,地图上会正确显示。但是,并非与呼叫有...
I CERTAINLY know there's a conflict though. As when I remove the ready function for the expandable DIV, the map will show up properly. But not with the call there...
所有code可以在这里找到:
All the code can be found here:
http://t-zonevibration.com/expandable_store_locator/
它是一个jQuery冲突?如果是这样,我怎么解决?
Is it a jQuery conflict? If so, how do I fix it?
推荐答案
的 #map
元素必须在页面可见...
The #map
element must be visible in the page...
所以你需要把初始化code在回调到的slideToggle
。
So you need to put the initialization code in the callback to the slideToggle
.
$(document).ready(function() {
//Hide (Collapse) the toggle containers on load
$(".toggle_container").hide();
//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
$("h9.trigger").click(function() {
$(this).toggleClass("active").next().slideToggle("slow", function() {
if ($(this).is(':visible')) {
map = InitMap(null, 'map', centerCoord, true); // initialize the map on default location
}
});
return false; //Prevent the browser jump to the link anchor
});
handle_clicks(); // click events handling by jQuery
});
在 http://jsfiddle.net/gaby/A5jnV/
这篇关于谷歌地图API V3 + jQuery的冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!