TRUE]); if (!is_numeric($config['frontpage']['map']['center']['lat']) || !is_numeric($config['frontpage']['map']['center']['lng'])) { $map_center = dbFetchRow('SELECT MAX(`location_lon`) AS `lng_max`, MIN(`location_lon`) AS `lng_min`, MAX(`location_lat`) AS `lat_max`, MIN(`location_lat`) AS `lat_min` FROM `devices_locations` ' . $where); $map_center['lat'] = ($map_center['lat_max'] + $map_center['lat_min']) / 2; $map_center['lng'] = ($map_center['lng_max'] + $map_center['lng_min']) / 2; $config['frontpage']['map']['center']['lat'] = $map_center['lat']; $config['frontpage']['map']['center']['lng'] = $map_center['lng']; // Auto-zoom if (!is_numeric($config['frontpage']['map']['zoom'])) { $map_center['lat_size'] = abs($map_center['lat_max'] - $map_center['lat_min']); $map_center['lng_size'] = abs($map_center['lng_max'] - $map_center['lng_min']); $l_max = max($map_center['lng_size'], $map_center['lat_size'] * 2); // This is the magic array (2: min zoom, 10: max zoom). foreach ([1 => 10, 2 => 9, 4 => 8, 6 => 7, 15 => 5, 45 => 4, 90 => 3, 360 => 2] as $g => $z) { if ($l_max <= $g) { $config['frontpage']['map']['zoom'] = $z; break; } } } //r($map_center); } else { if (!is_numeric($config['frontpage']['map']['zoom'])) { $config['frontpage']['map']['zoom'] = 4; } } ?> '; } else { echo ''; } ?>