LegacyMap

class folium.map.LegacyMap(location=None, width='100%', height='100%', left='0%', top='0%', position='relative', tiles='OpenStreetMap', API_key=None, max_zoom=18, min_zoom=1, zoom_start=10, attr=None, min_lat=-90, max_lat=90, min_lon=-180, max_lon=180, detect_retina=False, crs='EPSG3857')

Create a Map with Folium and Leaflet.js

Generate a base map of given width and height with either default tilesets or a custom tileset URL. The following tilesets are built-in to Folium. Pass any of the following to the “tiles” keyword:

  • “OpenStreetMap”
  • “MapQuest Open”
  • “MapQuest Open Aerial”
  • “Mapbox Bright” (Limited levels of zoom for free tiles)
  • “Mapbox Control Room” (Limited levels of zoom for free tiles)
  • “Stamen” (Terrain, Toner, and Watercolor)
  • “Cloudmade” (Must pass API key)
  • “Mapbox” (Must pass API key)
  • “CartoDB” (positron and dark_matter)

You can pass a custom tileset to Folium by passing a Leaflet-style URL to the tiles parameter: http://{s}.yourtiles.com/{z}/{x}/{y}.png

Parameters:
  • location (tuple or list, default None) – Latitude and Longitude of Map (Northing, Easting).
  • width (pixel int or percentage string (default: '100%')) – Width of the map.
  • height (pixel int or percentage string (default: '100%')) – Height of the map.
  • tiles (str, default 'OpenStreetMap') – Map tileset to use. Can choose from a list of built-in tiles, pass a custom URL or pass None to create a map without tiles.
  • API_key (str, default None) – API key for Cloudmade or Mapbox tiles.
  • max_zoom (int, default 18) – Maximum zoom depth for the map.
  • zoom_start (int, default 10) – Initial zoom level for the map.
  • attr (string, default None) – Map tile attribution; only required if passing custom tile URL.
  • detect_retina (bool, default False) – If true and user is on a retina display, it will request four tiles of half the specified size and a bigger zoom level in place of one to utilize the high resolution.
  • crs (str, default 'EPSG3857') – Defines coordinate reference systems for projecting geographical points into pixel (screen) coordinates and back. You can use Leaflet’s values : * EPSG3857 : The most common CRS for online maps, used by almost all free and commercial tile providers. Uses Spherical Mercator projection. Set in by default in Map’s crs option. * EPSG4326 : A common CRS among GIS enthusiasts. Uses simple Equirectangular projection. * EPSG3395 : Rarely used by some commercial tile providers. Uses Elliptical Mercator projection. * Simple : A simple CRS that maps longitude and latitude into x and y directly. May be used for maps of flat surfaces (e.g. game maps). Note that the y axis should still be inverted (going from bottom to top).
Returns:

Return type:

Folium LegacyMap Object

Examples

>>> map = folium.LegacyMap(location=[45.523, -122.675], width=750, height=500)
>>> map = folium.LegacyMap(location=[45.523, -122.675],
                           tiles='Mapbox Control Room')
>>> map = folium.LegacyMap(location=(45.523, -122.675), max_zoom=20,
                           tiles='Cloudmade', API_key='YourKey')
>>> map = folium.LegacyMap(location=[45.523, -122.675], zoom_start=2,
                           tiles=('http://{s}.tiles.mapbox.com/v3/'
                                  'mapbox.control-room/{z}/{x}/{y}.png'),
                            attr='Mapbox attribution')
add_tile_layer(tiles='OpenStreetMap', name=None, API_key=None, max_zoom=18, min_zoom=1, attr=None, tile_name=None, tile_url=None, active=False, detect_retina=False, **kwargs)

TODO: docstring.

Layer

class folium.map.Layer(name=None, overlay=False, control=True)

An abstract class for everything that is a Layer on the map. It will be used to define whether an object will be included in LayerControls.

Parameters:
  • name (string, default None) – The name of the Layer, as it will appear in LayerControls
  • overlay (bool, default False) – Adds the layer as an optional overlay (True) or the base layer (False).
  • control (bool, default True) – Whether the Layer will be included in LayerControls.

TileLayer

class folium.map.TileLayer(tiles='OpenStreetMap', min_zoom=1, max_zoom=18, attr=None, API_key=None, detect_retina=False, name=None, overlay=False, control=True)

Create a tile layer to append on a Map.

