Problem/Motivation

Views might contain many markers. Content of each marker gets rendered on page load. This reduces page performance, as popup content might contain content like media files, social embeds, etc.

Proposed resolution

Add possibility to load popup content via AJAX on open.

CommentFileSizeAuthor
#3 geolocation_ajax_popup.gif645.44 KBa.milkovsky

Comments

a.milkovsky created an issue. See original summary.

a.milkovsky’s picture

Status: Active » Needs review

Created a prototype sandbox module: https://www.drupal.org/sandbox/milkovsky/3280575

Feedback is welcome.

a.milkovsky’s picture

StatusFileSize
new645.44 KB

Example of work:

christianadamski’s picture

Status: Needs review » Needs work

Instead of a sandbox, please do a merge request

christianadamski’s picture

I think the saner approach is something like:

$rowPlugin = $this->view->rowPlugin;
    foreach ($data_provider->getPositionsFromViewsRow($row, $this->view->field[$this->options['geolocation_field']]) as $position) {
      if (
        $rowPlugin instanceof EntityRow
        && !empty($row->_entity)
        && $row->_entity instanceof EntityInterface
      ) {
   // Prepare Ajax Command Link
              $row->_entity->id(),
              $rowPlugin->getEntityTypeId(),
              $rowPlugin->options['view_mode'],

and then later something like

  public function ajaxLinkCallback($nojs = 'nojs') {
    // Determine whether the request is coming from AJAX or not.
    if ($nojs == 'ajax') {
      $output = $this->t("This is some content delivered via AJAX");
      $response = new AjaxResponse();
      $response->addCommand(new AppendCommand('#ajax-example-destination-div', $output));

      // See ajax_example_advanced.inc for more details on the available
      // commands and how to use them.
      // $page = array('#type' => 'ajax', '#commands' => $commands);
      // ajax_deliver($response);
      return $response;
    }
    $response = new Response($this->t("This is some content delivered via a page load."));
    return $response;
  }

christianadamski’s picture

Based on this an option could be added, if the row plugin is an entity (so not fields), it can be reproducibly loaded by ajax.

When using fields, this does not work.

christianadamski’s picture

Status: Needs work » Closed (outdated)

This is best solved via a custom "MapFeature" plugin.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.