You need to keep a global reference to the polylines when you create
them.
Add:
var gpolylines = []; // global
Replace:
map.addOverlay(new GPolyline(pts,colour,width));
With:
var poly = new GPolyline(pts,colour,width);
map.addOverlay(poly);
poly.hide();
gpolylines.push(poly);
Add:
function boxclick(box,n) {
if (box.checked) {
gpolyline[parseInt(n) - 1].show();
} else {
gpolyline[parseInt(n) - 1].hide();
}
}
Some browsers (e.g. Firefox) remember the .checked state of the
checkboxes when the page is reloaded. You can fix that by unchecking the
boxes from Javascript.
document.getElementById("001box").checked = false;
document.getElementById("002box").checked = false;
Actually, "id" attributes should start with a letter, not a number, so
it would be better to write
<input type="checkbox" id="box001"
and since you need the parameter as a number, it's easier to pass the
actual number than convert it and subtract 1 in boxclick()
<input type="checkbox" id="box001" onclick="boxclick(this,0)" >
--
http://econym.org.uk/gmap
The Blackpool Community Church Javascript Team
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---