Parameters:
  • tiles (str, default 'OpenStreetMap') –
    Map tileset to use. Can choose from this list of built-in tiles:
    • “OpenStreetMap”
    • “MapQuest Open”
    • “MapQuest Open Aerial”
    • “Mapbox Bright” (Limited levels of zoom for free tiles)
    • “Mapbox Control Room” (Limited levels of zoom for free tiles)
    • “Stamen” (Terrain, Toner, and Watercolor)
    • “Cloudmade” (Must pass API key)
    • “Mapbox” (Must pass API key)
    • “CartoDB” (positron and dark_matter)

    You can pass a custom tileset to Folium by passing a Leaflet-style URL to the tiles parameter: http://{s}.yourtiles.com/{z}/{x}/{y}.png

  • min_zoom (int, default 1) – Minimal zoom for which the layer will be displayed.
  • max_zoom (int, default 18) – Maximal zoom for which the layer will be displayed.
  • attr (string, default None) – Map tile attribution; only required if passing custom tile URL.
  • API_key (str, default None) – API key for Cloudmade or Mapbox tiles.
  • detect_retina (bool, default False) – If true and user is on a retina display, it will request four tiles of half the specified size and a bigger zoom level in place of one to utilize the high resolution.
  • name (string, default None) – The name of the Layer, as it will appear in LayerControls
  • overlay (bool, default False) – Adds the layer as an optional overlay (True) or the base layer (False).
  • control (bool, default True) – Whether the Layer will be included in LayerControls.

FeatureGroup

class folium.map.FeatureGroup(name=None, overlay=True, control=True)

Create a FeatureGroup layer ; you can put things in it and handle them as a single layer. For example, you can add a LayerControl to tick/untick the whole group.

Parameters:
  • name (str, default None) – The name of the featureGroup layer. It will be displayed in the LayerControl. If None get_name() will be called to get the technical (ugly) name.
  • overlay (bool, default True) – Whether your layer will be an overlay (ticked with a check box in LayerControls) or a base layer (ticked with a radio button).

LayerControl

class folium.map.LayerControl

Creates a LayerControl object to be added on a folium map.

render(**kwargs)

Renders the HTML representation of the element.

Icon

class folium.map.Icon(color='blue', icon_color='white', icon='info-sign', angle=0, prefix='glyphicon')

Creates an Icon object that will be rendered using Leaflet.awesome-markers.

Parameters:
  • color (str, default 'blue') –

    The color of the marker. You can use:

    [‘red’, ‘blue’, ‘green’, ‘purple’, ‘orange’, ‘darkred’,
    ‘lightred’, ‘beige’, ‘darkblue’, ‘darkgreen’, ‘cadetblue’, ‘darkpurple’, ‘white’, ‘pink’, ‘lightblue’, ‘lightgreen’, ‘gray’, ‘black’, ‘lightgray’]
  • icon_color (str, default 'white') – The color of the drawing on the marker. You can use colors above, or an html color code.
  • icon (str, default 'info-sign') – The name of the marker sign. See Font-Awesome website to choose yours. Warning : depending on the icon you choose you may need to adapt the prefix as well.
  • angle (int, default 0) – The icon will be rotated by this amount of degrees.
  • prefix (str, default 'glyphicon') – The prefix states the source of the icon. ‘fa’ for font-awesome or ‘glyphicon’ for bootstrap 3.
  • more details see (For) –
  • https (//github.com/lvoogdt/Leaflet.awesome-markers) –

Marker

class folium.map.Marker(location, popup=None, icon=None)

Create a simple stock Leaflet marker on the map, with optional popup text or Vincent visualization.

Parameters:
  • location (tuple or list, default None) – Latitude and Longitude of Marker (Northing, Easting)
  • popup (string or folium.Popup, default None) – Input text or visualization for object.
  • icon (Icon plugin) – the Icon plugin to use to render the marker.
Returns:

Return type:

Marker names and HTML in obj.template_vars

Examples

>>> Marker(location=[45.5, -122.3], popup='Portland, OR')
>>> Marker(location=[45.5, -122.3], popup=folium.Popup('Portland, OR'))

FitBounds

class folium.map.FitBounds(bounds, padding_top_left=None, padding_bottom_right=None, padding=None, max_zoom=None)

Fit the map to contain a bounding box with the maximum zoom level possible.

Parameters:
  • bounds (list of (latitude, longitude) points) – Bounding box specified as two points [southwest, northeast]
  • padding_top_left ((x, y) point, default None) – Padding in the top left corner. Useful if some elements in the corner, such as controls, might obscure objects you’re zooming to.
  • padding_bottom_right ((x, y) point, default None) – Padding in the bottom right corner.
  • padding ((x, y) point, default None) – Equivalent to setting both top left and bottom right padding to the same value.
  • max_zoom (int, default None) – Maximum zoom to be used.