Port the leaflet_widget to Drupal 8.

CommentFileSizeAuthor
#6 new_leaflet_reroll-2654864-6.patch677 bytesskylord
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jian he created an issue. See original summary.

morsok’s picture

Category: Bug report » Feature request
Priority: Normal » Major
Status: Active » Needs review

I found a Drupal 8 version on github : https://github.com/bforchhammer/leaflet_widget

It seems to work fine for me.

fran seva’s picture

Assigned: Unassigned » fran seva
Status: Needs review » Needs work

Hi -- I have tested the D8 branch created by @webflo and looks good. I think we have to review it and add it to a new leaflet_widget branch for D8.
I'm going to work on it and create that new branch with the approach in github and then we could iterate. I think a leaflet widget for geofield is needed.

Could someone create a D8 module version tag? cc/ @das-peter @tnightingale

FMB’s picture

Assigned: fran seva » Unassigned

The version on Github works fine indeed. How about welcoming it in a cozy D8 branch on drupal.org?

juves’s picture

Github version doesn't work for me on latest Leaflet and Geofield.

The website encountered an unexpected error. Please try again later.

Error: Call to undefined function Drupal\leaflet_widget\Plugin\Field\FieldWidget\leaflet_render_map() in Drupal\leaflet_widget\Plugin\Field\FieldWidget\LeafletWidget->formElement() (line 160 from /var/www/html/web/modules/contrib/leaflet_widget/src/Plugin/Field/FieldWidget/LeafletWidget.php) #0 /var/www/html/web/core/lib/Drupal/Core/Field/WidgetBase.php(335): Drupal\leaflet_widget\Plugin\Field\FieldWidget\LeafletWidget->formElement(Object(Drupal\Core\Field\FieldItemList), 0, Array, Array, Object(Drupal\Core\Form\FormState)) ..................
skylord’s picture

Status: Needs work » Needs review
FileSize
677 bytes

It's because of slightly changed leaflet module API to be more D8 aware (global function replaced with service). Simple patch to github version attached. BTW, module is working like a charm - wonder why it's still not in drupal.org repo and we don't have alpha/beta release at least. What other map input widgets with D8 support are there? Any based on google maps are out of the race because of new Google use conditions. geofield_map with leaflet support? It redundant in many cases an lives out of leaflet modules stack and uses own library references... So, D8 release is a must - especially in our case when ready for production code exists for 4 years (!!!) on github.

FMB’s picture

#6 works, thanks.

By the way, I'm willing to help maintain this module.

FMB’s picture

Status: Needs review » Reviewed & tested by the community
juves’s picture

Installed, patched. Placing a marker on a map doesn't fill/update a geo_field. It also doesn't show a marker on existing coordinates.
http://i63.tinypic.com/30le2jk.jpg

FMB’s picture

juves: did you install the Wicket library? Here is what I use in my composer.json file, under the "repositories" key:

        "wicket": {
            "type": "package",
            "package": {
                "name": "arthur-e/Wicket",
                "version": "1.3.4",
                "type": "drupal-library",
                "dist": {
                    "url": "https://github.com/arthur-e/Wicket/archive/1.3.4.zip",
                    "type": "zip"
                }
            }
        }

You will have to launch this command afterwards: composer require arthur-e/Wicket.

juves’s picture

Oh, I should have read the README :)

handkerchief’s picture

Is this going forward? This is a great module, that is useless, if no official drupal 8 version is available.

handkerchief’s picture

The only alternative at the moment, but with a lot of additional features you don't necessarily need and it is currently still based on google maps:

https://www.drupal.org/project/geofield_map

See also my feature request for the widget #3022269: Option: Do not set a marker manually
But this is optional/additional.

So please can anyone give FMB the maintainer role of this project if not already done?

mmjvb’s picture

That is not how it works, for correct procedure see https://www.drupal.org/node/251466

handkerchief’s picture

@FMB what do you think? Or what's next?

