@@ -484,21 +484,26 @@ def test_fit_bounds(self):
484484 def test_image_overlay (self ):
485485 """Test image overlay"""
486486 from numpy .random import random
487- from folium .utilities import write_png
487+ from folium .utilities import write_png , geodetic_to_mercator
488488 import base64
489489
490490 data = random ((100 ,100 ))
491491 png_str = write_png (data )
492492 with open ('data.png' , 'wb' ) as f :
493493 f .write (png_str )
494- inline_image_url = "data:image/png;base64," + base64 .b64encode (png_str ).decode ('utf-8' )
494+
495+ image_url = 'data.png'
496+ inline_image_url = ("data:image/png;base64," +
497+ base64 .b64encode (write_png (geodetic_to_mercator (data ))).decode ('utf-8' ))
495498
496499 image_tpl = self .env .get_template ('image_layer.js' )
497500 image_name = 'Image_Overlay'
498501 image_opacity = 0.25
499- image_url = 'data.png'
502+
500503 min_lon , max_lon , min_lat , max_lat = - 90.0 , 90.0 , - 180.0 , 180.0
501504 image_bounds = [[min_lon , min_lat ], [max_lon , max_lat ]]
505+
506+ # Test the external png.
502507
503508 image_rendered = image_tpl .render ({'image_name' : image_name ,
504509 'image_url' : image_url ,
@@ -509,6 +514,7 @@ def test_image_overlay(self):
509514 self .map .image_overlay (data , filename = image_url )
510515 assert image_rendered in self .map .template_vars ['image_layers' ]
511516
517+ # Test the inline png.
512518
513519 image_rendered = image_tpl .render ({'image_name' : image_name ,
514520 'image_url' : inline_image_url ,
0 commit comments