Skip to content

Commit 661fc9f

Browse files
authored
docs: update ImageOverlay with local file example (#2111)
1 parent 34e464d commit 661fc9f

File tree

1 file changed

+17
-23
lines changed

1 file changed

+17
-23
lines changed

docs/user_guide/raster_layers/image_overlay.md

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,31 @@ If you have a static image file on your disk, you can simply draw it on the map.
1111
import os
1212
import folium
1313
14-
m = folium.Map([37, 0], zoom_start=1)
15-
merc = os.path.join("data", "Mercator_projection_SW.png")
16-
17-
18-
if not os.path.isfile(merc):
19-
print(f"Could not find {merc}")
20-
else:
21-
img = folium.raster_layers.ImageOverlay(
22-
name="Mercator projection SW",
23-
image=merc,
24-
bounds=[[-82, -180], [82, 180]],
25-
opacity=0.6,
26-
interactive=True,
27-
cross_origin=False,
28-
zindex=1,
29-
)
14+
m = folium.Map([0, 0], zoom_start=2)
15+
image_filepath = os.path.join("..", "..", "_static", "folium_logo.png")
16+
17+
img = folium.raster_layers.ImageOverlay(
18+
name="Folium logo",
19+
image=image_filepath,
20+
bounds=[[-50, -45], [50, 45]],
21+
opacity=0.6,
22+
interactive=True,
23+
cross_origin=False,
24+
zindex=1,
25+
)
3026
31-
folium.Popup("I am an image").add_to(img)
27+
folium.Popup("I am an image").add_to(img)
3228
33-
img.add_to(m)
34-
folium.LayerControl().add_to(m)
29+
img.add_to(m)
30+
folium.LayerControl().add_to(m)
3531
3632
m
3733
```
3834

39-
A few remarks:
40-
41-
* Note that your image has to be in Mercator projection format.
35+
Note that your image has to be in Mercator projection format.
4236

43-
The image we've used is based on https://en.wikipedia.org/wiki/File:Mercator_projection_SW.jpg ; that you can find in wikipedia's article on Mercator Projection (https://en.wikipedia.org/wiki/Mercator_projection).
4437

38+
## Using an image from a url
4539

4640
You can also provide simply URL. In this case, the image will not be embedded in folium's output.
4741

0 commit comments

Comments
 (0)