Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Enter file contents hereif (type === 'circle') { // Make a strict comparison, no false positives
var test = [];
var theCenterPt = layer.getLatLng();
var theRadius = layer.getRadius();
var counter_points_in_circle = 0;
// Loop through each point in GeoJSON file //var allPoints = L.geoJson(data);
allPoints.eachLayer(function (layer) { // already in scope from lines before, try something else
var theLayer = layer; // unused variable
// Lat, long of current point
layer_lat_long = layer.getLatLng();
// Distance from our circle marker To current point in meters
distance_from_centerPoint = layer_lat_long.distanceTo(theCenterPt);
// See if meters is within radius
if (distance_from_centerPoint <= theRadius) {
counter_points_in_circle += 1;
test.push.layer; //Try pushing the new argument or theLayer
alert(counter_points_in_circle); //Works.
alert(test.features.length); //test.features is undefined..
alert("results "+JSON.stringify(test)); //results []
alert("results "+JSON.stringify(test.toGeoJSON())); //test.toGeoJSON is not a function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.