Hi,

Attached a port of Geofield to D8, including the submodule Geofield Map.

It would be really great if one of the maintainers could create an 8.x-1.x branch put the attached source in it and perhaps create an alpha release. A project page with a shiny 8.x badge on it shows we're really serious about maps and D8 at the same time!

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 have also ported Leaflet to D8 and the two work together well.

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 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 complete new D8 source, including the .git subdirectory.
I don't have an up-to-date patch file, but since this would be the start of a new branch it doesn't really mater.

Enjoy D8!

Rik

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Brandonian’s picture

Hey Rik!

So, I've also started working on some 8.x ports to geofield/geophp. I've been working off D.O to play with some architectural changes that I want to introduce to 8.x. Any chance I can get you to do a pull request there? Otherwise, I'll definitely take a look. It sounds like you've probably gotten a little bit farther ahead of me in terms of functionality, which is cool.

Geofield 8.x: https://github.com/fillerwriter/geofield
Geophp 8.x: https://github.com/fillerwriter/geoPHP-module

RdeBoer’s picture

Hi Brandon,

Silly me... should have asked first if someone had already started on this... I looked on the project page and saw little activity, but didn't think that the activity might be going on elsewhere...

Anyway, I don't think all of my work is wasted. Happy to morph my straight D7->D8 port into your fillerwriter playpen on GitHub, if that's what you're asking?

With the arrival of Symfony new files will be entering the scene, as opposed to changes to existing files, so merging yours with mine should be fairly easy. I've done the 3 Proximity plugins for Views (field, sort, filter) and also the complete Geofield Map Views interface, which it seems hasn't been done on Github yet. So that should work out nicely.

I do feel it would be great if we can very soon, e.g. after merging it all on Github, have a half-working 8.x branch working on drupal.org too, though. It just sends a great message to the Drupal community.

Rik

RdeBoer’s picture

Hi Brandon,
I've forked fillerwriter/geofield to my RikdeBoer account on GitHub.
Do you want me to do my pull request with respect to your fillerwriter master branch?
Is the master branch on fillerwriter/geofield the same as the Drupal.org 7.x-2.x branch?
Rik

RdeBoer’s picture

Ok, all done, Brandon!
Added my bits (in particular the Views extensions) to your fillerwriter/geofield master and initiated Pull Request on GitHub.
It's all yours!
Rik

Brandonian’s picture

Sweet! I'll keep this ticket open as a reminder to pull that code back into the d.o repo soon. I agree this should happen sooner than later.

RdeBoer’s picture

Great, Brandon!
Keep in mind that the geofield.tgz at the top of this issue is a functional D8 version, including the (old-style) data entry widgets, successful saving etc., so may be worth keeping at hand if you aim to flesh out the 8.x-1.x branch on D.O. based on the GitHub version.
Rik

RdeBoer’s picture

FileSize
495.32 KB
18.62 KB

Here's a port of Geofield post D8 core freeze.

I had to move GeofieldBackendDefault.php up a directory. I couldn't get the annotation system to scan down to the Plugin directory/namespace that file was in.

Works with the existing geoPHP 8.x-1.x without changes.
Geofield Map also works.
Attached are the complete module as well as the patch file.

# On branch 8.x-1.x
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#	renamed:    lib/Drupal/geofield/Plugin/GeofieldBackend/GeofieldBackendDefault.php -> lib/Drupal/geofield/GeofieldBackend/GeofieldBackendDefault.php
#
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#	modified:   lib/Drupal/geofield/GeofieldBackend/GeofieldBackendDefault.php
#	modified:   lib/Drupal/geofield/Plugin/field/field_type/GeofieldItem.php
#	modified:   lib/Drupal/geofield/Plugin/field/formatter/GeofieldDefaultFormatter.php
#	modified:   lib/Drupal/geofield/Plugin/field/widget/GeofieldDefaultWidget.php
#	modified:   lib/Drupal/geofield/Plugin/field/widget/GeofieldLatLonWidget.php
#	modified:   lib/Drupal/geofield/Plugin/views/field/GeofieldProximity.php
#	modified:   lib/Drupal/geofield/Plugin/views/filter/GeofieldProximity.php
#	modified:   lib/Drupal/geofield/Plugin/views/sort/GeofieldProximity.php
#	modified:   modules/geofield_map/geofield_map.info.yml
#	modified:   modules/geofield_map/lib/Drupal/geofield_map/Plugin/views/style/GeofieldMap.php
#
diff --git a/lib/Drupal/geofield/Plugin/GeofieldBackend/GeofieldBackendDefault.php b/lib/Drupal/geofield/GeofieldBackend/GeofieldBackendDefault.php
similarity index 100%
rename from lib/Drupal/geofield/Plugin/GeofieldBackend/GeofieldBackendDefault.php
rename to lib/Drupal/geofield/GeofieldBackend/GeofieldBackendDefault.php

