Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7809373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:25:00+00:00 2026-06-02T03:25:00+00:00

I am trying to produce multiple InfoWindows with the following code: EDIT: To clarify,

  • 0

I am trying to produce multiple InfoWindows with the following code: EDIT: To clarify, I want all windows to be open at the same time.

    for (var i = 0; i < 3; i++) {
      var markerOptions = {position:point[i], map:map};
      var marker = new google.maps.Marker(markerOptions);
      content = "Hello " + i;
      infowindow[i] = new google.maps.InfoWindow({content: content}); 
      google.maps.event.addListener(marker, 'mouseover', function()
      {
        infowindow[i].open(map,this);   
      });
    }

(full source)

However, I get the following error in Chrome: Uncaught TypeError: Cannot call method ‘open’ of undefined.

When I use a plain variable “infowindow” instead of the array, the single infowindow appears as expected.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T03:25:01+00:00Added an answer on June 2, 2026 at 3:25 am

    To accomplish what I want, I learned that a closure is needed:

    for (var i = 0; i < 3; i++) 
    {
      (function(i) {
        var markerOptions = {position:point[i], map:map, html:'Hello' };
        var marker = new google.maps.Marker(markerOptions);
    
        google.maps.event.addListener(marker, 'mouseover', function()
        {
            infowindow.setContent(this.html); // this is the trick: html attribute on markerOptions :), I used a array here
            infowindow.open(map,this);   
        });
      })(i);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to produce a report that has multiple grouping but does not just
I'm trying to produce a line chart using Flot, but I want the data
I'm trying to do multiple counts on the same column with different where like
I'm trying to use STL to solve the following problem (I don't want to
I'm trying to produce a multiple select list with selected options based from a
I'm trying to produce a Winforms report in my .NET application. Our users want
I'm trying to get the quantity attribute of multiple Elements ID at the same
I am trying to produce an effect where I have a title on a
I'm trying to produce sheets of photographs with captions arranged in a grid using
I'm trying to produce just the day number in a WPF text block, without

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.