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 8181843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T00:39:32+00:00 2026-06-07T00:39:32+00:00

I have a list of Google Maps API markers in a dictionary called markerList

  • 0

I have a list of Google Maps API markers in a dictionary called markerList. All of them are being placed on the map. Then I create an array of all my infowindow‘s. Then I need to addListener for each of them so that when the marker is clicked on the map, it will call infowindow.open on the correct map and infowindow.

Unfortunately, when I click on a marker, I get the following error in firebug console:

infowindow is not defined

infowindow.open(map,infowindowList[window]);

Here is my code:

 var infowindowList = {};

 for (var aMarker in markerList){
     infowindowList[aMarker] = new google.maps.InfoWindow({
          content: "This is a test!",
          size: new google.maps.Size(50,50)
     });

     console.log(infowindowList[aMarker]);
 }

 console.log("Done creating infowindowList...\n...Adding listeners");

 for (var window in infowindowList){
      google.maps.event.addListener(markerList[window], 'click', function() {
          // infowindow.open(map,infowindowList[window]); // wrong, see Edit
              infowindowList[window].open(map,markerList[window]);
      });
      console.log("added listener for window: ", infowindowList[window]);

 }

I think this is happening because in the google.maps.event.addListener(markerList[window]... function, I register the function to be run on click as infowindow.open(map,infowindowList[window]), but that value, window, is local to the function, and so when I click on the marker, that function doesn’t work, because it doesn’t know what window is. Is that correct?

EDIT: As geocodezip pointed out, infowindow does not exist. So I changed it to infowindowList[window].open(map,markerList[window]);, also changing the last argument to markerlist[window] because it should be a marker as an arg, not another infowindow.

  • 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-07T00:39:33+00:00Added an answer on June 7, 2026 at 12:39 am

    You are getting the error “infowindow is not defined” because the infowindow variable is not defined. It certainly isn’t defined in the code you posted.

    Usually it is defined globally so there is one infowindow (the v2 default behavior), but in that case you still have to define it and create it (usually in the onload function).

    working example

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of links that all go to a google maps api.
I have a Google Map on our site that has a list of markers
I am developing a web application, i have following uses of google maps List
using javascript google-maps api I currently have it setup to remove a maker I
I'm trying to add markers to a Google maps using V3. I have my
I have a list of polylines, just like google maps does when I click
We have a program that displays map data (think Google Maps, but with much
I have a web app that uses Google Maps API v3. I have it
I have a list of individual redirects that move users (and google) from abc.site.com/page/name
i have list of rows that user select and i want to delete them,

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.