Skip to content

Instantly share code, notes, and snippets.

@roma0104
Last active March 22, 2016 18:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roma0104/b50d62ad6fdb7440f8c2 to your computer and use it in GitHub Desktop.
Save roma0104/b50d62ad6fdb7440f8c2 to your computer and use it in GitHub Desktop.
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