I thought I'd start the ball rolling for a D8 port.

The attached port works with the Leaflet Demo submodule inside the Leaflet More Maps module, which I ported recently. It demonstrates on a single page 26 maps rendered through Leaflet, including Google Maps.

While I've also ported the Leaflet Views submodule, we can't show any markers yet, because Geofield hasn't been ported yet. But I thought having an 8.x-1.x-dev branch of Leaflet publicly visible and available on the project page, may inspire others to get cracking with the D8 port of Geofield.

Note:
o the D8 version is NOT dependent on the Libraries module (a single line needs to be removed to make this happen, see leaflet.module, line# 18.
o you need to change TRUE to FALSE in function drupal_merge_js_settings($settings_items), file includes/common.inc. See also this issue http://drupal.org/node/1875632#comment-7225104
o patch file is inside the attachment, which is the complete D8 module with all its added and deleted files

Comments

pvhee’s picture

Great initiative Rik! I'll review whenever I find a bit of time, and start the D8 branch.

rdeboer’s picture

StatusFileSize
new98.59 KB
new879 bytes
new9.54 KB

Thanks Peter.

I have just completed the D8 port of Geofield on my local machine, which I'll upload to the Geofield issue queue later today.

This has allowed me to test the above Leaflet D8 port more thoroughly and to make a few corrections.
Note that I've also ported geoPHP, which was trivial. Only had to change the .info file to .info.yml! See http://drupal.org/node/1956004

I can now confirm that Leaflet Views works with Geofield and so does the Leaflet format on nodes that have a Geofield.

There's only one little niggling issue: for some reason the Geofield data is not available in the Views raw results data structure. However it IS available in the Views RENDERED results. So I have enhanced the Leaflet D8 code to accept either. If the data IS in the normal place it will take it from there. If for some reason it isn't, it will talke the data from the rendered Views results.
So if this issue gets fixed in a later release of Geofield and/or Views, the code will continue to work without the user having to change anything.

Attached "git commit" report to show all change/added/deleted files and the patch file showing all changes to existing files. Also the complete new D8 source, including the .git subdirectory.

Enjoy D8!

Rik

rdeboer’s picture

StatusFileSize
new110.94 KB
new14.27 KB

Now that the D8 core API is frozen, I've updated the above D8 port.
This version works well with this recent Geofield D8 port https://drupal.org/node/1957760#comment-7741619 and with the current D8 release of geoPHP, available as per normal from the project page https://drupal.org/project/geophp

The View-as-a-map function works. I haven't done the formatter class yet to render a map on the node view page.

I'm happy to that as soon as an 8.x-1.x branch has been created and the attached code put in it.

The attached patch file is against 7.x-1.x. Because of a change in the way D8 core now deals with multiple occurrences of the JS settings I had to change leaflet.drupal.js a little, so that we can have multiple Leaflet maps on the same page, as demonstrated in the Leaflet Demo submodule inside the Leaflet More Maps projects (also ported to D8).

# Changes to be committed:
#
#	renamed:    leaflet.info -> leaflet.info.yml
#	renamed:    leaflet_views/leaflet_views.info -> leaflet_views/leaflet_views.info.yml
#	deleted:    leaflet_views/leaflet_views.install
#	modified:   leaflet_views/leaflet_views.module
#	deleted:    leaflet_views/leaflet_views.views.inc
#	renamed:    leaflet_views/leaflet_views_plugin_style.inc -> leaflet_views/lib/Drupal/leaflet_views/Plugin/views/style/LeafletMap.php
#	renamed:    leaflet_map.tpl.php -> leaflet_views/templates/leaflet_map.tpl.php
#
#	modified:   leaflet.drupal.js
#	modified:   leaflet.formatters.inc
#	modified:   leaflet.info.yml
#	modified:   leaflet.install
#	modified:   leaflet.make.example
#	modified:   leaflet.module
#	modified:   leaflet_views/leaflet_views.info.yml
#	modified:   leaflet_views/lib/Drupal/leaflet_views/Plugin/views/style/LeafletMap.php
#
#	added:      leaflet_views/templates/leaflet_map.html.twig

Attached are the patch file as well as the complete source, ready to be installed.

rdeboer’s picture

Assigned: Unassigned » rdeboer
Status: Active » Fixed

Applied to 8.x branch. May need a refresh as 8.x is not stable yet.

Status: Fixed » Closed (fixed)

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

bforchhammer’s picture

Issue summary: View changes
Related issues: +#2366069: Drupal 8 version not working

May need a refresh as 8.x is not stable yet.

Indeed :)