how show not all markers on google maps ?

238
December 26, 2017, at 03:51 AM

for me is too difficult show NOT ALL markers on google maps. I have many markers and each has a zIndex. I have 3 buttons where, if is clicked, i could add or remove a range of these markers.

$('#a, #b, #c').on('click', function(){
 if ($(this).attr('id') == 'a'){
  add_del(1,arg);
 }
 else if($(this).attr('id') == 'b'){
  add_del(2,arg);
 }
 else if($(this).attr('id') == 'c'){
  add_del(3,arg);
 }
});

function add_del(arg,stato){
 if(arg == 1){
  var a= 10;
  var b= 8;
 }
 else if(arg== 2){
  var a= 8;
  var b= 6;
 }
 else{
  var a= 6;
  var b= 4;
 }

 if(stato == "add"){
  stato= map;
 }
 else if(stato== "delete"){
  stato= null;
 }

 for(var x=0; x < markers.length; x++){
    var index= (markers[x].getZIndex())+0;
    if((index <= a) && (index => b)){           
        markers[x].setMap(stato);           
    }
 }
}

If the button is active, at the click, i remove its markers. If the button is not active, at the click, i add its markers.

The code in example is simplified but i can assure you that works...the problem is this:

if i click on #c markers with zIndex between 6 and 4 are removed. Then if i click on #b also markers with zIndex between 8 and 6 are removed.

But if i click another time on #b (and active it) will add ALL markers ! This isn't correct because should add only markers of #b, so with zindex between 8 and 6. I don't understand where is the problem: maybe when i for loop array of markers ?

I hope you can help me.

Rent Charter Buses Company
READ ALSO
Week numbers in header FullCalendar scheduler [on hold]

Week numbers in header FullCalendar scheduler [on hold]

I am using FullCalendar scheduler into my project, and I have a timeline Month view that I declare it like this:

251
how to remove an element in html string with jQuery

how to remove an element in html string with jQuery

I have a Html String and I want to parse it to html and then remove any pre tags and it's childrenI tried this:

256
jQuery code to change &amp; fade background-image CSS ONLY

jQuery code to change & fade background-image CSS ONLY

I need a jQuery background fader from background to background

198