Skip to content

Instantly share code, notes, and snippets.

@tmcw
Created January 17, 2013 20:38
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 tmcw/4559545 to your computer and use it in GitHub Desktop.
Save tmcw/4559545 to your computer and use it in GitHub Desktop.
function filteredExtent(markers) {
var ext = [{
lat: Infinity,
lon: Infinity
}, {
lat: -Infinity,
lon: -Infinity
}];
var ft = m.features();
for (var i = 0; i < ft.length; i++) {
if (!m.filter()(ft[i])) continue;
var coords = ft[i].geometry.coordinates;
if (coords[0] < ext[0].lon) ext[0].lon = coords[0];
if (coords[1] < ext[0].lat) ext[0].lat = coords[1];
if (coords[0] > ext[1].lon) ext[1].lon = coords[0];
if (coords[1] > ext[1].lat) ext[1].lat = coords[1];
}
return ext;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment