question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hi,

I’d like my heat point around lat/lng to have a fixed (zoom independent) radius of 500m : how can I specify this ?

Thank you

Issue Analytics

  • State:open
  • Created 9 years ago
  • Reactions:4
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
bobintornadocommented, Mar 22, 2015

Having a similar but not exactly the same issue here. Because I am not sure about how to recalculate the radius of each feature on each zoom, I implement this by removing old layers and add back new layers on each zoom. Something like

map.on('zoomend', function() {
    // remove existing layer
    map.removeLayer(old_layer);
    // add in new
    new_layer = L.geoJson(data, data_options);
    map.addLayer(new_layer);
});

and in my data_options, I implemented the resizing method

var data_options = {
    pointToLayer: function(feature, latlng) {
        mk = L.circleMarker(latlng);

        var pointC = map.latLngToContainerPoint(latlng);
        var pointX = [pointC.x + 1, pointC.y];

        // convert containerpoints to latlng's
        var latLngC = map.containerPointToLatLng(pointC);
        var latLngX = map.containerPointToLatLng(pointX);

       // Assuming distance only depends on latitude 
        var distanceX = latLngC.distanceTo(latLngX);
      // 100 meters is the fixed distance here
        var pixels = 100 / distanceX;
        mk.setRadius(pixels);

        return mk;
    }
};

Hope this helps! I refer to http://stackoverflow.com/questions/27545098/leaflet-calculating-meters-per-pixel-at-zoom-level when I implemented method for calculating meters per pixel at different zoom levels.

0reactions
cpunekarcommented, Aug 1, 2016

Thanks @kuzvac for the reply. I wanted to have fixed radius when I asked this question but now since the intensity value of points get added as we zoom out, I was curious if we can recalculate the radius each time we zoom in and out. As in I want the radius to increase when we zoom in and to decrease when we zoom out. This would give me a better picture of the intensity values as I am not looking for density heatmap.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fixed-radius near neighbors - Wikipedia
In computational geometry, the fixed-radius near neighbor problem is a variant of the nearest neighbor search problem. In the fixed-radius near neighbor ...
Read more >
Fixed-Radius Plots as Inventory Method in Southern Forests
Fixed -radius plots are usually circular with plot sizes commonly reported in fractions of acres (1/10 acre, 1/20 acre, etc.). Size and number...
Read more >
Searching for Fixed-Radius Near Neighbors with Cell Lists ...
This article will teach you how to implement the Cell Lists algorithm in Julia Language for performing a fixed-radius near neighbors search.
Read more >
The complexity of finding fixed-radius near neighbors
A survey of techniques for fixed-radius near neighbor searching. Stanford Linear Accelerator Center Report SLAC-186 (1975), p. 33.
Read more >
Calculated Fixed Radius Definition - Law Insider
Define Calculated Fixed Radius. means a technique to delineate a wellhead protection area, based on the determination of the volume of the aquifer...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found