【问题标题】:Google Maps v3 API + jQuery conflict [closed]Google Maps v3 API + jQuery 冲突 [关闭]
【发布时间】:2011-10-05 00:00:14
【问题描述】:

我正在尝试开发一个商店定位器(使用 Google Maps v3 API),它位于可扩展的 div 中。但是,地图没有正确显示(见下面的链接)。总的来说,我是 jQuery 的新手,所以这对我来说有点新。

我知道有冲突。当我删除可扩展 div 的准备功能时,地图将正确显示。但不是与那里的电话。

所有代码都可以在这里找到:

http://t-zonevibration.com/expandable_store_locator/

是 jQuery 冲突吗?如果是这样,我该如何解决?

【问题讨论】:

  • 不幸的是,这个问题依赖于一个外部链接,该链接现在返回 404。这意味着该帖子缺少minimal reproducible example,这是使其易于理解所必需的。现在,我建议将这个问题搁置,考虑到它的年龄。

标签: jquery api


【解决方案1】:

#map 元素必须在页面中可见...

所以你需要把初始化代码放在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/的演示

【讨论】:

    猜你喜欢
    • 2012-01-06
    • 1970-01-01
    • 2014-05-09
    • 1970-01-01
    • 2011-01-03
    • 1970-01-01
    • 2011-10-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多