How to use the folium.TileLayer function in folium

To help you get started, we’ve selected a few folium examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github python-visualization / folium / tests / test_raster_layers.py View on Github external
def test_custom_tile_subdomains():
    """Test custom tile subdomains."""
    url = 'http://{s}.custom_tiles.org/{z}/{x}/{y}.png'
    m = folium.Map()
    folium.TileLayer(
        tiles=url,
        name='subdomains2',
        attr='attribution',
        subdomains='mytilesubdomain'
    ).add_to(m)
    out = m._parent.render()
    assert 'mytilesubdomain' in out
github python-visualization / folium / tests / test_raster_layers.py View on Github external
def test_tilelayer_api_key():
    """Test cloudmade tiles and the API key."""
    with pytest.raises(ValueError):
        folium.TileLayer(tiles='cloudmade')

    tile_layer = folium.TileLayer(tiles='cloudmade', API_key='###')
    cloudmade = 'http://{s}.tile.cloudmade.com/###/997/256/{z}/{x}/{y}.png'
    assert tile_layer.tiles == cloudmade
github microsoft / msticpy / msticpy / nbtools / foliummap.py View on Github external
Custom set of tiles or tile URL (the default is None)
        width : str, optional
            Map display width (the default is '100%')
        height : str, optional
            Map display height (the default is '100%')

        Attributes
        ----------
        folium_map : folium.Map
            The map object.

        """
        self.folium_map = folium.Map(
            zoom_start=zoom_start, tiles=tiles, width=width, height=height
        )
        folium.TileLayer(name=title).add_to(self.folium_map)
github akkana / scripts / mapping / polidistmap.py View on Github external
def create_map(lat, lon, label, infile, fieldname):
    '''Create a map and write it to index.html
    '''
    jsonfile = infile

    m = folium.Map(location=[lat, lon], zoom_start=7)

    # Add some alternate tile layers
    folium.TileLayer('Stamen Terrain').add_to(m)
    folium.TileLayer('Stamen Toner').add_to(m)

    def style_fcn(x):
        '''The style function can key off x['properties']['NAME10']
           which will be strings like 'Senate District 42'
           but for now, let's just return random colors.
        '''
        return { 'fillColor': random_html_color() }

    def highlight_fcn(x):
        return { 'fillColor': '#ff0000' }

    gj = folium.GeoJson(jsonfile,
                        name="State %s Boundaries" % label,
                        tooltip=folium.GeoJsonTooltip(
                            fields=[fieldname],
github SanPen / GridCal / src / GridCal / Engine / Visualization / visualization.py View on Github external
def get_base_map(location, zoom_start=5):
    """
    Get map with all the base defined layers
    :param location: (lat, lon)
    :param zoom_start: integer
    :return: map, marker_layer
    """

    my_map = folium.Map(location=location, zoom_start=zoom_start)

    # add possible tiles
    folium.TileLayer('cartodbpositron').add_to(my_map)
    folium.TileLayer('cartodbdark_matter').add_to(my_map)
    folium.TileLayer('openstreetmap').add_to(my_map)
    folium.TileLayer('Mapbox Bright').add_to(my_map)
    folium.TileLayer('stamentoner').add_to(my_map)

    # add markers layer
    marker_cluster = MarkerCluster().add_to(my_map)

    # add the layer control
    folium.LayerControl().add_to(my_map)

    return my_map, marker_cluster
github akkana / scripts / mapping / polidistmap.py View on Github external
def create_map(lat, lon, label, infile, fieldname):
    '''Create a map and write it to index.html
    '''
    jsonfile = infile

    m = folium.Map(location=[lat, lon], zoom_start=7)

    # Add some alternate tile layers
    folium.TileLayer('Stamen Terrain').add_to(m)
    folium.TileLayer('Stamen Toner').add_to(m)

    def style_fcn(x):
        '''The style function can key off x['properties']['NAME10']
           which will be strings like 'Senate District 42'
           but for now, let's just return random colors.
        '''
        return { 'fillColor': random_html_color() }

    def highlight_fcn(x):
        return { 'fillColor': '#ff0000' }

    gj = folium.GeoJson(jsonfile,
                        name="State %s Boundaries" % label,
                        tooltip=folium.GeoJsonTooltip(
                            fields=[fieldname],
github SanPen / GridCal / src / GridCal / Engine / Visualization / visualization.py View on Github external
def get_base_map(location, zoom_start=5):
    """
    Get map with all the base defined layers
    :param location: (lat, lon)
    :param zoom_start: integer
    :return: map, marker_layer
    """

    my_map = folium.Map(location=location, zoom_start=zoom_start)

    # add possible tiles
    folium.TileLayer('cartodbpositron').add_to(my_map)
    folium.TileLayer('cartodbdark_matter').add_to(my_map)
    folium.TileLayer('openstreetmap').add_to(my_map)
    folium.TileLayer('Mapbox Bright').add_to(my_map)
    folium.TileLayer('stamentoner').add_to(my_map)

    # add markers layer
    marker_cluster = MarkerCluster().add_to(my_map)

    # add the layer control
    folium.LayerControl().add_to(my_map)

    return my_map, marker_cluster