/**** Start of imports. If edited, may not auto-convert in the playground. ****/
var lead_tree_species = ee.Image("projects/sat-io/open-datasets/CA_FOREST/LEAD_TREE_SPECIES");
/***** End of imports. If edited, may not auto-convert in the playground. *****/
// Define a dictionary which will be used to make legend and visualize image on map
var dict = {
  "names": [
    "Non Tree",
    "Amabilis fir",
    "Balsam fir",
    "Subalpine fir",
    "Bigleaf maple",
    "Red maple",
    "Sugar maple",
    "Gray alder",
    "Red alder",
    "Yellow birch",
    "White birch",
    "Yellow-cedar",
    "Black ash",
    "Tamarack",
    "Western larch",
    "Norway spruce",
    "Engelmann spruce",
    "White spruce",
    "Black spruce",
    "Red spruce",
    "Sitka spruce",
    "Whitebark pine",
    "Jack pine",
    "Lodgepole pine",
    "Ponderosa pine",
    "Red pine",
    "Eastern white pine",
    "Balsam poplar",
    "Largetooth aspen",
    "Trembling aspen",
    "Douglas-fir",
    "Red oak",
    "Eastern white-cedar",
    "Western redcedar",
    "Eastern hemlock",
    "Western hemlock",
    "Mountain hemlock",
    "White elm",

  ],
  "colors": [
    "#000000",
    "#fef2ec",
    "#fff2c7",
    "#ffedb3",
    "#fdb462",
    "#fdbf6f",
    "#fca773",
    "#e3b9db",
    "#d6aad3",
    "#fb8069",
    "#fb9a85",
    "#ae027e",
    "#808080",
    "#e5b75a",
    "#e5c468",
    "#b3de53",
    "#f2fa8c",
    "#e6f47f",
    "#d9ef74",
    "#cce968",
    "#bfe35d",
    "#d9f1f7",
    "#bfe7f1",
    "#b3e2e3",
    "#99cee3",
    "#80c5dd",
    "#4eb3d3",
    "#68d094",
    "#66c092",
    "#33a97e",
    "#faa7c8",
    "#f668b2",
    "#e38776",
    "#e36f5c",
    "#bfc26b",
    "#a6b96c",
    "#8cb06c",
    "#99c2b5",

  ]};

Map.setCenter(-97.61655457157725,55.6280720462063,4)

// Add image to the map
Map.addLayer(lead_tree_species, {min:0, max:37, palette:dict['colors']}, 'CA Lead Tree Species')
/////////////////////////////////////////////////////////////////////////
var legend = ui.Panel({
  style: {
    position: 'middle-right',
    padding: '8px 15px'
  }
});

// Create and add the legend title.
var legendTitle = ui.Label({
  value: 'CA Lead Tree Species',
  style: {
    fontWeight: 'bold',
    fontSize: '18px',
    margin: '0 0 4px 0',
    padding: '0'
  }
});
legend.add(legendTitle);

var loading = ui.Label('Loading legend...', {margin: '2px 0 4px 0'});
legend.add(loading);

  // Creates and styles 1 row of the legend.
  var makeRow = function(color, name) {
    // Create the label that is actually the colored box.
    var colorBox = ui.Label({
      style: {
        backgroundColor: color,
        // Use padding to give the box height and width.
        padding: '8px',
        margin: '0 0 4px 0'
      }
    });

  // Create the label filled with the description text.
  var description = ui.Label({
    value: name,
    style: {margin: '0 0 4px 6px'}
  });

  return ui.Panel({
    widgets: [colorBox, description],
    layout: ui.Panel.Layout.Flow('horizontal')
  });
};
  var palette = dict['colors'];
  var names = dict['names'];
  loading.style().set('shown', false);

  for (var i = 0; i < names.length; i++) {
    legend.add(makeRow(palette[i], names[i]));
  }

// Print the panel containing the legend
print(legend);

var Dark
 = 
