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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T04:31:15+00:00 2026-06-10T04:31:15+00:00

I looked for error and I couldn’t find it. Any google maps infoWindow always

  • 0

I looked for error and I couldn’t find it. Any google maps infoWindow always shows the same information for some reason.

Here is a coffeescript code

infowindow = new google.maps.InfoWindow()
for company in companiesData
  marker = new google.maps.Marker({
    position: new google.maps.LatLng(company.latitude, company.longitude)
    map: map
  })

  #debugger ---> each company.name is different!
  google.maps.event.addListener(marker, 'click', ()->
    infowindow.setContent(company.name)
    infowindow.open(map,this)
  )

I debugged it and saw that each company.name was different.

The output javascript

  infowindow = new google.maps.InfoWindow();
  _results = [];
  for (_j = 0, _len1 = companiesData.length; _j < _len1; _j++) {
    company = companiesData[_j];
    marker = new google.maps.Marker({
      position: new google.maps.LatLng(company.latitude, company.longitude),
      map: map
    });
    _results.push(google.maps.event.addListener(marker, 'click', function() {
      infowindow.setContent( company.name);
      return infowindow.open(map, this);
    }));
  }
  return _results;
});

So where is an error?

  • 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-10T04:31:16+00:00Added an answer on June 10, 2026 at 4:31 am

    you need to obtain closure on the variable company. You can do that by creating your markers in a separate function. for example:

    infowindow = new google.maps.InfoWindow()
    for(var n = 0 ; n < n companiesData.length ;n++){
      createMarker(companiesData[n]);
    }
    
    function createMarker(data){
      var marker = new google.maps.Marker({
        position: new google.maps.LatLng(parseFloat(data.latitude), parseFloat(data.longitude)),
        map: map
      })
    
      #debugger ---> each company.name is different!
      google.maps.event.addListener(marker, 'click', function(){
        infowindow.setContent(data.name);
        infowindow.open(map,this);
      }
      )
    }
    

    Explanation here.

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

Sidebar

Related Questions

I have some problem about operator overloading. I looked everywhere but couldn't find a
I've looked everywhere for a similar error but couldn't find a solution, so in
I looked through other questions and couldn't find what I needed. Best if I
I looked around and couldn't find it! Maybe I didn't look hard enough,but this
I've looked a lot of examples but I couldn't find anything to solve my
I looked the site to find a solution for my problem, but couldn't find
I looked on here, but couldn't find anything that applies to what I am
I've looked quite intensely, but couldn't find a post that directly solves my problem.
There is some linking error here. I looked for that online, yet still I
I looked all over facebook api docs for FLEX and i couldn't find a

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.