Reputation: 2552
I'm using folium with patches for offline mode, by replacing the default JS/CSS and loading from local tilesets. So far it seems to work for normal plotting.
However, using folium.plugins.Heatmap
, I dont see a visual for the heatmap at all. It appears as a layer as I can see it in the layercontrol, but theres no actual heatmap visually.
There are no console errors, and ive already altered the link in the render
method of heat_map.py
to load from the offline leaflet-js
file as well. Nothing works
Anyone can guide with this?
Thanks~
Example code (not including edits for offline mode)
import folium
from folium.plugins import HeatMap
m = folium.Map(
location=[1.3521, 103.8198],
tiles='tiles/{z}/{x}/{y}.png'
min_zoom=5,
max_zoom=14,
zoom_start=6,
control_scale=True
)
rand_l = np.random.uniform(1.3,1.4,size=100)
rand_lon = np.random.uniform(103.63,104,size=100)
data = np.array([rand_l,rand_lon]).reshape(100,2).tolist()
HeatMap(data).add_to(folium.FeatureGroup(name='Heat Map').add_to(m))
folium.map.LayerControl(collapsed=False).add_to(m)
m.save("test.html")
Upvotes: 0
Views: 1137
Reputation: 2552
Figured it out, It's basically my own stupidity, and was tempted to delete this question but leaving it here incase it helps anyone.
The offline mode works fine. The way I was testing it was wrong. In my rush to generate mock data, I stupidly have the data in [lat,lat]...[lon,lon] pairs instead of [lat,lon] pairs
It works. Check your input data people.
Upvotes: 1