Ejemplo n.º 1
0
def test_scroll_zoom_toggler():
    m = folium.Map([45., 3.], zoom_start=4)
    szt = plugins.ScrollZoomToggler()
    m.add_child(szt)
    m._repr_html_()

    out = m._parent.render()

    # Verify that the div has been created.
    tmpl = Template("""
        <img id="{{this.get_name()}}" alt="scroll"
        src="https://cdnjs.cloudflare.com/ajax/libs/ionicons/2.0.1/png/512/arrow-move.png"
        style="z-index: 999999"
        onclick="{{this._parent.get_name()}}.toggleScroll()"></img>
    """)
    assert ''.join(tmpl.render(this=szt).split()) in ''.join(out.split())

    # Verify that the style has been created
    tmpl = Template("""
        <style>
            #{{this.get_name()}} {
                position:absolute;
                width:35px;
                bottom:10px;
                height:35px;
                left:10px;
                background-color:#fff;
                text-align:center;
                line-height:35px;
                vertical-align: middle;
                }
        </style>
    """)
    assert ''.join(tmpl.render(this=szt).split()) in ''.join(out.split())

    # Verify that the script is okay.
    tmpl = Template("""
        {{this._parent.get_name()}}.scrollEnabled = true;

        {{this._parent.get_name()}}.toggleScroll = function() {
            if (this.scrollEnabled) {
                this.scrollEnabled = false;
                this.scrollWheelZoom.disable();
                }
            else {
                this.scrollEnabled = true;
                this.scrollWheelZoom.enable();
                }
            };

        {{this._parent.get_name()}}.toggleScroll();
    """)
    assert ''.join(tmpl.render(this=szt).split()) in ''.join(out.split())

    bounds = m.get_bounds()
    assert bounds == [[None, None], [None, None]], bounds
Ejemplo n.º 2
0
def create_swiss_map(df: pd.DataFrame, column: str) -> folium.Map:
    """
    create a map of switzerland
    """

    m = folium.Map([46.8734, 8.2200], zoom_start=8)
    plugins.ScrollZoomToggler().add_to(m)
    m.choropleth(geo_data=open(swiss_topo),
                 topojson='objects.cantons',
                 data=df,
                 columns=['Canton_abv', column],
                 key_on='id',
                 fill_color='YlOrRd',
                 fill_opacity=0.7,
                 line_opacity=0.2,
                 legend_name='Unemployment Rate (%)',
                 reset=True)
    return m
Ejemplo n.º 3
0
def mymap(nodelst):
    pos = G.nodes[nodelst[0]]  # for the start point

    # creating the Map focusing on the start point

    vismap = folium.Map(location=[pos['latitude'], pos['longitude']],
                        zoom_start=10)

    #Layers Map

    folium.raster_layers.TileLayer('Open Street Map').add_to(vismap)
    folium.raster_layers.TileLayer('Stamen Terrain').add_to(vismap)

    #adding lcontrol on map
    folium.LayerControl().add_to(vismap)

    #minimap

    # plugin for mini map
    visminimap = plugins.MiniMap(toggle_display=True)

    # add minimap to map
    vismap.add_child(visminimap)

    # add scroll zoom toggler to map
    plugins.ScrollZoomToggler().add_to(vismap)

    # creating a marker of HOme on the start point

    folium.Marker(location=[(pos['latitude']), (pos['longitude'])],
                  icon=folium.Icon(color='red', icon='home'),
                  popup=(nodelst[0])).add_to(vismap)

    # creating a marker on the rest of the point

    for i in range(len(nodelst) - 1):
        pos = (G.nodes[nodelst[i + 1]])
        folium.Marker(location=[(pos['latitude']), (pos['longitude'])],
                      popup=(nodelst[i + 1])).add_to(vismap)

    return vismap
Ejemplo n.º 4
0
    def map(nodelst):  #start point
        pos = G.nodes[nodelst[0]]
        vismap = folium.Map(location=[pos['latitude'], pos['longitude']],
                            zoom_start=10)
        folium.raster_layers.TileLayer('Open Street Map').add_to(vismap)
        folium.raster_layers.TileLayer('Stamen Terrain').add_to(vismap)
        folium.LayerControl().add_to(vismap)
        #minimap
        visminimap = plugins.MiniMap(toggle_display=True)
        #add to map
        vismap.add_child(visminimap)
        plugins.ScrollZoomToggler().add_to(vismap)
        folium.Marker(location=[(pos['latitude']), (pos['longitude'])],
                      icon=folium.Icon(color='red', icon='home'),
                      popup=(nodelst[0])).add_to(vismap)
        for i in range(len(nodelst) - 1):
            pos = (G.nodes[nodelst[i + 1]])
            folium.Marker(location=[(pos['latitude']), (pos['longitude'])],
                          popup=(nodelst[i + 1])).add_to(vismap)

        return vismap
Ejemplo n.º 5
0
uk_umrlih = df_umrli.iloc[:, -1].values
uk_oporavljenih = df_oporavljeni.iloc[:, -1].values

m = folium.Map(location=[52.954784, -1.158109], zoom_start=5)

#### TYPES OF MAPS
folium.raster_layers.TileLayer('Stamen Terrain').add_to(m)
folium.raster_layers.TileLayer('Stamen Toner').add_to(m)
folium.raster_layers.TileLayer('Stamen Watercolor').add_to(m)
folium.raster_layers.TileLayer('CartoDB Positron').add_to(m)
folium.raster_layers.TileLayer('CartoDB Dark_Matter').add_to(m)

