import folium
from folium.plugins.measure_control import MeasureControl
m = folium.Map(location=[-27.5717, -48.6256], zoom_start=9)
c = MeasureControl()
c.add_to(m)
radius = 50
folium.CircleMarker(
location=[-27.55, -48.8],
radius=radius,
color="cornflowerblue",
stroke=False,
fill=True,
fill_opacity=0.6,
opacity=1,
popup="{} pixels".format(radius),
tooltip="I am in pixels",
).add_to(m)
radius = 25
folium.CircleMarker(
location=[-27.35, -48.8],
radius=radius,
color="black",
weight=3,
fill=False,
fill_opacity=0.6,
opacity=1,
).add_to(m)
radius = 10000
folium.Circle(
location=[-27.551667, -48.478889],
radius=radius,
color="black",
weight=1,
fill_opacity=0.6,
opacity=1,
fill_color="green",
fill=False, # gets overridden by fill_color
popup="{} meters".format(radius),
tooltip="I am in meters",
).add_to(m)
m
# Coordinates are 15 points on the great circle from Boston to
# San Francisco.
# Reference: http://williams.best.vwh.net/avform.htm#Intermediate
coordinates = [
[42.3581, -71.0636],
[42.82995815, -74.78991444],
[43.17929819, -78.56603306],
[43.40320216, -82.37774519],
[43.49975489, -86.20965845],
[43.46811941, -90.04569087],
[43.30857071, -93.86961818],
[43.02248456, -97.66563267],
[42.61228259, -101.41886832],
[42.08133868, -105.11585198],
[41.4338549, -108.74485069],
[40.67471747, -112.29609954],
[39.8093434, -115.76190821],
[38.84352776, -119.13665678],
[37.7833, -122.4167],
]
# Create the map and add the line
m = folium.Map(location=[41.9, -97.3], zoom_start=4)
folium.PolyLine(
locations=coordinates,
color="#FF0000",
weight=5,
tooltip="From Boston to San Francisco",
).add_to(m)
folium.PolyLine(
smooth_factor=50,
locations=coordinates,
color="grey",
tooltip="Too much smoothing?",
weight=5,
).add_to(m)
m
lon = lat = 0
zoom_start = 1
m = folium.Map(location=[lat, lon], zoom_start=zoom_start)
kw = {"opacity": 1.0, "weight": 6}
folium.PolyLine(
locations=[(2, 179), (2, -179)],
tooltip="Wrong",
color="red",
line_cap="round",
**kw,
).add_to(m)
folium.PolyLine(
locations=[(-2, 179), (-2, 181)],
tooltip="Correct",
line_cap="butt",
color="blue",
**kw,
).add_to(m)
folium.PolyLine(
locations=[(-6, -179), (-6, 179)],
line_cap="square",
color="green",
tooltip="Correct",
**kw,
).add_to(m)
folium.PolyLine(
locations=[(12, -179), (12, 190)],
color="orange",
tooltip="Artifact?",
**kw,
).add_to(m)
m
lat = +38.89399
lon = -77.03659
zoom_start = 17
m = folium.Map(location=[lat, lon], zoom_start=zoom_start)
kw = {"color": "red", "fill": True, "radius": 20}
folium.CircleMarker([38.89415, -77.03738], **kw).add_to(m)
folium.CircleMarker([38.89415, -77.03578], **kw).add_to(m)
locations = [
[
(38.893596444352134, -77.03814983367920),
(38.893379333722040, -77.03792452812195),
],
[
(38.893379333722040, -77.03792452812195),
(38.893162222428310, -77.03761339187622),
],
[
(38.893162222428310, -77.03761339187622),
(38.893028615148424, -77.03731298446655),
],
[
(38.893028615148424, -77.03731298446655),
(38.892920059048464, -77.03691601753235),
],
[
(38.892920059048464, -77.03691601753235),
(38.892903358095296, -77.03637957572937),
],
[
(38.892903358095296, -77.03637957572937),
(38.893011914220770, -77.03592896461487),
],
[
(38.893011914220770, -77.03592896461487),
(38.893162222428310, -77.03549981117249),
],
[
(38.893162222428310, -77.03549981117249),
(38.893404384982480, -77.03514575958252),
],
[
(38.893404384982480, -77.03514575958252),
(38.893596444352134, -77.03496336936950),
],
]
folium.PolyLine(
locations=locations,
color="orange",
weight=8,
opacity=1,
smooth_factor=0,
).add_to(m)
m
m = folium.Map(location=[35.685, 139.76], zoom_start=15)
kw = {
"color": "blue",
"line_cap": "round",
"fill": True,
"fill_color": "red",
"weight": 5,
"popup": "Tokyo, Japan",
"tooltip": "<strong>Click me!</strong>",
}
folium.Rectangle(
bounds=[[35.681, 139.766], [35.691, 139.776]],
line_join="round",
dash_array="5, 5",
**kw,
).add_to(m)
dx = 0.012
folium.Rectangle(
bounds=[[35.681, 139.766 - dx], [35.691, 139.776 - dx]],
line_join="mitter",
dash_array="5, 10",
**kw,
).add_to(m)
folium.Rectangle(
bounds=[[35.681, 139.766 - 2 * dx], [35.691, 139.7762 - 2 * dx]],
line_join="bevel",
dash_array="15, 10, 5, 10, 15",
**kw,
).add_to(m)
m
m = folium.Map(location=[35.67, 139.78], zoom_start=13)
locations = [
[35.6762, 139.7795],
[35.6718, 139.7831],
[35.6767, 139.7868],
[35.6795, 139.7824],
[35.6787, 139.7791],
]
folium.Polygon(
locations=locations,
color="blue",
weight=6,
fill_color="red",
fill_opacity=0.5,
fill=True,
popup="Tokyo, Japan",
tooltip="Click me!",
).add_to(m)
m
locations = [
[
[7.577794326946673, 8.998503901433935],
[7.577851434795945, 8.998572430673164],
[7.577988491475764, 8.998652380403087],
[7.578105560723088, 8.998426807051544],
[7.577891409660878, 8.998289750371725],
[7.577794326946673, 8.998503901433935],
],
[
[7.578139824893071, 8.999291979141560],
[7.578359687549607, 8.999414759083890],
[7.578456769364435, 8.999266281014116],
[7.578471046101925, 8.999197181604700],
[7.578247331649095, 8.999094883721964],
[7.578139824893071, 8.99929197914156],
],
[
[7.577851730672876, 8.997811268775080],
[7.578012579816743, 8.997460464828633],
[7.577798113991832, 8.997311104523930],
[7.577667902951418, 8.997663440915119],
[7.577851730672876, 8.997811268775080],
],
[
[7.578562417221803, 8.999551816663029],
[7.578688052511666, 8.999654609172921],
[7.578813688700849, 8.999443313458185],
[7.578670920426703, 8.999369073523950],
[7.578562417221803, 8.999551816663029],
],
[
[7.577865711533433, 8.998252059784761],
[7.577989601239152, 8.998002756022402],
[7.577648754586391, 8.997784460884190],
[7.577545911714481, 8.998069316645683],
[7.577865711533433, 8.998252059784761],
],
]
m = folium.Map(location=[7.577798113991832, 8.997311104523930], zoom_start=16)
folium.Polygon(
locations=locations,
smooth_factor=2,
color="crimson",
no_clip=True,
tooltip="Hi there!",
).add_to(m)
m