Right not an elegant solution but I still learning about Object
orientated programming language.

What I have done is made each one a new variable and separate
function.
Ie uni checkbox relates to the function uni shops relates to the shops
function

Not very efficient hence why I was looking at different ways.

var check = 0;
var checksh = 0
var checkpu =0;
var map;
var kml_uni = new GGeoXml("http://www.mu130.acres-air.co.uk/Maps/
univeristy.kml");
var kml_pub = new GGeoXml("http://www.mu130.acres-air.co.uk/Maps/
pub.kml");
var kml_shops = new GGeoXml("http://www.mu130.acres-air.co.uk/Maps/
shops.kml");
var kml_church = new GGeoXml("http://www.mu130.acres-air.co.uk/Maps/
church.kml");
var kml_health = new GGeoXml("http://www.mu130.acres-air.co.uk/Maps/
health.kml");
var kml_place = new GGeoXml("http://www.mu130.acres-air.co.uk/Maps/
place.kml");
 function initialize() {

  map = new GMap2(document.getElementById("map_canvas"));
   map.setCenter(new GLatLng(51.8951, -2.0699), 13);
   map.addControl(new GLargeMapControl());
   map.addControl(new GMapTypeControl());

 }
  function Univeristy(){
         if(check == 1){
                 map.removeOverlay(kml_uni)
   check = 0;
         }
         else {
                map.addOverlay(kml_uni)
                check = 1;
         }
  }

  function Shops(){
         if(checksh == 1){
                 map.removeOverlay(kml_shops)
   checksh = 0;
         }
         else {
                map.addOverlay(kml_shops)
                checksh = 1;
         }
  }
  function Pubs(){
         if(checkpu == 1){
                 map.removeOverlay(kml_pub)
   checkpu = 0;
         }
         else {
                map.addOverlay(kml_pub)
                checkpu = 1;
         }
  }


the results will be at this address

http://www.mu130.acres-air.co.uk/map.html

On Feb 23, 3:33 pm, Lance Dyas <[email protected]> wrote:
> Hint: You will need more than one variable (an array probably) if you want
> to be
> able to remove more than just the last one your added.
>
>
>
> On Tue, Feb 23, 2010 at 2: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:-
>
> > 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?? 
> > > > l=en<http://groups.google.com/group/google-maps-api?hl=en>
> > .- Hide quoted text -
>
> - Show quoted text -

-- 
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.

Reply via email to