I have set a leaflet field formatter for a geofield field. When this geofield contains a linestring, I get Fatal error: Call to a member function getComponents() on a non-object. With a point there is no error, but the displayed map does not contain a marker and cannot be zoomed. I should open another issue for that.

CommentFileSizeAuthor
#6 1912716.patch1.14 KBbalagan

Comments

balagan’s picture

I get the same error with the beta version, and not sure if it is related to this, but I also got Notice: Undefined index: wkt in leaflet_process_geofield() (line 272 of F:\...\sites\all\modules\leaflet\leaflet.formatters.inc).

balagan’s picture

I am setting the data of geofield from code, and it contains for example LINESTRING (20.03624 47.9022243, 20.0361933 47.9022289, 20.0362102 47.9022034, 20.0362435 47.9021819, 20.036252 47.9021677)
Maybe I messed up something with my code, but still don't know what.

balagan’s picture

Category: bug » support
Priority: Critical » Normal

I had an idea, what might be wrong. I am using version = "7.x-2.0-alpha2+6-dev" of geofield. I have found a code, where the field was set like this:

  $node->field_wptgeofield[$node->language][0]['wkt'] = 'POINT ('.$lon.' '.$lat.')';
  $node->field_wptgeofield[$node->language][0]['geo_type'] = 'point';

When I tried this, I got Notice: Undefined index: geom in geofield_field_presave() (line 292 ... so I solved it with

  $node->field_wptgeofield[$node->language][0]['geom'] = 'POINT ('.$lon.' '.$lat.')';
  $node->field_wptgeofield[$node->language][0]['geo_type'] = 'point';

It must be my fault, I have to still find out how to properly set geofield from code. With the wkt array there is no fatal error, just a gray map.

balagan’s picture

Project: Leaflet » Geofield
balagan’s picture

Just tried what is proposed in the documentation, but

  $node->field_trackgeofield[$node->language][0]['geom'] = $linestring;
  $node->field_trackgeofield[$node->language][0]['input_format'] = 'GEOFIELD_INPUT_WKT';

gives me: Fatal error: Uncaught exception 'Exception' with message 'geoPHP could not find an adapter of type GEOFIELD_INPUT_WKT'

That was with devel version of geoPHP and geofield. With the latest stable versions I get Notice: Undefined index: wkt in geofield_compute_values() (line 191

balagan’s picture

Project: Geofield » Leaflet
StatusFileSize
new1.14 KB

Ok, last night I did some debugging of both leaflet and geofield. It seems the dev version of geofield changed the structure of its array, and no longer uses ['wkt'] dimension, but it introduced the ['geom'] dimension. The dev version of leaflet still does not support it, so I move back this bug to leaflet and attach a patch that is working for me. I think the dev version of Leaflet should support the dev version of geofield.

balagan’s picture

Category: support » bug
Priority: Normal » Critical
pvhee’s picture

Thanks for finding out the issue that caused this, but I am not sure whether this is a patch we can apply safely in Leaflet. As for now, Leaflet seems to evolve at a faster pace than Geofield, so if we add that patch, the next beta release of Leaflet will have to rely on a development snapshot of Geofield, and on the 2.x version of the module, while right now the 1.x version is recommended.

I'd maybe like to see Geofield promoting first the 2.x branch as the recommended release (even in alpha) before we add this to Leaflet. If not, when people enable both Geofield and Leaflet with the recommended releases, there will be a problem...

balagan’s picture

Ok, who need support for geofield dev, will find this patch here. By the way, I think geofield dev now stores data in wkb, so I hope they roll out a new recommended release soon and users can benefit from it.

pvhee’s picture

Great, as soon as they roll out a new recommended release we should update Leaflet as well. Keeping this issue open to track.

aaronbauman’s picture

see also #2093273: [meta] Create a 2.x branch corresponding to geofield-2.x branch
to hopefully resolve future problems like this.

rdeboer’s picture

Assigned: Unassigned » rdeboer
Status: Active » Fixed

Fixed with this commit: http://drupalcode.org/project/leaflet.git/blobdiff/b13e96466886c002045f1...
Leaflet is now compatible with both versions 7.x-1.x and 7.x-2.x of Geofield.
Duplicate of #1996056: Compatibility with Geofield 7.x-2.0 and later
Rik

aaronbauman’s picture

Awesome, thanks Rik

Status: Fixed » Closed (fixed)

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