[
  {
    "featureType": "all",
    "elementType": "labels",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  },
  {
    "featureType": "all",
    "elementType": "labels.text",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  },
  {
    "featureType": "all",
    "elementType": "labels.text.fill",
    "stylers": [
      {
        "saturation": 36
      },
      {
        "color": "#000000"
      },
      {
        "lightness": 40
      }
    ]
  },
  {
    "featureType": "all",
    "elementType": "labels.text.stroke",
    "stylers": [
      {
        "visibility": "on"
      },
      {
        "color": "#000000"
      },
      {
        "lightness": 16
      }
    ]
  },
  {
    "featureType": "all",
    "elementType": "labels.icon",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  },
  {
    "featureType": "administrative",
    "elementType": "geometry",
    "stylers": [
      {
        "visibility": "on"
      }
    ]
  },
  {
    "featureType": "administrative",
    "elementType": "geometry.fill",
    "stylers": [
      {
        "color": "#000000"
      },
      {
        "lightness": 20
      }
    ]
  },
  {
    "featureType": "administrative",
    "elementType": "geometry.stroke",
    "stylers": [
      {
        "color": "#000000"
      },
      {
        "lightness": 17
      },
      {
        "weight": 1.2
      }
    ]
  },
  {
    "featureType": "administrative",
    "elementType": "labels",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  },
  {
    "featureType": "administrative",
    "elementType": "labels.text",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  },
  {
    "featureType": "landscape",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#000000"
      },
      {
        "lightness": 20
      }
    ]
  },
  {
    "featureType": "landscape",
    "elementType": "labels.text",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  },
  {
    "featureType": "poi",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#000000"
      },
      {
        "lightness": 21
      }
    ]
  },
  {
    "featureType": "poi",
    "elementType": "labels.text",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  },
  {
    "featureType": "road",
    "elementType": "geometry.fill",
    "stylers": [
      {
        "visibility": "simplified"
      },
      {
        "color": "#8a4040"
      }
    ]
  },
  {
    "featureType": "road",
    "elementType": "geometry.stroke",
    "stylers": [
      {
        "visibility": "on"
      },
      {
        "color": "#ffffff"
      }
    ]
  },
  {
    "featureType": "road",
    "elementType": "labels.text",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  },
  {
    "featureType": "road.highway",
    "elementType": "geometry.fill",
    "stylers": [
      {
        "color": "#000000"
      },
      {
        "lightness": 17
      }
    ]
  },
  {
    "featureType": "road.highway",
    "elementType": "geometry.stroke",
    "stylers": [
      {
        "color": "#000000"
      },
      {
        "lightness": 29
      },
      {
        "weight": 0.2
      }
    ]
  },
  {
    "featureType": "road.arterial",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#000000"
      },
      {
        "lightness": 18
      }
    ]
  },
  {
    "featureType": "road.arterial",
    "elementType": "geometry.fill",
    "stylers": [
      {
        "color": "#ffffff"
      },
      {
        "visibility": "on"
      }
    ]
  },
  {
    "featureType": "road.local",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#000000"
      },
      {
        "lightness": 16
      }
    ]
  },
  {
    "featureType": "road.local",
    "elementType": "geometry.fill",
    "stylers": [
      {
        "visibility": "on"
      },
      {
        "color": "#faf2f2"
      }
    ]
  },
  {
    "featureType": "transit",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#000000"
      },
      {
        "lightness": 19
      }
    ]
  },
  {
    "featureType": "transit",
    "elementType": "labels",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  },
  {
    "featureType": "transit",
    "elementType": "labels.text",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  },
  {
    "featureType": "water",
    "elementType": "geometry",
    "stylers": [
      {
        "color": "#b4bcc2"
      },
      {
        "lightness": 17
      }
    ]
  },
  {
    "featureType": "water",
    "elementType": "labels",
    "stylers": [
      {
        "visibility": "on"
      }
    ]
  },
  {
    "featureType": "water",
    "elementType": "labels.text",
    "stylers": [
      {
        "visibility": "off"
      }
    ]
  }
]
Map.setOptions('Dark', {Dark
: Dark
})