Created
January 17, 2013 20:38
-
-
Save tmcw/4559545 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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