Multiple map in GEE

Comparing the results of multiple analyses.

Use the script below or follow this link

function initMap(map) {
map.setCenter(106.15,21.25, 12);
}

// Initialize
initMap(Map);

// set image
var image = ee.Image("LANDSAT/LC8_L1T_TOA/LC81260452014268LGN00");

// function to create map 1
function createMap1() {
var map = new ui.Map();
map.addLayer(image.select(['B6','B5','B8']), {}, 'image');
var water = image.expression('(b(7)-b(4))/(b(7)+b(4)) > -0.05');
map.addLayer(water.mask(water), {palette:['3182bd']}, 'water');
map.add(ui.Label('Screen 1', {position:'bottom-center'}));
return map;
}

// function to create map 2
function createMap2() {
var map = new ui.Map();
map.addLayer(image.select(['B6','B5','B8']), {}, 'image');
var water = image.expression('(b(7)-b(4))/(b(7)+b(4)) > -0.05');
map.addLayer(water.mask(water), {palette:['f442f1']}, 'water');
map.add(ui.Label('Screen 2', {position:'bottom-center'}));
return map;
}

// function to create map 3
function createMap3() {
var map = new ui.Map();
map.addLayer(image.select(['B6','B5','B8']), {}, 'image');
var water = image.expression('(b(7)-b(4))/(b(7)+b(4)) > -0.05');
map.addLayer(water.mask(water), {palette:['fc071b']}, 'water');
map.add(ui.Label('Screen 3', {position:'bottom-center'}));
return map;
}

// add maps
function createMap(title) {
var map = ui.Map();
ui.Label(title, {position:'top-center'});
map.add(title);
return map;
}

function getMapSize() {
var scale = Map.getScale();
var bounds = ee.Geometry(Map.getBounds(true)).transform('EPSG:32648', scale).coordinates().get(0).getInfo();

var ll = bounds[0];
var ur = bounds[2];
var width = (ur[0] - ll[0]) / scale;
var height = (ur[1] - ll[1]) / scale;

return { w: Math.floor(width), h: Math.floor(height) };
}

var maps = [createMap1(), createMap2(), createMap3()];

var height = getMapSize().h;

// Create a panel with vertical flow layout.
var panel = ui.Panel({
layout: ui.Panel.Layout.flow('horizontal'),
style: {width: '100vw', height: height + 'px'}
});

var linker = ui.Map.Linker(maps)

maps.map(function(map) {
initMap(map)
map.setOptions('HYBRID')
panel.add(map)
})

ui.root.clear();

ui.root.add(panel);

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s