javascript - How to show marker content by default without any mouse event? -


i have written following code:

for (var i=1; < latitude.length; i++) {     var markercenter = new google.maps.latlng(latitude[i],longitude[i]);     var marker = new google.maps.marker({         position: markercenter,         animation: google.maps.animation.bounce     });      marker.setmap(map);     marker.setvisible(visible)     markers.push(marker);     addinfowindow(marker,location[i]); }  function addinfowindow(marker, message) {      var infowindow = new google.maps.infowindow({         content: message     });      google.maps.event.addlistener(marker, 'click', function () {         infowindow.open(map, marker);     }); } 

when user selects or unselects check-box corresponding marker set visible according action.

function markervisibility(check_box,lat,lon) {     var index;      (var = 1; < latitude.length; i++) {         if (latitude[i] == lat && longitude[i] == lon) {             index=i-1;             break;         }     }     //user selects check box see marker in google map    if (check_box.checked) {        markers[index].setvisible(true)         markers[index].setanimation(google.maps.animation.bounce);     }     //user unselects checkbox not see marker    else {         markers[index].setvisible(false)    } } 

code working fine. code have click marker see content. need load marker content default when loads map , points marker (without clicking or hovering).

another thing, if set marker set visibility "false" still, it's showing marker content. how set it's visibility off? please give suggestion in javascript.

simply remove event listener infowindow, , open create it.

function addinfowindow(marker, message) {     var infowindow = new google.maps.infowindow({         content: message     });      infowindow.open(map, marker); } 

also if want show/hide infowindow when marker's visibility toggled, following:

function addinfowindow(marker, message) {     var infowindow = new google.maps.infowindow({         content: message     });      infowindow.open(map, marker);      marker.infowindow = infowindow; }  function markervisibility(check_box,lat,lon) {     ...     if (check_box.checked) {        markers[index].setvisible(true);        marker.infowindow.open(map, marker);    }    else {         markers[index].setvisible(false);         marker.infowindow.close();    } } 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -