Multiple Marker from different json file on google map api

58 views
Skip to first unread message

Prashant Kumar

unread,
Nov 23, 2015, 4:08:41 PM11/23/15
to Google Maps JavaScript API v3
I have 4 json files with coordinates. I want to show marker on map with checkbox selection. My issue is when I click on checkbox the marker is appear but when I uncheck the checkbox the marker is not disappear. 

ralfwessels

unread,
Nov 24, 2015, 4:00:28 AM11/24/15
to Google Maps JavaScript API v3
Hi Prashant,
one approach to make the markers disappear when uncheck the checkbox is to make them unvisible with  'setVisible(false)'.
To get all the markers of a category you need to put them in an array and go through all markers to make them invisible:

      for (var i=0; i<gmarkers.length; i++) {
          if (gmarkers[i].mycategory == category) {
            gmarkers[i].setVisible(false);
          }
        }

Have a look to the whole example here: http://www.ralf-wessels.de/test/apiv3/marker_categories.html

Ralf
Reply all
Reply to author
Forward
0 new messages