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 8831855
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T08:24:14+00:00 2026-06-14T08:24:14+00:00

I have a map application that uses jQuery to show/hide some map controls upon

  • 0

I have a map application that uses jQuery to show/hide some map controls upon clicking of a button. Now, all the controls are working fine except for one – the pan_zoom control. The html elements for the map controls are added dynamically together with some inline styling:

<div class="pan_zoom" style="display: block; top: 4px">pan zoom button</div>

The pan_zoom control is hidden upon loading of the map with:

$('.pan_zoom').hide();

Upon clicking of the button, a function containing the following line is called:

$('.pan_zoom').toggle();

This function hide the pan_zoom control on the first click. However, it did not show the control on the next click.

I tested the above again, without hiding the pan_zoom control upon initialization. This time, toggling has no effect on the element.

What could be the possible reasons that is preventing the toggle function from working properly?

Note that I did not set any CSS display property for this element and that I can solve this problem by replacing the toggle function with:

if($('.pan_zoom').css('display') == 'block')
{
 $('.pan_zoom').hide();
}
else
{
 $('.pan_zoom').show();
}

What I am more interested is to find out why toggle() is not working properly.

The click handler is:

$('button[name="expand_map"]').click(toggleMap);
function toggleMap() {
....
 $('.pan_zoom, .and_other_controls').toggle();
}
  • 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-06-14T08:24:15+00:00Added an answer on June 14, 2026 at 8:24 am

    This is a tricky one. I write it down here so that others who came across this will take a hard look at the computed element style. In my case, the computed height and width for the pan_zoom control element turns out to be 0 due to absolute positioning of divs within the control div. This in turn affects how jQuery toggle() function treat the display of the element.

    I presume it considers elements with zero width and height to be equivalent to a hidden element and therefore does not hide it. One way to overcome this problem is to use show() / hide() as described in the question. Another less obvious way, in order to use toggle(), is to set a value for the width and height. With jQuery, this will be:

    $('.pan_zoom').css({'height': '1px', 'width': '1px'});
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing sample application that uses Google Map API. I have generated Google
I have an application that uses the mapview-overlay-manager code to draw map markers on
I have an application that uses OpenLayers library. I create a scale line: map.addControl(new
I have a small application that uses a DrawingArea to draw a simple map
I have manage to create a small size js application that uses jQuery and
I have an application that uses MKMapView and at some point in the app
I have an application that uses HTTPS for some of its routes in conjunction
I have a silverlight application that contains Bing map. I want when the user
We have built an application that uses packages and components. When we debug the
I have a MVC 4 web api application that receives json objects and uses

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.