cartoframes.viz.map module¶
-
class
cartoframes.viz.map.
HTMLMap
¶ Bases:
object
-
set_content
(size, layers, bounds, viewport=None, basemap=None, default_legend=None, show_info=None, _carto_vl_path=None, _airship_path=None)¶
-
-
class
cartoframes.viz.map.
Map
(layers=None, basemap='DarkMatter', bounds=None, size=None, viewport=None, default_legend=False, show_info=None, **kwargs)¶ Bases:
object
Parameters: - layers (list of Layer-types) – List of layers. One or more of
Layer
. - basemap (str) –
- if a str, name of a CARTO vector basemap. One of positron,
voyager, or darkmatter from the
BaseMaps
class - if a dict, Mapbox or other style as the value of the style key. If a Mapbox style, the access token is the value of the token key.
- if a str, name of a CARTO vector basemap. One of positron,
voyager, or darkmatter from the
- bounds (dict or list) – a dict with east,`north`,`west`,`south` properties, or a list of floats in the following order: [west, south, east, north]. If not provided the bounds will be automatically calculated to fit all features.
- size (tuple of int) – a (width, height) pair for the size of the map. Default is (1024, 632)
- show_info (bool, optional) – Whether to display center and zoom information in the map or not. It is False by default.
Example
from cartoframes.auth import set_default_context from cartoframes.viz import Map, Layer set_default_context( base_url='https://your_user_name.carto.com', api_key='your api key' ) Map(Layer('table in your account'))
CARTO basemap style.
from cartoframes.auth import set_default_context from cartoframes.viz import Map, Layer, basemaps set_default_context( base_url='https://your_user_name.carto.com', api_key='your api key' ) Map( Layer('table in your account'), basemaps.darkmatter )
Custom basemap style. Here we use the Mapbox streets style, which requires an access token.
from cartoframes.auth import set_default_context from cartoframes.viz import Map, Layer, basemaps set_default_context( base_url='https://your_user_name.carto.com', api_key='your api key' ) basemap = { 'style': 'mapbox://styles/mapbox/streets-v9', 'token: '<your mapbox token>' } Map( Layer('table in your account'), basemap )
Color basemap style.
from cartoframes.auth import set_default_context from cartoframes.viz import Map, Layer, basemaps set_default_context( base_url='https://your_user_name.carto.com', api_key='your api key' ) Map( Layer('table in your account'), basemap='yellow' # None, False, 'white', 'rgb(255, 255, 0)' )
Custom bounds.
from cartoframes.auth import set_default_context from cartoframes.viz import Map, Layer set_default_context( base_url='https://your_user_name.carto.com', api_key='your api key' ) bounds = { 'west': -10, 'east': 10, 'north': -10, 'south': 10 } Map( Layer('table in your account'), bounds=bounds )
Show map center and zoom values
from cartoframes.auth import Context, set_default_context from cartoframes.viz import Map, Layer context = Context( base_url='https://your_user_name.carto.com', api_key='your api key' ) set_default_context(context) Map(Layer('table in your account'), show_info=True)
-
publish
()¶
- layers (list of Layer-types) – List of layers. One or more of