I'm trying to draw a heatmap with folium.
My code:
import folium
from folium.plugins import HeatMap
base_location = (41.38861123888889, 2.1716497203703704)
m = folium.Map(
location=base_location,
zoom_start=13,
)
# Some testing locs
locs = [
[41.4257715, 2.1761088],
[41.384546, 2.1638681],
[41.3850111, 2.1658954],
[41.3809043, 2.1734703],
[41.3865159, 2.1709474],
[41.3874418, 2.1706964],
[41.3854827, 2.1700754],
[41.3893763, 2.1728965],
[41.3816256, 2.1748245],
[41.3858352, 2.1943144]
]
HeatMap(locs).add_to(m)
m
But my system returns a map without any heatmap layer. Why??
I also try to save the map into a html, and to present locs as list of tuples, but the result is the same.
I solved, I'v found that my company firewall block's github sources.
I just change heat_map.py:
def render(self, **kwargs):
super(HeatMap, self).render(**kwargs)
figure = self.get_root()
assert isinstance(figure, Figure), ('You cannot render this Element '
'if it is not in a Figure.')
figure.header.add_child(
# Changed github source with any gitraw service alternative
# JavascriptLink('https://leaflet.github.io/Leaflet.heat/dist/leaflet-heat.js'), # noqa
JavascriptLink('https://rawcdn.githack.com/Leaflet/Leaflet.heat/5885ec0ec2442876b67725c64dc537cb12c52c73/dist/leaflet-heat.js'), # noqa
name='leaflet-heat.js')