original_string: 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;
      }
code: 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;
      }
code_tokens: 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 ; }
docstring: Builds a map of locations
  
  @param string $template
  @param Search $result
  
  @return \Ivory\GoogleMap\Map
docstring_tokens: Builds a map of locations