Add Multiple Layers

In this example, three Layers are added to a Map. Notice the draw order and default symbology for each.

For more information, run help(Layer)


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

set_default_credentials('cartoframes')

In [2]:
Map([
    Layer('countries'),
    Layer('global_power_plants'),
    Layer('world_rivers')
])


Out[2]:
:
StackTrace
    ">

    Using default legends

    
    
    In [3]:
    from cartoframes.viz import default_legend
    
    Map([
        Layer('countries', legends=default_legend('Countries')),
        Layer('global_power_plants', legends=default_legend('Global Power Plants')),
        Layer('world_rivers', legends=default_legend('World Rivers'))
    ])
    
    
    
    
    Out[3]:
    :
    StackTrace
      ">

      Adding a Layer Selector

      
      
      In [4]:
      from cartoframes.viz import default_legend
      
      Map([
          Layer('countries', title='Countries', legends=default_legend()),
          Layer('global_power_plants', title='Global Power Plants', legends=default_legend()),
          Layer('world_rivers', title='World Rivers', legends=default_legend())
      ], layer_selector=True)
      
      
      
      
      Out[4]:
      :
      StackTrace
        ">