I am trying to save a map containing markers and also heatmap.
Here is the code to display the map.
import folium
m_f = folium.Map(location= [39.76258, 254.994682],
zoom_start=8)
m_f.save('f_map.html')
m_f
I then use phantomjs to save the image.
import selenium.webdriver
import time
from selenium import webdriver
driver = webdriver.PhantomJS(executable_path='/Users/path/Downloads/PhantomJS/bin/phantomjs')
driver.set_window_size(4000, 3000) # choose a resolution
driver.get('f_map.html')
# You may need to add time.sleep(seconds) here
time.sleep(1)
driver.save_screenshot('f_map.png')
There is no problem until here.
However, when I add some markers on the map, I get the correct html file, which I can open also in the browser, but its screenshot is a blank file (content).
Here is the code of the new map
import folium
m_f = folium.Map(location= [39.74258, 254.993682],
zoom_start=12)
arr_test1 = [39.74258, 254.993682]
arr_test2 = [39.75258, 254.994682]
arr_test3 = [39.76258, 254.994682]
all_loc = [arr_test1, arr_test2, arr_test3]
for cur_loc in all_loc:
point = folium.Circle(
radius=200,
location=cur_loc,
popup='The Waterfront',
color='red',
fill=False,
)
point.add_to(m_f)
time.sleep(0.001)
m_f
m_f.save('f_map_marker.html')
and its phantonjs code lines
import selenium.webdriver
import time
from selenium import webdriver
driver = webdriver.PhantomJS(executable_path='/Users/path/Downloads/PhantomJS/bin/phantomjs')
driver.set_window_size(4000, 3000) # choose a resolution
driver.get('f_map_marker.html')
time.sleep(1)
driver.save_screenshot('f_map_marker.png')
So, the f_map_marker.png file is blank.
Does anyone has an idea, why it behaves this way, and how I can solve the issue ?
Any hints will be welcome.