-1

Who can help me out with the following: from several sources I combined some javascript to make a google map with a dropdown-menu. From this menu I'm able to place/hide markers on the map by categorie. That part works fine, but now I'm trying to get the "check all"/"uncheck all" buttons inside the menu to work... So far the buttons do check/uncheck the checkboxes, but the markers on the map are not responding accordingly.

I tried several options like Remove all markers google map v3 & Google Maps API v3: How to remove all markers? & Hide particular marker google maps api

Untill now i can't get it to work... (my basic javascript knowledge is very limited...) Who can give me a hint?

Here is a working fiddle

 `http://jsfiddle.net/n86zxopp/`
C Bouwman
  • 21
  • 3
  • You're checking the boxes, but not initiating the actual event behind them. – roberrrt-s Jan 10 '18 at 10:08
  • True, thats exactly what's happening. Thats why i tried to clear the map with something like 'marker.setMap(null);' I also tried to work with the hide/show functions inside the javascript, but i can't get it to work – C Bouwman Jan 10 '18 at 10:15

1 Answers1

0

plz check this http://jsfiddle.net/n86zxopp/2/

I have updated your click functions like

function check() {
  $('input[type="checkbox"]').prop("checked", true).change();
}

function uncheck() {
  $('input[type="checkbox"]').prop("checked", false).change();
}
Aswin Ramesh
  • 1,654
  • 1
  • 13
  • 13
  • maybe, any idea how to set ALL categories 'hidden' initially? now I have to set all categories onen by one, like in the example " hide("DaR"); hide("AmLeg"); " – C Bouwman Jan 10 '18 at 11:13
  • yeah.. you can have like `markers.forEach((marker) => marker.setVisible(false))` – Aswin Ramesh Jan 10 '18 at 12:37
  • OK, moving on with my project, I tried to insert about 10.000 markers in the javascript. I expected it not to work (i allready read about that) but I just wanted to try it out. – C Bouwman Jan 12 '18 at 09:56
  • So,I inserted about 10.000 markers (and about 200 categories) in the javascript itself, and that didn't work... Could someone explain me why this doesn't work? (the markers are all hidden initially, and only show when checking a checkbox). – C Bouwman Jan 12 '18 at 10:12