You are here

function _ip_geoloc_get_center in IP Geolocation Views & Maps 7

Get the center of a lat/lon pair.

1 call to _ip_geoloc_get_center()
ip_geoloc_plugin_style_leaflet::render in views/ip_geoloc_plugin_style_leaflet.inc
Transform the View result in a list of marker locations and render on map.

File

views/ip_geoloc_plugin_style_leaflet.inc, line 1748

Code

function _ip_geoloc_get_center($location) {
  if (empty($location->type) || $location->type == 'point') {
    $lat = isset($location->lat) ? $location->lat : (isset($location->latitude) ? $location->latitude : 0.0);
    $lon = isset($location->lon) ? $location->lon : (isset($location->longitude) ? $location->longitude : 0.0);
    return array(
      'lat' => $lat,
      'lon' => $lon,
    );
  }
  if (!empty($location->component[0]['points'][0])) {
    return $location->component[0]['points'][0];
  }
}