/** * Set zoom level for map based on radius * * @param Model\Location|Model\Constraint $location * @param Model\Constraint $constraint * * @return Model\Location */ public function setZoomLevel($location, Model\Constraint $constraint) { $radius = $constraint->getRadius(); if ($radius > 500 && $radius <= 1000) { $zoom = 12; } elseif ($radius < 2) { $zoom = 2; } elseif ($radius < 3) { $zoom = 3; } elseif ($radius < 5) { $zoom = 4; } elseif ($radius <= 25) { $zoom = 7; } elseif ($radius <= 100) { $zoom = 9; } elseif ($radius <= 500) { $zoom = 11; } else { $zoom = 13; } $location->setZoom(18 - $zoom); return $location; }
/** * Adds radius to query parts if present in contraints * * @param \Evoweb\StoreFinder\Domain\Model\Constraint $constraint * @param array $queryParts * @return array */ protected function addRadiusQueryPart($constraint, $queryParts) { /** @var \TYPO3\CMS\Core\Database\DatabaseConnection $database */ $database = $GLOBALS['TYPO3_DB']; if ($this->settings['distanceUnit'] == 'miles') { $constraint->setRadius(max($constraint->getRadius(), 1) * 1.6); } $queryParts['WHERE'] .= ' HAVING distance <= ' . $database->fullQuoteStr($constraint->getRadius(), ''); return $queryParts; }