1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| var oData = [
{
'url': 'http://forumdubateau.com/guide/kml/mouillag.kml',
'tag': 'chk1'
},
{
'url': 'http://forumdubateau.com/guide/kml/ports.kml',
'tag': 'chk2'
},
{
'url': 'http://forumdubateau.com/guide/kml/carburants.kml',
'tag': 'chk3'
},
{
'url': 'http://forumdubateau.com/guide/kml/chantier.kml',
'tag': 'chk4'
},
{
'url': 'http://forumdubateau.com/guide/kml/restaurant.kml',
'tag': 'chk5'
},
{
'url': 'http://forumdubateau.com/guide/kml/commerce.kml',
'tag': 'chk6'
},
{
'url': 'http://forumdubateau.com/guide/kml/pointsremarquable.kml',
'tag': 'chk7'
}
];
// création de la carte
var oMap = new google.maps.Map(document.getElementById( 'div_map'),{
'zoom' : 6,
'center' : new google.maps.LatLng(42.80184957552014, 8.701172187499985),
'backgroundColor' : '#fff',
'streetViewControl' : false,
'zoomControlOptions' : {
'style' : google.maps.ZoomControlStyle.SMALL
},
'mapTypeId': google.maps.MapTypeId.TERRAIN,
});
// affectation de la fonction affichage oui/non
var tKML = [], oCheck;
var i, nb = oData.length;
for( i=0; i < nb; i++){
oCheck = document.getElementById( oData[i].tag);
if( oCheck){
oCheck.value = oData[i].url;
oCheck.onclick = function(){
showKml(this);
};
oCheck.checked = true;
showKml( oCheck);
}
}
function showHideAll( flag){
for( i in tKML){
tKML[i].check.checked = flag;
showKml( tKML[i].check);
}
}
function showKml( obj){
if( !tKML[ obj.id]){
tKML[obj.id] = {};
tKML[obj.id].kml = new google.maps.KmlLayer( obj.value, {preserveViewport:true});
tKML[obj.id].check = obj;
}
tKML[obj.id].kml.setMap( obj.checked ? oMap :null);
}
var oBtn = document.getElementById('btn_hide');
oBtn.onclick = function(){
showHideAll( false);
};
oBtn = document.getElementById('btn_show');
oBtn.onclick = function(){
showHideAll( true);
}; |
Partager