protected function buildMap($template, Search $result)
    {
        $map = $this->getMap();

        if (!$result->hasResults()) { //in case of no result we center on the searched location
            $map->setCenter(
                new Coordinate(
                    $result->getCenter()->getLatitude(),
                    $result->getCenter()->getLongitude()
                )
            );

            return $map;
        }

        $twigTemplate = $this->get('twig')->loadTemplate($template);
        $map->setAutoZoom(true); //this is important to set before adding markers

        foreach ($result->getResults() as $result) { /* @var $result Result */

            $location = $result->location;

            if (!$location instanceof GeolocatableInterface) {
                continue;
            }

            $marker = new Marker(
                new Coordinate(
                    $location->getLatitude(),
                    $location->getLongitude()
                )
            );

            if ($twigTemplate->hasBlock('teneleven_geolocator_item_window', [])) {

                $infoWindow = new InfoWindow($twigTemplate->renderBlock(
                    'teneleven_geolocator_item_window',
                    array('result' => $result)
                ));

                $marker->setInfoWindow($infoWindow);
                $result->mapWindowId = $infoWindow->getVariable();
            }

            $result->mapMarkerId = $marker->getVariable();
            $map->getOverlayManager()->addMarker($marker);
        }

        return $map;
    }
protected function buildMap($template, Search $result)
    {
        $map = $this->getMap();

        if (!$result->hasResults()) { //in case of no result we center on the searched location
            $map->setCenter(
                new Coordinate(
                    $result->getCenter()->getLatitude(),
                    $result->getCenter()->getLongitude()
                )
            );

            return $map;
        }

        $twigTemplate = $this->get('twig')->loadTemplate($template);
        $map->setAutoZoom(true); //this is important to set before adding markers

        foreach ($result->getResults() as $result) { /* @var $result Result */

            $location = $result->location;

            if (!$location instanceof GeolocatableInterface) {
                continue;
            }

            $marker = new Marker(
                new Coordinate(
                    $location->getLatitude(),
                    $location->getLongitude()
                )
            );

            if ($twigTemplate->hasBlock('teneleven_geolocator_item_window', [])) {

                $infoWindow = new InfoWindow($twigTemplate->renderBlock(
                    'teneleven_geolocator_item_window',
                    array('result' => $result)
                ));

                $marker->setInfoWindow($infoWindow);
                $result->mapWindowId = $infoWindow->getVariable();
            }

            $result->mapMarkerId = $marker->getVariable();
            $map->getOverlayManager()->addMarker($marker);
        }

        return $map;
    }
protected function buildMap ( $ template , Search $ result ) { $ map = $ this -> getMap ( ) ; if ( ! $ result -> hasResults ( ) ) { //in case of no result we center on the searched location $ map -> setCenter ( new Coordinate ( $ result -> getCenter ( ) -> getLatitude ( ) , $ result -> getCenter ( ) -> getLongitude ( ) ) ) ; return $ map ; } $ twigTemplate = $ this -> get ( 'twig' ) -> loadTemplate ( $ template ) ; $ map -> setAutoZoom ( true ) ; //this is important to set before adding markers foreach ( $ result -> getResults ( ) as $ result ) { /* @var $result Result */ $ location = $ result -> location ; if ( ! $ location instanceof GeolocatableInterface ) { continue ; } $ marker = new Marker ( new Coordinate ( $ location -> getLatitude ( ) , $ location -> getLongitude ( ) ) ) ; if ( $ twigTemplate -> hasBlock ( 'teneleven_geolocator_item_window' , [ ] ) ) { $ infoWindow = new InfoWindow ( $ twigTemplate -> renderBlock ( 'teneleven_geolocator_item_window' , array ( 'result' => $ result ) ) ) ; $ marker -> setInfoWindow ( $ infoWindow ) ; $ result -> mapWindowId = $ infoWindow -> getVariable ( ) ; } $ result -> mapMarkerId = $ marker -> getVariable ( ) ; $ map -> getOverlayManager ( ) -> addMarker ( $ marker ) ; } return $ map ; }
Builds a map of locations

@param string $template
@param Search $result

@return \Ivory\GoogleMap\Map
Builds a map of locations