Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3661126
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:16:21+00:00 2026-05-19T01:16:21+00:00

I have a google maps app that will resize the map div if its

  • 0

I have a google maps app that will resize the map div if its too big, the problem I am having is that I am trying to use Jquerys animate and its returning the function before it’s finished and I have to trigger to the google maps that it was resized.

Therefore the map is zoomed in and bounds set before its triggered, thus offseting it. and only correctly working when its triggered a second time.

function doResize() {
    if ($("#map_div").width() > 600) {
        $("#stores").hide(0, function(){
            $("#map_div").animate({width: '500px'}, function(){
                google.maps.event.trigger(G_MAP, 'resize');
                $("#stores").fadeIn(1000);
            });
        });
    }
}

I cannot put the rest of the code in the callback for two main reasons, one is that its a big function and its used in two places. Also the width is only over 600 once.

Notice how when you first click newyork its offset and not centered, then click a different state and click back on new york.

Edit:

Since I cannot make the animation synchronous and doing:

while($("#map_div").width() > 500) {
    $("#map_div").width($("#map_div").width() - 1)
}

Is not smooth at all, I’ve decided to ditch the animation. Forcing Jquery to have to run asynchronous is really a downfall sometimes. Especially when javascript itself is single threaded, you’d think they would have options for waiting until its finished.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T01:16:22+00:00Added an answer on May 19, 2026 at 1:16 am

    I cannot put the rest of the code in the callback for two main reasons, one is that its a big function and its used in two places. Also the width is only over 600 once.

    And yet, that’s exactly what you must do — or rather, you don’t want to move the code there, just add a call to it from the callback. You can’t hold up the return of a function waiting for the animation to complete, there’s just no way to do that in JavaScript. The various ways in which you might try to do that (busy-waiting, etc.) don’t work. It doesn’t matter that it only happens once, you still need to use a callback.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.