Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #27149

Re: javascript loop problem

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!aioe.org!.POSTED!not-for-mail
From Richard Maher <maher_rjSPAMLESS@hotmail.com>
Newsgroups comp.lang.javascript
Subject Re: javascript loop problem
Date Wed, 01 Apr 2015 10:49:12 +0800
Organization Aioe.org NNTP Server
Lines 39
Message-ID <mffmbc$fs1$1@speranza.aioe.org> (permalink)
References <8f8b8bbd-fed1-4871-b3e4-e0b96abd3692@googlegroups.com>
NNTP-Posting-Host uYFkdLFMFILrcerhBCvdBA.user.speranza.aioe.org
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
X-Complaints-To abuse@aioe.org
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:31.0) Gecko/20100101 Thunderbird/31.5.0
X-Notice Filtered by postfilter v. 0.8.2
Xref csiph.com comp.lang.javascript:27149

Show key headers only | View raw


On 4/1/2015 10:05 AM, chrisb@ctlsoft.com wrote:
> little script which adds map markers to the appropriate locations with a label.
> The array 'myaddresses' contain the locations to mark on the map and the numbers to put on the labels.
> Works fine for the location bit, but the labels all show the last count (35).
>
> So the line labelContent: myaddresses[x][1] always seems to return the final array element for some reason.
>
> Any ideas greatly appreciated!

1) Stop using that jQuery shit!!!

2) Load the maps with 		
         google.load('maps', '3', {
             'other_params' :
             'sensor=true&language=' + params.lang,
			'callback' : mapsLoaded
         });

3) What the hell is MarkerWithLabel and where does it com from?

4) FWIW, InfoWindow.setContent() does not render the change a(nother) 
InfoWindow.Open() is needed to see the results.

5) Use InfoBubble instead!!!

6) Don't know what that crap getJSON does but I'm guessing you're 
specifying a callback that fires after the loop (once for each of your 
calls. Javascript is single-threaded. Have to leave your function to 
allow further events in). "X" has it's last value.

7) You need a closure (actually a redesign but . . .) use function(inCntr){
var x = inCntr;
function(){
// your function referencing x
}
}(x);

8) I lived in Wellington and Christchurch for 18 months. Shame about 
CHCH :-(

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

javascript loop problem chrisb@ctlsoft.com - 2015-03-31 19:05 -0700
  Re: javascript loop problem Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2015-04-01 10:49 +0800
  Re: javascript loop problem "Christoph M. Becker" <cmbecker69@arcor.de> - 2015-04-01 14:42 +0200
  Re: javascript loop problem Denis McMahon <denismfmcmahon@gmail.com> - 2015-04-01 14:43 +0000

csiph-web