Hi, I am using leaflet,leaflet views on drupal 8. The field type i use for location content type is 'geofield'. I can display the leaflet map view for individual content. but when I create a view, it is always blank. There is nothing showing up.

CommentFileSizeAuthor
#3 2902898-fix.patch1.92 KBpitop
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jestinijames created an issue. See original summary.

pitop’s picture

Hi I had the same problem, incompatibility with the new version of Views.

pitop’s picture

FileSize
1.92 KB

Just created this patch that try to fix this issue - pb for me when using the Leaflet map (old) Settings

alarcombe’s picture

ladamiak’s picture

Hi... I have the exact same problem.

As I can see, the problem is that the "Features" array is beeing rendered empty on the js output, as the code bellow.

"options":{"attribution":"OSM Mapnik"}}}},"features":[]}},

I realized that when we get to the "render()" function in leaflet_views\src\Plugin\views\style\Leaflet.php the object "$this->view->attachment_before" is empty.

I just don't know where it's beeing populated. :(

ladamiak’s picture

just for note, in order to show the markers on the map I've changed temporarily, in leaflet_views\src\Plugin\views\style\Leaflet.php, this code:

    foreach ($this->view->attachment_before as $id => $attachment) {
      if (!empty($attachment['#leaflet-attachment'])) {
        $features = array_merge($features, $attachment['rows']);
        $this->view->element['#attached'] = NestedArray::mergeDeep($this->view->element['#attached'], $attachment['#attached']);
        unset($this->view->attachment_before[$id]);
      }
    }

for this:

    $res = func_get_args()[0];
    $features = array();
    foreach ($res as $id => $attachment) {
      array_push($features, array("type" => strtolower($attachment->_entity->field_geofield->geo_type),"lat" => $attachment->_entity->field_geofield->lat,"lon" => $attachment->_entity->field_geofield->lon,"popup" => $attachment->_entity->title->value));
    }
s-jack’s picture

The patch seems to be working for me.
Thanks.

paul_canning’s picture

The patch will not apply to the 1.x-dev branch.

Gathering patches for dependencies. This might take a minute.
  - Installing drupal/leaflet (dev-1.x da0386d): Cloning da0386d509 from cache
  - Applying patches for drupal/leaflet
    https://www.drupal.org/files/issues/leaflet-recognize_geofield-2839538.patch (LeafletMarker could not recognize geofield)
    https://www.drupal.org/files/issues/2902898-fix.patch (Leaflet not compatible with new version of Views)
   Could not apply patch! Skipping. The error was: Cannot apply patch https://www.drupal.org/files/issues/2902898-fix.patch

This is what I get from 'composer update drupal/leaflet'

Any ideas?

EDIT - I tried just using the patch from this issue (as it seems like the patch for the Leaflet MarkerCluster issue is mostly the same) and it still doesn't work. I just get a map that shows the entire world, no markers, despite my filtered nodes having a geolocation field. Is it correct that there is only basic settings for 'Leaflet" such as map type and size? "Leaflet (Old)" has much more indepth settings....

s-jack’s picture

Hi,@paul_canning.

I have patched for leaflet dev-1.x.
My environment is geofield.
You may have to look for some problems in the geolocation field.
https://www.drupal.org/project/issues/geolocation?text=&status=Open&prio...

OSM maplink views quickly with marker cluster, but some more map type views blank or so slowly.
I installed marker cluster is dev-1.x.
I can't imagine the cause.

You should reinstall modules are geolocation field, leaflet as developer version and appropriate javascript libraries, then you try to apply some appropriate patches to them.

Try rebuild.

GaëlG’s picture

Status: Active » Closed (duplicate)

Duplicate of #2839538