You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I may be missing the section in the documentation on these, but i am having a few problems and can't find out where to look for the answers.
First, after creating a instance of the heatmap
var stuff = {
"radius": 1,
"scaleRadius": true,
"useLocalExtrema": true,
latField: 'lat',
lngField: 'lng',
valueField: 'count'
};
var data = {
max: 10,
data:[{ lat: 5.102, lng: 85.112, count:5}, { lat: 5.202, lng: 85.312, count:5})]};
var heatmapLayer = new HeatmapOverlay(stuff);
heatmapLayer.setData(data);
map.addLayer(heatmapLayer);
One, later, calling map.removeLayer(heatmapLayer);
does nothing at all. No errors, but the heatmaps are still there in the map. I want to hide the layer so the user can view the map without the heatmap obscuring, and also unhide it later without needing to recreate the heatmap. It's toggling through a leaflet button.
Two,
How do I remove the heatmap permanently (unlike hiding it above)? doing a setData([{}]) seems to create errors of invalid lat lng
Three,
I don't know if it's my map size or scaleRadius or useLocalExtrema, but I can't seem to create a very small heatmap to cover an area of about 100 meters radius. the smallest I can get is about a few kilometers in radius and sometimes i get errors like:
Failed to execute 'drawImage' on 'CanvasRendering Context2D': The image argument is a canvas element with a width or height of 0.
Lastly,
How do I later get a referrence to this heatmap object? Say I create the heatmap in my Main.js using var heatmapLayer = new HeatmapOverlay(stuff);
How do i later referrence this Layer in , say a Leaflet or another Javascript file? I can't just get object by elementid, right?
Can anyone enlighten me?
Thanks
The text was updated successfully, but these errors were encountered:
Hello,
I am also trying to remove the heatmap layer using the code
map.removeLayer(heat);
But it does not seem to work. I get the following error when I try it.
Uncaught TypeError: Cannot read properties of undefined (reading '_leaflet_id')
And when I try to print out the layer using the console.log(heat); It gives me undefined.
In short, the layer is added properly to the map and I can see it. It also shows the data perfectly as expected. But when I try to remove the layer, it shows the error mentioned above. Is there any way I can solve this or am I missing something?
Hi,
I may be missing the section in the documentation on these, but i am having a few problems and can't find out where to look for the answers.
First, after creating a instance of the heatmap
One, later, calling
map.removeLayer(heatmapLayer);
does nothing at all. No errors, but the heatmaps are still there in the map. I want to hide the layer so the user can view the map without the heatmap obscuring, and also unhide it later without needing to recreate the heatmap. It's toggling through a leaflet button.
Two,
How do I remove the heatmap permanently (unlike hiding it above)? doing a setData([{}]) seems to create errors of invalid lat lng
Three,
I don't know if it's my map size or scaleRadius or useLocalExtrema, but I can't seem to create a very small heatmap to cover an area of about 100 meters radius. the smallest I can get is about a few kilometers in radius and sometimes i get errors like:
Failed to execute 'drawImage' on 'CanvasRendering Context2D': The image argument is a canvas element with a width or height of 0.
Lastly,
How do I later get a referrence to this heatmap object? Say I create the heatmap in my Main.js using
var heatmapLayer = new HeatmapOverlay(stuff);
How do i later referrence this Layer in , say a Leaflet or another Javascript file? I can't just get object by elementid, right?
Can anyone enlighten me?
Thanks
The text was updated successfully, but these errors were encountered: