2
votes

I am trying to show all Types[Food,Shops and Travel] of markers initially and all checkbox as checked .If I uncheck any of checkbox that particular marker will be invisible from that map and again If I check that particular marker would be visible on map .But I am unable to do so..

The data from which I am able to get the latlng is from local json in which I have specified the type as one of matching parameter to separate the markers

I have tried the select event of checkbox control but the event/function get triggered/called , when for both selected="true" and selected="false"

I only want that markers to be present when the selected property is set to true

enter image description here

The markers are placed once from the init function but when I check or uncheck the checkbox nothing happens with the markers

1
You have make list of all marker and put all marker in it. After that when you click checkbox, clean all marker and re-set marker on map, only those marker which having type equal to "food" or "Shop".. etc.Sanwal Singh

1 Answers

0
votes

Yes we can do it. Keep food, shop and travel marker in their respective array, once they click on check box pass that array to below function.

function fnRemoveMarker(markers)
    {
        if(markers != null)
        {
            _.each(markers, function(marker){
                marker.setMap(null);
            });
        }
    };

It will remove the relevant marker from map. Hope this will help you.