In [1]:
#Import the Module Folium
import folium
In [2]:
#Gather all the data you want to use
url = (
    "https://raw.githubusercontent.com/jwitcoski/jwitcoski.github.io/master/Antikythera/data/"
)

tracts = f"{url}""tracts.geojson"
geology = f"{url}""geology.geojson"
In [3]:
#Define the map's location and zoom level
map = folium.Map(
    location=[35.8644, 23.2988],
    zoom_start=13,
)
In [4]:
#add some basemaps
folium.raster_layers.TileLayer(
    tiles='OpenStreetMap', name='Open Street Map'
).add_to(map)
folium.raster_layers.TileLayer(
    tiles='stamentoner', name='Black/White Map'
).add_to(map)
folium.raster_layers.TileLayer(
    tiles='stamenterrain', name='stamenterrain'
).add_to(map)
folium.raster_layers.TileLayer(
    tiles='CartoDB dark_matter', name='CartoDB dark_matter'
).add_to(map)
Out[4]:
<folium.raster_layers.TileLayer at 0x2378d1eaf98>
In [5]:
#give the layers some color
def style_function(self):
    return {'fillColor': 'black'};

def style_function2(self):
    return {'fillColor': 'green', "opacity": 0.99}
In [6]:
#Insert the layers into the map, Give them tool tips and names we can recognize
folium.GeoJson(geology,tooltip= folium.GeoJsonTooltip(fields=["Type","Age"]), name="geology", style_function=style_function).add_to(map)
folium.GeoJson(tracts, tooltip= folium.GeoJsonTooltip(fields=["Tract","Comments"]), name="tracts", style_function=style_function2, show = False).add_to(map)
Out[6]:
<folium.features.GeoJson at 0x2378d285630>
In [7]:
#Add the layer control so that the user can turn on and off layers
folium.LayerControl().add_to(map)
Out[7]:
<folium.map.LayerControl at 0x2378d1ff780>
In [8]:
#Create the map
map
Out[8]:
Make this Notebook Trusted to load map: File -> Trust Notebook
In [9]:
#Export the map as HTML
map.save("fuliummap.html")
In [ ]: