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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:38:13+00:00 2026-06-14T14:38:13+00:00

So after some fantastic help from users here I now have a button to

  • 0

So after some fantastic help from users here I now have a button to hide all of the map markers on my website. However I need to be able to hide markers based on their category.

The code below passes the results from Google to a markers array

  function createMarker(place) {
    var iconType = {};
    iconType['atm'] = "http://maps.google.com/mapfiles/ms/micons/dollar.png";
    iconType['bus_station'] = "http://maps.google.com/mapfiles/ms/micons/bus.png";
    //iconType['restaurant'] = "http://maps.google.com/mapfiles/ms/micons/restaurant.png";
    iconType['parking'] = "http://maps.google.com/mapfiles/ms/micons/parkinglot.png";
    var placeLoc = place.geometry.location;
    var marker = new google.maps.Marker({
      map : map,
      icon : iconType[place.types[0]],
      position : place.geometry.location,
      category : category
    });

    google.maps.event.addListener(marker, 'click', function() {
      infowindow.setContent(place.name);
      infowindow.open(map, this);
    });

    return marker;
  }

I think that the category attribute should now be populated with the response from google, the problem I now have is chosing these results (a particular category) when I call my function to hide the markers, I dont know how to access the array data for category, I have searched multiple threads here but their code is vastly different from mine. My code for hiding the markers is here.

  function onRemoveBtn_Clicked() {
    var i;
    for (i = 0; i < markers.length; i++) {
      markers[i].setMap(null);
    }
  }

Any help greatly appreciated. Oh, and the code used to get the results is.

service = new google.maps.places.PlacesService(map);
service.nearbySearch(request, callback);
  function callback(results, status) {
    if (status == google.maps.places.PlacesServiceStatus.OK) {
      for (var i = 0; i < results.length; i++) {
        var place = results[i];
        markers.push(createMarker(results[i]));
      }
    }
  }
  • 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-14T14:38:14+00:00Added an answer on June 14, 2026 at 2:38 pm

    You can get the category of the marker like this:

    function onRemoveBtn_Clicked() {
        var i;
        for (i = 0; i < markers.length; i++) {
          if (markers[i].get("category") != selected_category) {
            markers[i].setMap(null);
          }
        }
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After some great help from Josh Mein with a Javascript Hide/Show menu, the menu
After some advice on how to clear markers on googlemaps, I have a map
After some help here, I've got WPF using the windows.forms notifyIcon class (It's not
After some recursive function I have an array: first iteration: Array ( [category_id] =>
After some serious googleing I found out that the RandomAccessFile-class is not thread-safe. Now
after some years in Java and C# now I'm back to C++. Of course
After some searching I found this youtube style url generator with encryption to hide
After some advice. I have a client wishing to have an app which lets
After some theoretical help on the best approach for allowing a SaaS product to
So after some trial and error, I think I have my math finally figured

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.