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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T07:07:10+00:00 2026-06-04T07:07:10+00:00

I have these markers in google maps. I need to be able to show

  • 0

I have these markers in google maps. I need to be able to show or hide them according to the ‘id’ part of the array using check boxes to toggle them on & off.

  var places = [  
  {  
    "title": "USA",  
    "description": "This is the united states",  
    "position": [ 39.639538,-104.414062 ],
    "id": "america"
  },  
  {  
    "title": "China",  
    "description": "This is the peoples republic of china",  
    "position": [ 34.016242,103.359375 ],
    "id": "asia"  
  }
]

I’ve displayed the markers using the .each() methid and I’ve tried using the below jquery to toggle them on and off according to their id but the markers seem to ignore it. Any help would be greatly appreciated.

 var showAmerica = $("#showAmerica");
    google.maps.event.addDOMListener(showAmerica, 'click', function(){
        $('#america').toggle();
});

HTML for the checkbox

<input type="checkbox" value="fund" id="showAmerica" />
  • 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-04T07:07:11+00:00Added an answer on June 4, 2026 at 7:07 am

    You’re code is referencing the jQuery object, not the DOM element. It’s easy to get at the actual DOM element, which is what the DOM listener is expecting as an argument. Simply add .get(0) to the showAmerica variable in the first argument:

    var showAmerica = $("#showAmerica");
        google.maps.event.addDOMListener(showAmerica.get(0), 'click', function(){
            $('#america').toggle();
    });
    

    Also, suggest you watch this video on using DevTools with the Google Maps API.

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

Sidebar

Related Questions

I'm using the Google Maps API and have added markers. Now I want to
I have a map with multiple markers of companies using google maps API v3.
I have a google maps app which plots markers as it loads. One of
I'm using Google Maps v3. I've already suppressed markers to display my own on
I need to use Google Maps (v3) to check whether an address typed into
Currently I have JavaScript that displays markers on a Google map using the Google
Playing around with Google Maps these days, with some directions. I have a map
I'm using Google Maps JavaScript API V2 to mark locations saved in an array.
I have a bit of a puzzle on my hands. I'm Using Google Maps
I have an application where I'm using the Google Map API to display markers

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.