It is assumed that we already have an initialized map and markers stored in a certain array.
Task: for a certain house-event, you need to display an information window at the corresponding label.
The code below works, but the information window opens in the upper left corner of the map without being tied to a specific marker. If I try to pass the corresponding marker to the second parameter, i.e. instead of infowindow.open (map); I write infowindow.open (map, marker); then I get the Uncaught TypeError error message in the console : b.get is not a function.
Why and how to solve this issue?
$.each( markers, function( key, marker ) { if (marker.id == activeStore) { console.log(marker); console.log(map); //Всплывашка var contentString = '<b>' + marker.title +'</b>' + '<br>' + marker.description + //'<br>' + 'Адрес: ' + this.address + '<br>' + 'Телефон: ' + marker.phone + '<br>' + 'Режим работы: ' + marker.schedule; var infowindow = new google.maps.InfoWindow({ content: contentString }); arrInfoWindows[arrInfoWindows.length] = infowindow; infowindow.open(map); // Центрируем и масштабируем карту //map.setCenter(markersBounds.getCenter(), map.fitBounds(markersBounds)); } });
AddMarkerfunction, which then displaysInfoWindow- Sv__t