Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #27149
| From | Richard Maher <maher_rjSPAMLESS@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.javascript |
| Subject | Re: javascript loop problem |
| Date | 2015-04-01 10:49 +0800 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <mffmbc$fs1$1@speranza.aioe.org> (permalink) |
| References | <8f8b8bbd-fed1-4871-b3e4-e0b96abd3692@googlegroups.com> |
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
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