There is an interval in which the elements of the array are displayed on the map. I want to add information to the displayed markers. But for some reason the method does not work.
var Cicle = setInterval(function() { var locations = [ ['Bondi Beach', -33.890542, 151.274856, 4], ['Coogee Beach', -33.923036, 151.259052, 5], ['Cronulla Beach', -34.028249, 151.157507, 3], ['Manly Beach', -33.80010128657071, 151.28747820854187, 2], ['Maroubra Beach', -33.950198, 151.259302, 1] ]; var markers = []; var infowindow = []; var num_markers = locations.length; for (var i = 0; i < num_markers; i++) { markers[i] = new google.maps.Marker({ position: { lat: locations[i][1], lng: locations[i][2] }, map: map }); }; for (var i = 0; i < num_markers.length; i++) { markers[i].setPosition(locations[i][1], locations[i][2]); //Данный метод добавения окна с текстом не работает* infowindow[i] = new google.maps.InfoWindow(); infowindow[i].setContent(locations[i][0]); infowindow[i].open(map, marker[i]); } }, 15000); Cicle;
var infowindow = []; ....... then use push ..... happy end - Alexey Shimansky