Having never used Geokit before, the math behind this operation is relatively easy to implement. Assuming these points are made up of latitude and longitude, you just need the average latitude and average longitude for all points. Once you have these two meanings, you have a center.
points = [[14, 19], [-5, 57], [23, -12]] points.transpose.map{|c| c.inject{|a, b| a + b}.to_f / c.size}
Similarly, if these points are Geokit::LatLng objects instead of a 2-dimensional array, you can simply list their lat and lng values ββby simply typing #to_a beforehand.
points.map(&:to_a).transpose.map{|c| c.inject{|a, b| a + b}.to_f / c.size}
Michael richards
source share