var mapObject = null;
var imgLayer_id = [
  'id_image',
  'id_image_label',
  'id_River_img',
  'id_river_label_img',
];
var terLayer_id = [
  'id_ter',
  'id_ter_label',
  'id_River_ter',
  'id_river_label_ter',
];
export function baseMapChangeHandler(map, val) {
  if (val == '影像') {
    for (var i = 0; i < imgLayer_id.length; i++) {
      var lyr = map.findLayerById(imgLayer_id[i]);
      if (lyr) {
        lyr.visible = true;
      }
    }
    for (var i = 0; i < terLayer_id.length; i++) {
      var lyr = map.findLayerById(terLayer_id[i]);
      if (lyr) {
        lyr.visible = false;
      }
    }
    var lyr1 = map.findLayerById('id_gaode');
    if (lyr1) {
      lyr1.visible = false;
    }
    var lyr2 = map.findLayerById('id_google');
    if (lyr2) {
      lyr2.visible = false;
    }
  } else if (val == '地形') {
    for (var i = 0; i < imgLayer_id.length; i++) {
      var lyr = map.findLayerById(imgLayer_id[i]);
      if (lyr) {
        lyr.visible = false;
      }
    }
    for (var i = 0; i < terLayer_id.length; i++) {
      var lyr = map.findLayerById(terLayer_id[i]);
      if (lyr) {
        lyr.visible = true;
      }
    }
    var lyr1 = map.findLayerById('id_gaode');
    if (lyr1) {
      lyr1.visible = false;
    }
    var lyr2 = map.findLayerById('id_google');
    if (lyr2) {
      lyr2.visible = false;
    }
  } else if (val == '高德') {
    for (var i = 0; i < imgLayer_id.length; i++) {
      var lyr = map.findLayerById(imgLayer_id[i]);
      if (lyr) {
        lyr.visible = false;
      }
    }
    for (var i = 0; i < terLayer_id.length; i++) {
      var lyr = map.findLayerById(terLayer_id[i]);
      if (lyr) {
        lyr.visible = false;
      }
    }
    var lyr1 = map.findLayerById('id_gaode');
    if (lyr1) {
      lyr1.visible = true;
    }
    var lyr2 = map.findLayerById('id_google');
    if (lyr2) {
      lyr2.visible = false;
    }
  } else if (val == '谷歌') {
    for (var i = 0; i < imgLayer_id.length; i++) {
      var lyr = map.findLayerById(imgLayer_id[i]);
      if (lyr) {
        lyr.visible = false;
      }
    }
    for (var i = 0; i < terLayer_id.length; i++) {
      var lyr = map.findLayerById(terLayer_id[i]);
      if (lyr) {
        lyr.visible = false;
      }
    }
    var lyr1 = map.findLayerById('id_gaode');
    if (lyr1) {
      lyr1.visible = false;
    }
    var lyr3 = map.findLayerById('id_image_label');
    if (lyr3) {
      lyr3.visible = true;
    }
    var lyr2 = map.findLayerById('id_google');
    if (lyr2) {
      lyr2.visible = true;
    }
  }
}
