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

The Archive Base Latest Questions

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

Here is my markers[] array: partnerMarkers = [ // London { lat: 51.515482718, lng:

  • 0

Here is my markers[] array:

partnerMarkers = [
        // London
        { lat: 51.515482718, lng: -0.142903122, name: "London", content: "Our home town and international hub." },
// Dubai
        { lat: 25.2644444, lng: 55.3116667, name: "Middle East", content: "Dubai desc" }
];

I have this function, looping through the array of markers (triggered by a button elsewhere):

function toggle_layer(markers) {
    for (var i=0; i<markers.length; i++) {
        markers[i].setVisible(false);
    }
}

I get markers[i].setVisible is not a function – but then this works fine:

function toggle_layer(markers) {
    for (var i=0; i<markers.length; i++) {
        console.log(markers[i]);
    }
}

Why does setVisible not work in this context?

  • 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-21T05:16:22+00:00Added an answer on May 21, 2026 at 5:16 am

    Here is the JSFiddle Demo:

    Seems like your markers are just objects instead of google.maps.Markers, and thus it does not have setVisible() function within it. You basically want to convert the data within your Object into a google.maps.Marker object. I created a global array gooMarker to hold the Markers. By clicking on the link below the map, it’ll hide the markers. Here is the way to create Markers and then hide them:

    HTML Markup:

    <div id='parent'>
        <div id="map_canvas" style="width: 650px; height: 550px;"></div>
    </div>
    <div id='hidemark'>Click to hide markers</div>
    

    JavaScript + Google Map V3 API:

    var map;
    var gooMarker = [];
    
    var partnerMarkers = [
       {
        lat: 51.515482718,
        lng: -0.142903122,
        name: "London",
        content: "Our home town and international hub."},
        {
        lat: 25.2644444,
        lng: 55.3116667,
        name: "Middle East",
        content: "Dubai desc"}
    ];
    
    function initialize() {
    
        var london = new google.maps.LatLng(51.5, 0);
    
        var myOptions = {
            backgroundColor: '#FFFFF',
            zoom: 2,
            center: london,
            navigationControl: true,
            mapTypeId: google.maps.MapTypeId.ROADMAP
        };
    
        var map_canvas = document.getElementById("map_canvas");
    
        map = new google.maps.Map(map_canvas, myOptions);
    
        for (var i = 0; i < partnerMarkers.length; i++) {
            gooMarker.push(new google.maps.Marker({
                position: new google.maps.LatLng(partnerMarkers[i].lat, partnerMarkers[i].lng),
                map: map,
                title: partnerMarkers[i].name
            }));
        }
    }
    
    function hideMarkers(){
        for(var i=0; i<gooMarker.length; i++){
            gooMarker[i].setVisible(false);
        }
    }
    
    document.getElementById('hidemark').onclick = hideMarkers;
    
    window.onload = initialize;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is a sample of the XML: <markers><marker name=Faulkner State Community College lat=30.853801 lng=-87.776692
I'm using Google Maps API v3. My code takes objects (name, lat, lng, and
I'm having a hard time understanding why this.$map and this.markers are undefined. Here's the
here is my php code $titikPetaInti = array(); while($row = mysql_fetch_assoc($hasil2)) { $titikPetaInti[] =
Here's a piece of code I copied from http://www.schillmania.com/content/projects/javascript-animation-1/demo/ Very simple JS animation: function
The problem here is pretty self-evident from the resulting JSON array at the bottom.
My Php/mySQL code for creating google maps markers is printing out Array instead of
code //array store the markers var googleMarker = []; //this function get json object
I am having some markers on maps the part of the code is here
I have a map with multiple markers, which I populate via an array. Each

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.