A few red herrings, like lat/lon having to be reversed for WKT POINTs.
The Proxomity field doesn't show in Views. Not sure why.

Brandonian’s picture

Committed patch in #7. Thanks, @RdeBoer!

http://drupalcode.org/project/geofield.git/commit/f6858a7

Brandonian’s picture

Issue summary: View changes

Added note on 8.x release

  • Brandonian committed f6858a7 on 8.x-clear-files authored by RdeBoer
    [#1957760] - general cleanup of what's been done so far in D8 port
    
Jean-Philippe Bousselin’s picture

Hi guys, there is an issue with GeoConstraint because the annotation should now be "Constraint" and not "Plugin". Here's the patch!

vdsh’s picture

Version: 7.x-2.x-dev » 8.x-1.x-dev
vdsh’s picture

Issue in the administration with FieldFormatter incorrectly set (issues with $options and $formOptions) preventing from choosing the display option

alarcombe’s picture

Can confirm patch #10 works (https://www.drupal.org/node/1957760#comment-10124388) and is required for geofield to work correctly.

ExTexan’s picture

I've applied patches #10 and #12 to the dev branch, but I still get the "GeoType plugin does not exist" error. I realize that's not what this issue is about, but https://www.drupal.org/node/2535450 is flagged as a duplicate and refers everyone to this issue.

I'm actually a bit confused about comment #13. The #10 patch is only changing comments, not actual code, so how could that be required for geofield to work correctly?

In any case, does anyone know if a patch exists for the "GeoType plugin does not exist" error? I get it whenever I populate the lat/long fields and try to save the node.

kpv’s picture

Actually it's not just a "comment" but part of plugin annotation which is used in plugin discovery process.

alarcombe’s picture

@ExTexan - @kpv is right, those comments are used by Drupal's plugin mechanism to detect and cache the various plugins. The change in comment 13 is because the name of the verification plugin types changed in core. This is why you cannot save the contents of a geofield without that patch, as verification fails.

I found that in order to get geofield working you need the following:

latest HEAD of geofield
latest HEAD of geophp enables creation of field and saving settings.

This patch for geofield https://www.drupal.org/files/issues/geofield-annotations_fixes-1957760-1...
This patch for geofield https://www.drupal.org/files/issues/geofield-formatter_fix-1957760-12.patch
This patch for geofield https://www.drupal.org/files/issues/geofield-geolocation-fix-2573983-1.p...
This patch for geophp https://www.drupal.org/files/issues/geophp-add_getadaptermap_method-2463...
This patch for geophp https://www.drupal.org/files/issues/geophp-safemarkup.patch

ExTexan’s picture

Excellent! Thanks for the detailed reply.

I'll give that a try.

pmackay’s picture

May I ask, what's the current state of geocoding from another field? Might it be useful to list in the summary what parts of D7 geofield are supported in D8 version?

  • plopesc committed aa3d9d2 on 8.x-1.x authored by vdsh
    Issue #1957760 by RdeBoer, vdsh, Jean-Philippe Bousselin, alarcombe:...
plopesc’s picture

Hello all.

I already committed all the patches listed in #16. Could someone take a look to confirm all the things are working now?

Thanks!

juliencarnot’s picture

Hi all,

Regarding plopesc's last question, I just installed Geofield 8.x-1.x-dev from 2015-Nov-23 with PHPgeo version 8.x-1.0-beta1 from 2014-Oct-28 on my D8 install. Geofield seems to install correctly, but I get a blank page when saving the changes after adding a geofield lat/long field to a content type, with this error:
PHP Fatal error: Call to undefined method Drupal\\geophp\\GeoPHPWrapper::load() in /[...]/modules/geofield/src/Plugin/Field/FieldType/GeofieldItem.php on line 206, referer: /[...]/admin/structure/types/manage/ressource/fields/node.ressource.field_geofield?destinations%5B0%5D%5Broute_name%5D=entity.node.field_ui_fields&destinations%5B0%5D%5Broute_parameters%5D%5Bfield_config%5D=node.ressource.field_geofield&destinations%5B0%5D%5Broute_parameters%5D%5Bnode_type%5D=ressource&destinations%5B1%5D=/[...]/admin/structure/types/manage/ressource/fields/add-field

When I go back to the field list (/admin/structure/types/manage//fields), the field has been added. The next tab (form-display) seems to work fine, but the "display" tab gives me another blank page:

PHP Fatal error: Call to undefined method Drupal\\geophp\\GeoPHPWrapper::getAdapterMap() in /[...]/modules/geofield/src/Plugin/Field/FieldFormatter/GeofieldDefaultFormatter.php on line 59, referer: /[...]/admin/structure/types/manage/ressource/form-display

Hope this helps, and thanks to all the contributors so far!

balagan’s picture

I am using the 8.x-1.x branch (also Nov. 23). Everything is working fine, I can add geofield to content type with no problem. Only when I create a content of that type, I get the "The "GeoType" plugin does not exist." error.

scottholmes’s picture

I have several content types in a Drupal 7 site that contain geofields. These were not recognized by drupal's migration to drupal 8 modules. I don't know if this is a problem of much significance at this point to geofield's porting efforts. I have not tried entering data manually and I don't know if this is something I need to tweak in using migration.

sillygwailo’s picture

juliencarnot: what happens if you use the dev branch of the geoPHP module? I encountered the first error you mention. Then I updated to the latest dev version of geoPHP (not GeoField), and was able to add content.

juliencarnot’s picture

sillygwailo: Sorry, I moved to Geolocation field for now and don't have enough time to test this on a clean environment, but I guess your suggestion would solve my initial problem!

gdelver@xs4all.nl’s picture

Hi, I am testing geofield with address and geocoder and leaflet. I got the adsress with geocoding working (nice and thanks!). Leaflet produces a blanc screen when i add it to the display format (leaflet map) of the geofield. I tried the 8.x-1.0-alpha1 and the 8.x-1.x-dev versions. Both produce the same problem. For the geofield I use 8.x-1.0-alpha2. I use the leaflet Leaflet 1.0.0-rc1 library and put it in sites/all/libraries/leaflet as indicated. So where do I go wrong? I read that that work well together. Any advise will be appreciated greatly. Guido.

FMB’s picture

pmackay: you'll need the Geocoder module in order to geocode from another field.

gdelver@xs4all.nl’s picture

@FMB: I have a full set working now in production for some time with geofield, geocoder, address field and leaflet including the leaflet more maps. Works fine. I am eager to use e.g. some of the input features that have not been converted yet leaflet input widget. It turns out that not all of the features have been moved to d8 in both geofield and leeaflet...

FMB’s picture

gdelver@xs4all.nl: regarding Leaflet Widget, see #2654864: Port to Drupal 8 and https://github.com/bforchhammer/leaflet_widget, which works although it does not seem to be currently maintained, and it is obviously not on drupal.org.

gdelver@xs4all.nl’s picture

@FMB, thanks for the tip. I will give it a try asap and report back.

vitaliych’s picture

@gdelver@xs4all.nl could you please explain me how you made that work for you step - by step
i'm trying to make it worked address module for D8 plus geofield+geocoder+geocoder address+leaflet
all steps
1 installation
2 configuration

There are no Documentation for D8 at the moment

Regards

itamair’s picture

Status: Active » Closed (outdated)