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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:36:54+00:00 2026-06-13T10:36:54+00:00

So I have two html buttons that each run a different function (both functions

  • 0

So I have two html buttons that each run a different function (both functions are below). Basically, you click one of the two buttons to add a Google Maps actionlistener to the map. I’ve successfully got that to work. The only problem is that I only want the actionlistener to be available one click. After that one click I want the user to have to click another button before the actionlistener “listens” again. I hope that makes sense.

    function addLaunch() {
google.maps.event.addListener(map, "click", function(event) {
    marker = new google.maps.Marker({
      position: event.latLng,
      map: map

    });
    infowindow.open(map, marker);
});
};
function addFishing() {  
google.maps.event.addListener(map, "click", function(event) {
    marker = new google.maps.Marker({
      position: event.latLng,
      map: map
    });
    fishinfowindow.open(map, marker);
});
};

So I just tried this:

function addLaunch(setBoolean) {
var clicked = new Boolean(false);
    clicked.boolValue = setBoolean;
if (clicked = true) {
google.maps.event.addListener(map, "click", function(event) {
    marker = new google.maps.Marker({
      position: event.latLng,
      map: map

        });
        infowindow.open(map, marker);
        clicked.boolValue = false;
    });
   }
   else {
   google.maps.event.clearListeners(map, "click");
   }
 };

and it didn’t work….. Please point me in the right direction…
(BTW, the button passed “true” to the ‘setBoolean’.

This works to disable all actionlisteners after the first click. But it doesn’t reset after the button is clicked again.

    var temp = true;
function addLaunch() {
    if (temp == true) {
        google.maps.event.addListener(map, "click", function(event) {
    marker = new google.maps.Marker({
      position: event.latLng,
      map: map

        });
infowindow.open(map, marker);
        temp = false;
        if (temp == false) {
        google.maps.event.clearListeners(map, "click");
                }
        });
    }
}
  • 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-13T10:36:56+00:00Added an answer on June 13, 2026 at 10:36 am

    Use google.maps.event.addListenerOnce()

    From the documentation:

    addListenerOnce(instance:Object, eventName:string, handler:Function)
    MapsEventListener Like addListener, but the handler removes itself
    after handling the first event.

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

Sidebar

Related Questions

I have those two html radio buttons and textarea. I basically want to enable
I have an HTML document where I have two different tables. One is class
I have two select lists that each display users and two buttons (add and
I have two buttons that popup the same Modal window, but display a different
I have two templates for my HTML email: one for bigger screens, and one
I have two images in the background of my html doc. One positioned top
I have two files: master/newsletter1/file.html master/newsletter2/file.html newsletter1/file.html has a lot of new changes that
I am using jQuery to customize some radio buttons. I have two different radio
I want to use a form that has two submit buttons. Each button calls
I would like to have a dialog common to two different call-to-action buttons (row

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.