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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:13:57+00:00 2026-06-11T20:13:57+00:00

Possible Duplicate: Looping through Markers with Google Maps API v3 Problem I have a

  • 0

Possible Duplicate:
Looping through Markers with Google Maps API v3 Problem

I have a loop in which I extract some data from an array element, then add an event listener for each iteration. But I need to pass these values to each associated listener but I end up having only the last array item values in the listener. I have tried to understand from “this” but the solution seems not suitable in my case and I am confused. This is the code that I have:

for(var i=0;i<route.length;i++)
{
  var input= route[i];
  var sdata= input.split("@",19)
  //Some code
  google.maps.event.addListener(marker,'click',showiwindow);
}

function showiwindow(event)
{
  var input= event.latLng;
  //some code 
  ...
  document.getElementById('<%= lbl1.ClientID %>').innerHTML = sdata[1];
  document.getElementById('<%= lbl2.ClientID %>').innerHTML = sdata[2];
  document.getElementById('<%= lbl3.ClientID %>').innerHTML = sdata[3];
  document.getElementById('<%= lbl4.ClientID %>').innerHTML = sdata[4];     
  ......
}    

When I click on a marker I only get the values of the last iteration. Coming back to the solution in that link, how do I pass the array along with the iteration value that is i. Kindly refer to the link of what I meant.

  • 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-11T20:13:58+00:00Added an answer on June 11, 2026 at 8:13 pm

    How about something like this?

    for(var i=0;i<route.length;i++)
    {
      var input= route[i];
      var sdata= input.split("@",19)
      //Some code
      showiwindow(sdata);
    }
    
    function showiwindow(sdata)
    {
      google.maps.event.addListener(marker,'click', function(event) {
        var input= event.latLng;
        //some code 
        ...
        document.getElementById('<%= lbl1.ClientID %>').innerHTML = sdata[1];
        document.getElementById('<%= lbl2.ClientID %>').innerHTML = sdata[2];
        document.getElementById('<%= lbl3.ClientID %>').innerHTML = sdata[3];
        document.getElementById('<%= lbl4.ClientID %>').innerHTML = sdata[4];     
        ......
      });
    }    
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: How does foreach work when looping through function results? If I have
Possible Duplicate: Looping through rows in a DataView I have created a dataview from
Possible Duplicate: iterate through pairs of items in python list I have a list
Possible Duplicate: looping through enum values Suppose we're dealing with a deck of cards
Possible Duplicate: Looping through a directory on the web and displaying its contents (files
Possible Duplicate: How does foreach work when looping through function results? Title has the
Possible Duplicate: indexOf method in an object array? I have a javascript array which
Possible Duplicate: How do i Loop through the hidden field items and put in
Possible Duplicate: Auto-Initializing C# Lists I have a list of integers that has a
Possible Duplicate: C# - google translate I am looking for a web service or

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.