Instantly share code, notes, and snippets.

Embed
What would you like to do?
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