开发者

Google Maps v3 API + jQuery conflict [closed]

开发者 https://www.devze.com 2023-04-10 23:35 出处:网络
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necess
Closed. This question needs debugging details. It is not currently accepting answers.

Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.

Closed 3 years a开发者_StackOverflow中文版go.

Improve this question

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.

I 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.

All the code can be found here:

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

Is it a jQuery conflict? If so, how do I fix it?


The #map element must be visible in the page...

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    
});

Demo at http://jsfiddle.net/gaby/A5jnV/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号