[thelist] Googlemap script

Chris Price chris.price at choctaw.co.uk
Thu Mar 29 07:24:42 CDT 2012


I've written a script for generating a Google map with several markers,
each with their own location, description and directions.

It works up to the point where I click on a marker to bring up the bubble
with its specific text. The problem is it always shows the last bubble in
my array whichever marker I click.

I know the problem is that its picking up the last variable in a for next
loop but I can't figure out the solution.

I've created a window.map object in another script to generate my variables.

Can anyone shed some light on this please. Script follows:


addLoadEvent(function() {
if ((document.getElementById(window.map.mapid))) {
var myOptions = {
zoom: window.map.zoom,
    center: new
    mapTypeId: google.maps.MapTypeId.ROADMAP
var myMap = new

function setMarkers(map,locations) {
 var shadow = new google.maps.MarkerImage(
new google.maps.Size(window.map.shadowsize[0],window.map.shadowsize[1]),
new google.maps.Point(0,0),

for (var i = 0; i < locations.length; i++) {

var location = window.map.location[i]
 var image = new google.maps.MarkerImage(
new google.maps.Size(window.map.iconsize[0],window.map.iconsize[1]),
      new google.maps.Point(0,0),
 var infowindow = new google.maps.InfoWindow({ content:
window.map.bubbletext[i] });
 var myLoc = locations[i];
var myLatLng = new google.maps.LatLng(myLoc[1], myLoc[2]);
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
shadow: shadow,
icon: image,
title: myLoc[0],
zIndex: myLoc[3]
 google.maps.event.addListener(marker, 'click', function() {
infowindow.open(map,marker); });


@Choctaw.co.uk <http:\\choctaw.co.uk>
0777 629 0227

Design is my native language

Choctaw Media Ltd is a company registered in England and Wales (04627649)

More information about the thelist mailing list