Sulu\Bundle\LocationBundle\Controller\GeolocatorController::queryAction PHP Method

queryAction() public method

Query the configured geolocation service.
public queryAction ( Request $request ) : Symfony\Component\HttpFoundation\JsonResponse
$request Symfony\Component\HttpFoundation\Request
return Symfony\Component\HttpFoundation\JsonResponse
    public function queryAction(Request $request)
    {
        $geolocatorName = $request->get('providerName');
        $query = $request->get('query');
        $geolocatorManager = $this->get('sulu_location.geolocator.manager');
        try {
            $geolocator = $geolocatorManager->get($geolocatorName);
        } catch (GeolocatorNotFoundException $e) {
            throw new NotFoundHttpException(sprintf('Wrapped "%s"', $e->getMessage()), $e);
        }
        $res = $geolocator->locate($query);
        return new JsonResponse(['_embedded' => ['locations' => $res->toArray()]]);
    }
GeolocatorController