Skip to content

Instantly share code, notes, and snippets.

@HydJing
HydJing / average-geolocation.js
Created March 1, 2018 22:46 — forked from tlhunter/average-geolocation.js
Calculate the center/average of multiple GeoLocation coordinates
/**
* Calculate the center/average of multiple GeoLocation coordinates
* Expects an array of objects with .latitude and .longitude properties
*
* @url http://stackoverflow.com/a/14231286/538646
*/
function averageGeolocation(coords) {
if (coords.length === 1) {
return coords[0];
}