On Feb 23, 12:39 am, Krad <[email protected]> wrote:
> Ok i have updated the API key and add the other tick boxes to work up
> to Pub and Bars. The bit that does not work is the map.remove
> Overlay(kml)
> where kml is the variable for the file url.
>
> I read the bit about global and if you remove var it becomes global to
> calls in the programm. So I tried that and nothing you tick and
> markers load you clikc the tick again and nothing. I have used
> firebug in Firefox to follow with the break points set and its doing
> the above steps on untick:-
You need to keep a _unique_ reference to each overlay so you can
remove it. I usually use an associative array, something like
(totally untested):
var kmlArray = [];
function toggleKml(file) {
var kmlCheckbox = document.getElementById(file).checked;
kmlArray[file] = new GGeoXml('http://www.mu130.acres-air.co.uk/Maps/'
+ file + '.kml');
if (kmlCheckbox)
map.addOverlay(kmlArray[file]);
else
map.removeOverlay(kmlArray[file]);
}
-- Larry
>
> PDL
>
> IF (checked) ---- false
> {
> load map kml overlay}
>
> else
> remove map kml overlay --- picks up the url with the file name been
> pased in via the onclick call.
>
> }
>
> I'v look at loads of examples and they have simlar to the above and
> they work? What am I doing wrong.
>
> On Feb 22, 11:21 pm, "[email protected]" <[email protected]>
> wrote:
>
> > On Feb 22, 12:58 pm, Krad <[email protected]> wrote:
>
> > > Hello,
>
> > > I'm having truble with the remove of a kml overlay when a checkbox is
> > > used can some one help?
>
> > >http://www.mu130.acres-air.co.uk/map2.html
>
> > I get a key error on that page, then a map
> > All the checkboxes except the first give errors because the functions
> > they call don't exist.
>
> > Removing the overlay generates an error because:
> > map.removeOverlay();
>
> > is not the correct
> > syntax.http://code.google.com/apis/maps/documentation/reference.html#GMap2.r...
>
> > removeOverlay takes an argument (the overlay you want to remove).
>
> > working example:http://www.geocodezip.com/GenericMapBrowser.asp
> > see the "addTrafficOverlay()" function.
>
> > -- Larry
>
> > > the code is this:-
>
> > No thanks.
>
> > > it loads the overlay just can't get it to remove?
>
> > > also would I get more problems with more overlays and the memeroy
> > > location of the kml??
--
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.