I want to assign index to the content, in order to add infowindow to markers based on their index.
console.log(storeData.length) will returns 4 rows of data.
Right now, both method returns me the same result, 4 infowindow overlay with each other. I seem a lot of examples, however I do not know how to implement to my code. Especially the var marker,i;
TS
for ( let infowindowData of storeData){
let content = '<ion-item>' +
'<h2 style="color:red;">' + infowindowData.ListingTitle +'</h2>' +
'<p>' + infowindowData.ListingDatePosted + ' ' + infowindowData.ListingTime + '</p>' +
'</ion-item>';
this.addInfoWindow(marker, content);
}
What I tried
let storeData = this.data;
for(let i=0; i<storeData.length;i++){
let content = '<ion-item>' +
'<h2 style="color:red;">' + storeData[i].ListingTitle +'</h2>' +
'<p>' + storeData[i].ListingDatePosted + ' ' + storeData[i].ListingTime + '</p>' +
'<p> Salary: $' + storeData[i].ListingSalary + '</p>' +
'</ion-item>';
let infoWindow = new google.maps.InfoWindow({
content: content
});
google.maps.event.addListener(marker, 'click', () => {
infoWindow.open(this.map, marker);
});
}
for(i>=0;? You surely meani = 0? Also what exactly do you mean by "it does not run through"? TypeScript code has to be compiled to JavaScript first, so did you get an error here? What has debugging shown you?iasany? It's pretty clearly anumberhereanyjust to test. for debugging, i useconsole.log()before the for loop and within the for loop. theconsole.logbefore runs on console but theconsole.logwithin did not appearfor(i=0;), there's no info-window shown. While when I tried with thefor(let a of b), the info-window appears. However it appeared 4 times (I had 4 rows of data) and overlay with one another.