Gmap3 - Forum

Gmap3 exchange platform

You are not logged in.

Ads
(server costs 27.50€ per month)

#1 2011-11-24 12:08:20

ingegnis
Member
Registered: 2011-11-24
Posts: 1

reg.expr. on tag value

Hello, I refer to the example:

$('#test').gmap3(
  { action: 'addKmlLayer',
    url: 'http://www.gmap3.net/kml/rungis.kml',
    options:{
      suppressInfoWindows: true
    },
    tag:'chk1'
  },
  { action: 'addKmlLayer',          
    url: 'http://www.gmap3.net/kml/sogaris.kml',
    options:{
      suppressInfoWindows: true
    },
    tag:'chk2'
  }
);

$('.tools input[type=checkbox]').change(function(){
  var map = $('#test').gmap3('get'),
      kml = $('#test').gmap3({
        action:'get',
        name:'kmllayer',
        tag: $(this).attr('id')
      });
  kml.setMap( $(this).is(':checked') ? map : null );
});

if I have a lot of kml tags that have a part of the same,
I can hide
with a unique ceckbox?

I would like to group files into "levels", each ceckbox show / hide ALL the kml that level...

action:'get',
name:'kmllayer',
tag: jQuery(this).attr('id')+ String
$('#test').gmap3(
  { action: 'addKmlLayer',
    url: 'http://www.gmap3.net/kml/rungis.kml',
    options:{
      suppressInfoWindows: true
    },
    tag:'chk1_a'
  },
  { action: 'addKmlLayer',          
    url: 'http://www.gmap3.net/kml/sogaris.kml',
    options:{
      suppressInfoWindows: true
    },
    tag:'chk1_b'
  }
{ action: 'addKmlLayer',          
    url: 'http://www.gmap3.net/kml/xxxx.kml',
    options:{
      suppressInfoWindows: true
    },
    tag:'chk2'
  }
);

$('.tools input[type=checkbox]').change(function(){
  var map = $('#test').gmap3('get'),
      kml = $('#test').gmap3({
        action:'get',
        name:'kmllayer',
        tag: $(this).attr('id')  <-- ?????
      });
  kml.setMap( $(this).is(':checked') ? map : null );
});

Offline

Ads
(server costs 27.50€ per month)

#2 2011-11-24 16:54:31

charlietfl
Moderator
Registered: 2011-11-24
Posts: 201

Re: reg.expr. on tag value

declare your id outside of the gmap3 object where your "this" will refer to the input

$('.tools input[type=checkbox]').change(function(){
  var id=this.id
  var map = $('#test').gmap3('get'),
      kml = $('#test').gmap3({
        action:'get',
        name:'kmllayer',
        tag: id
      });
  kml.setMap( $(this).is(':checked') ? map : null );
});

Offline

Board footer

Powered by FluxBB