FMB’s picture

handkerchief: I've formally applied in #3022839: Offering to co-maintain Leaflet Widget for Geofield and e-mailed das-peter, we'll see what happens.

FMB’s picture

Version: 7.x-2.x-dev » 8.x-1.x-dev
Status: Reviewed & tested by the community » Fixed

Congratulations, we now have a Drupal 8 release! I pushed bforchhammer's code into a new D8 branch, applied skylord's patch and slightly corrected it in order to use dependency injection. I also fixed coding standards issues.

handkerchief’s picture

Great! I will look into this! Thx for your support and work.

todda’s picture

Hi,

i just found your Module and i´ve installed it and it looks great!!!
I´ve searched for a Leaflet Plugin, where i can draw on leaflet maps. Will this feature be available soon?

Sry for my english. I´ve tried the geofield_map and other mapping modules, but in your description is everything i´ve been looking for.

So, can you tell me, if the drawning / polygon Feature is planned?

Thank you,,

Todda

FMB’s picture

Thanks todda for your feedback.

Concerning your request, this would preferably go into a new issue (feature request), the current one was about porting Leaflet Widget to Drupal 8. Do you have a precise plugin in mind?

todda’s picture

Hi FMB,

i´m building a website where users create locations, for example places, where you can find something like geo-caching.
Now i want to give the option of drawing routes/lines on the map to show other users, where they can go for a walk.
I know that leaflet has the following options:
http://2.bp.blogspot.com/-KWtBMMOCBCY/UuQEhGMGZKI/AAAAAAAAAk0/SeD6vzbVaF...

but there is no!!!! drupal 8 module, where drawing on a leaflet map is possible.

FMB’s picture

todda: I do not know whether this is a widget issue. Still, could you please create a separate issue (feature request) for this? We could assign it to another project if needed.

todda’s picture

hello fmb,

now i've created an issue / Feature request for my question. Thank you for your help and your great work for porting this module to drupal 8,,

todda

Status: Fixed » Closed (fixed)

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

Andy-vv’s picture

hello skylord - I wonder if you can help me out? I'm having a problem in updating the .json to activate wicket. It might be more than I can manage.

I am a bit of a newbie to drupal, and not much of a coder. I have been trying to get drupal 8 to allow me to render a leaflet map with two points joined by a line. I have installed all the modules (including leaflet widget 8x-2.0) and installed the wicket library. I can render a leaflet map with two points on, but no line between them. I am stuck at the point where I need to add the code to my .json file

"wicket": {
"type": "package",
"package": {
"name": "arthur-e/Wicket",
"version": "1.3.4",
"type": "drupal-library",
"dist": {
"url": "https://github.com/arthur-e/Wicket/archive/1.3.4.zip",
"type": "zip"
}
}
}

Wherever I put hte code in the .json i get an error like the following:

quote
gnome (devel) $ composer require arthur-e/Wicket

[Seld\JsonLint\ParsingException]
"./composer.json" does not contain valid JSON
Parse error on line 137:
...} } }}"wicket": { "typ
------------------^
Expected one of: 'EOF', '}', ',', ']'

unquote

I wonder if you could give me a layout of what the .json looks like above and below the snippet? or else tell me that this is beyond my paygrade, and then I will stick to just having tow points on the map until an integrated module for beginners works :)

Regards,
Andy

FMB’s picture

Andy-vv: please create a new issue (support request) and attach your whole composer.json file there. I guess it lacks a comma or something. Now, I don't think you need Wicket for this version. Keep in mind this is a widget module, which is not responsible for map rendering: you need a field formatter to do so.

mmjvb’s picture

Looks like a missing , in front of "wicket".
Or you need to remove the "wicket" when put in composer.json "repositories".

Andy-vv’s picture

FMB and mmjvb many thanks for the help, much appreciated. I added an extra comma after the new code and now I get a different error message, so something worked :) I will create a new issue support request with the new situation as FMB suggested.