Layout viewport

Use the Layout class to create a variety of map views for comparison.

For more information, run help(Layout).

The first example sets a common viewport for all maps while the second sets two different viewports for maps.


In [1]:
from cartoframes.auth import set_default_credentials
from cartoframes.viz import Map, Layer, Layout, basic_style

set_default_credentials('cartoframes')

Same viewport


In [2]:
Layout([
    Map(Layer('select * from drought_wk_1 where dm = 3', basic_style(color='#e15383'))),
    Map(Layer('select * from drought_wk_2 where dm = 3', basic_style(color='#e15383'))),
    Map(Layer('select * from drought_wk_3 where dm = 3', basic_style(color='#e15383'))),
    Map(Layer('select * from drought_wk_4 where dm = 3', basic_style(color='#e15383'))),
], is_static=True, viewport={'zoom': 3, 'lat': 33.4706, 'lng': -98.3457})


Out[2]:
:
StackTrace
    ">

     Different viewports

    
    
    In [3]:
    Layout([
        Map(Layer('drought_wk_1'), viewport={ 'zoom': 0.5 }),
        Map(Layer('select * from drought_wk_1 where dm = 1', basic_style(color='#ffc285'))),
        Map(Layer('select * from drought_wk_1 where dm = 2', basic_style(color='#fa8a76'))),
        Map(Layer('select * from drought_wk_1 where dm = 3', basic_style(color='#e15383'))),
    ], is_static=True, viewport={'zoom': 3, 'lat': 33.4706, 'lng': -98.3457})
    
    
    
    
    Out[3]:
    :
    StackTrace
      ">