In drupal-project/web/modules/contrib/styled_google_map/src/Plugin/views/style/StyledGoogleMapStyle.php the $results is empty after upgrade from Drupal 9 to Drupal 10.

D9.2.9: styled_google_map (8.X-2.0) / geocoder (8.x-3.20)
D10.2.5: styled_google_map (8.x-2.3) / geocoder (8.X-4.23)

create a view, select "styled google map" as format, add geolocation field and select it as field that contains the geodata.
(raw output / WKT)

The content type exists of a address field and a geolocation.

Below pre_prender function is correctly populated with the results, but the $results within the render() function remains empty (StyledGoogleMapStyle.php)...

function styled_google_map_views_pre_render(Drupal\views\ViewExecutable $view) {
  if ($view->id() == 'your_view_id') {
    \Drupal::logger('styled_google_map')->notice('Pre-render results: @results', ['@results' => print_r($view->result, TRUE)]);
  }
}

No js errors, no php errors.
why is the result empty?
This map has 0 points

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Lance Lancelot created an issue. See original summary.

redeight’s picture

So, I believe the issue is that StylePluginBase->render() doesn't take any parameters, but StyledGoogleMapsStyle->render is defined as public function render($results = []) and nothing passes anything to that $results. Adding $results = $this->view->result; as the first line of StyledGoogleMapsStyle->render suddenly fixes the issue. Which makes sense. The render function has access to the result directly from itself, no reason to pass in another array entirely.

redeight’s picture

Is there something else that was supposed to populate that call to render with the $results it was expecting? Did Drupal change something so it no longer does that?

  • a.dmitriiev committed 12d32837 on 8.x-2.x
    Issue #3439676: render function keeps empty: This map has 0 points
    
a.dmitriiev’s picture

Category: Support request » Bug report

To be honest, I am shocked myself. I have no idea how it was working before like that :) Thank you for reporting this.

a.dmitriiev’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.