#### MINI MAP, ZOOM TOOLS
minimap = plugins.MiniMap(toggle_display=True)
m.add_child(minimap)
plugins.ScrollZoomToggler().add_to(m)
plugins.Fullscreen(position='topright').add_to(m)

#### GET LAT AND LONG TOOLS
m.add_child(folium.LatLngPopup())

#### MEASURING TOOLS
measure_control = plugins.MeasureControl(position='topleft',
                                         active_color='red',
                                         completed_color='blue',
                                         primary_length_unit='metres')
m.add_child(measure_control)

#### DRAWING TOOLS
draw = plugins.Draw(export=True).add_to(m)
Ejemplo n.º 6
0
def add_minimap(map_name):
    # Plugin for mini map
    minimap = plugins.MiniMap(toggle_display = True)
    map_name.add_child(minimap) # Add minimap
    plugins.ScrollZoomToggler().add_to(map_name) # Add scroll zoom toggler to map
    plugins.Fullscreen(position='topright').add_to(map_name) # Add full screen button to map
Ejemplo n.º 7
0
def addPlugins(m):
    plugins.Fullscreen(position='bottomright',
                       title='Expand me',
                       title_cancel='Exit me',
                       force_separate_button=True).add_to(m)
    plugins.ScrollZoomToggler().add_to(m)  #Block scroll
Ejemplo n.º 8
0
 def test_terminator(self):
     mapa = folium.Map([45., 3.], zoom_start=1)
     mapa.add_plugin(plugins.Terminator())
     mapa.add_plugin(plugins.ScrollZoomToggler())
     mapa._build_map()
Ejemplo n.º 9
0
 def test_scroll_zoom_toggler(self):
     mapa = folium.Map([45., 3.], zoom_start=4)
     mapa.add_plugin(plugins.ScrollZoomToggler())
     mapa._build_map()
Ejemplo n.º 10
0
 def test_terminator(self):
     mapa = folium.Map([45., 3.], zoom_start=1)
     mapa.add_children(plugins.Terminator())
     mapa.add_children(plugins.ScrollZoomToggler())
     mapa._repr_html_()
Ejemplo n.º 11
0
 def test_scroll_zoom_toggler(self):
     mapa = folium.Map([45., 3.], zoom_start=4)
     mapa.add_children(plugins.ScrollZoomToggler())
     mapa._repr_html_()
Ejemplo n.º 12
0
        dt_series = get_total_confirmed_global_cases()
    plt.style.use(plot_background)
    plt.figure(figsize = (fig_width, fig_height))
    plt.title(f'{country_name.upper()}: Total Coronavirus Cases Reported\nCreated by {your_name.upper()}, fontsize = 16)
    plt.plot(dt_series.index, dt_series, c = colour, lw = linewidth, marker = markertype, markersize = 7)
    plt.xticks(rotation = 45)
    plt.ylabel("Total Cases")
    plt.grid(linestyle='--', c='grey')
    plt.show()

# Add minimap
def add_minimap(map_name):
    # Plugin for mini map
    minimap = plugins.MiniMap(toggle_display = True)
    map_name.add_child(minimap) # Add minimap
    plugins.ScrollZoomToggler().add_to(map_name) # Add scroll zoom toggler to map
    plugins.Fullscreen(position='topright').add_to(map_name) # Add full screen button to map

# Add title to map
def add_title(map_name, country, your_name):
    title_html = '''
        <h2 align="center" style="font-size:20px"><b>Coronavirus Total Confirmed Cases in {}</b></h2>
        <h4 align="center" style="font-size:16px"><i>Created by</i> {}</h4>
        <h4 align="center" style="font-size:16px"><i>Powered by</i>
        </h4>
             '''.format(country, your_name.upper())   
    return map_name.get_root().html.add_child(folium.Element(title_html))

# Function to create folium maps using for India, US and the world
def folium_map_with_circles(your_name, country, map_width, map_height, left_margin, top_margin, map_tile, zoom, circle_color, minimap):
    last_col = conf_df.columns[-1]
Ejemplo n.º 13
0
def add_minimap(map_name):
  
    minimap = plugins.MiniMap(toggle_display = True)
    map_name.add_child(minimap) 
    plugins.ScrollZoomToggler().add_to(map_name) 
    plugins.Fullscreen(position='topright').add_to(map_name) 
Ejemplo n.º 14
0
	folium.raster_layers.TileLayer('Stamen Watercolor').add_to(world_map)
	folium.raster_layers.TileLayer('CartoDB Positron').add_to(world_map)
	folium.raster_layers.TileLayer('CartoDB Dark_Matter').add_to(world_map)

	# add layer control
	folium.LayerControl().add_to(world_map)

	# mini map, scroll zoom toggle button, full screen
	# plugin for mini map
	minimap = plg.MiniMap(toggle_display=True)

	# add minimap to map
	world_map.add_child(minimap)

	# add scroll zoom toggler to map
	plg.ScrollZoomToggler().add_to(world_map)

	# add full screen button to map
	plg.Fullscreen(position='topright').add_to(world_map)

	# draw the position of the space station as a red circle
	folium.Circle(
		location=[iss_lat,iss_long],
		popup='IIS position:'+ '\nlongitude = ' + str(iss_long) + '\nlatitude = ' + str(iss_lat),
		radius=1000,
		color='red',
		fill=True,
		fill_color='crimson'
		).add_to(world_map)

	# save the map as html file to open it in a browser