Skip to content

Instantly share code, notes, and snippets.

@fitomad
Created October 22, 2018 07:02
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 fitomad/8b96451d41f15d3d79726fa2123bbe2a to your computer and use it in GitHub Desktop.
Save fitomad/8b96451d41f15d3d79726fa2123bbe2a to your computer and use it in GitHub Desktop.
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