-
-
Save fitomad/8b96451d41f15d3d79726fa2123bbe2a 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 centerMap(coordinates) | |
{ | |
let latitudes = coordinates.map(function(element) { | |
return element.latitude; | |
}); | |
let longitudes = coordinates.map(function(element) { | |
return element.longitude; | |
}); | |
let longitudeMax = Math.max.apply(null, longitudes); | |
let longitudeMin = Math.min.apply(null, longitudes); | |
let latitudeMax = Math.max.apply(null, latitudes); | |
let latitudeMin = Math.min.apply(null, latitudes); | |
let boundingRegion = new mapkit.BoundingRegion(latitudeMax, longitudeMax, latitudeMin, longitudeMin); | |
let region = boundingRegion.toCoordinateRegion(); | |
map.setRegionAnimated (region, true); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment