How To Convert Html Map Into Image (png Or Jpg )
I am trying to save a map containing markers and also heatmap into an image. Here is the code to display the map. from ipywidgets import Layout import geopandas defaultLayout=Layo
Solution 1:
One option (which admittedly is a little crude) is to use the selenium library to automatically open the HTML and from there take a screenshot which then is saved as an image. The code will look like (I have given the code here according to MS Edge, but the code should be similar for other browsers):
from selenium import webdriver
from time import sleep
filename = '<Name (without path) of your HTML file here>'
MyBrowser = webdriver.Edge(r"<path to webdriver here>\\msedge.exe")
murl = r'file:\\{path}\{mapfile}'.format(path='<path to HTML here>',mapfile=mfilename)
MyBrowser.get(murl)
sleep(10) #this is not strictly necessary but is here in case you need time for map tiles to load
MyBrowser.save_screenshot('<Image_file_name>')
MyBrowser.quit()
Note that this will require you to install a webdriver for your browser in advance.
Post a Comment for "How To Convert Html Map Into Image (png Or Jpg )"