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

  • Home
  • SEARCH
  • 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 712219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T04:49:27+00:00 2026-05-14T04:49:27+00:00

Here is the problem: Lets say a Jquery toggle button which loads a Google

  • 0

Here is the problem:

Lets say a Jquery toggle button which loads a Google Map upon request and hides its later when toggled:

 $('#showmeMap').toggle(function() 
 {
   var map = new GMap2($("#map").get(0));
   var mapCenter = new GLatLng(-2, 20);
   map.setCenter(mapCenter, 12);
   $('#map').show();
 }
 }, function() {
$('#map').hide();
 });

Then I add some random markers and later another function which removes markers from the map:

 $('#destroyMarkersButton').click(function() {
    for (var i=0; i<gmarkers.length; i++) 
    {
    map.removeOverlay(gmarkers[i]);
    }
  });   

When clicking on the button I´ve got the error Map is undefined. My thought was defining Google Map object globally:

  map = new GMap2($("#map").get(0));

Which works perfectly in Firefox, however, map fails to load on internet explorer!!

Any suggestions ?

  • 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-14T04:49:27+00:00Added an answer on May 14, 2026 at 4:49 am

    Either wrap both in a function so you can get to map via the closure (they should already be anyway because you should be doing document.ready on these):

    $(function()
    {
        var map;
        $('#showmeMap').toggle(function() 
        {
            map = new GMap2($("#map").get(0));
            // ...
        });
    
        $('#destroyMarkersButton').click(function() {
            // ...
        });
    });
    

    Or, you can define a namespace of sorts (usually I have a library for this that does it recursively rather than directly like this):

    if (window.myApp === undefined)
        window.myApp = {};
    var appNS = window.myApp;
    

    Then, you can use that namespace with confidence that it’ll hold through the whole page, since it’s tied directly to window:

    $('#showmeMap').toggle(function() 
    {
        appNS.map = new GMap2($("#map").get(0));
        // ...
    });
    

    and so on.

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

Sidebar

Related Questions

Here is the problem. lets say I have a product category table and a
Here's my problem: Lets say I have two dictionaries, dict_a and dict_b. Each of
Here is the problem, lets say we are making a video game and want
hello im just having a problem here with PREG_MATCH_ALL() lets say i have 2
Here is the Problem: Lets say I have something like this: <div id=leftcontainer> <div
Maddening problem here. When my page loads: <body onload=getClientDateTime();> It runs this function: document.getElementById('ClientDateTime').value=hello
I'm facing a problem here, with HttpListener. When a request of the form http://user:password@example.com/
Lets say there is a base class pointer which is pointing to a base
Here's the situation: I have a web application which response to a request for
Lets say that I'm trying to solve a parsing problem of string to char

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.