Hi all,

I'm having the following error:

Exception: Invalid GeoJSON: GeometryCollection with no component geometries a GeoJSON->objToGeometryCollection() (línia 104 de /XXX/sites/all/modules/contrib/geophp/geoPHP/lib/adapters/GeoJSON.class.php).

seems like when the node has not value for the geofield the leaflet_widget_geojson_feature is calling GeoPHP::load with a wrong json value. Adding this line at the function the error disapears:

function leaflet_widget_geojson_feature($wkt, $properties = array()) {                                                                                                                                                                                                                                                       
    $geophp = geophp_load();
   if (!$geophp) return FALSE;                                                                                                                                                                                                                                                                                                
      
// --> Added line
  if($wkt == 'GEOMETRYCOLLECTION EMPTY') return FALSE;                                                                                                                                                                                                                                                                       
                                                                                                                                                                                                                                                                                                                               
    $geometry = geoPHP::load($wkt, 'wkt');
    return array(
      'type' => 'Feature',
      'geometry' => json_decode($geometry->out('json')),
      'properties' => $properties,
    );
  }

Anyone can take a look to this?

thank you so much

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

eleuthere’s picture

I use Leaflet to geolocalise events.
I added geofield fields to events that have a logo image : logo is an image, geocoord and logocoord are geofields.
Geocoder reads GPS coordinates in the image to set logocoord.
A rule copies logocoord into geocoord if logocoord is set and geocoord is empty.

With original Leaflet.widget, all worked fine if I used a geolocalised photo or if I setup th event coordinates with the leaflet widget at creation time. Then I could change coordinates afterward. If the coordinates were not set at creation time, I could not place any marker on the widget to set them nor change the logo image.

I edited xxx/sites/all/modules/leaflet_widget/leaflet_widget.module to make the change you propose.
Now, I can set the coordinates with the widget.
Nevertheless, if the geocoord are not set, I can't set them by changing the logo. I have this error in a popup:

"An AJAX HTTP request terminated abnormally.
Debugging information follows.
Path: /?q=file/ajax/field_group_logo/und/0/form-Wa3BGM4VLhIkL0Occl1nksMQkH1c76TIpQYyNYJzp1o
StatusText: n/a
ResponseText:
Blablabla
Error
Error messageException: Invalid JSON in GeoJSON->read() (line 23 of xxxxx/sites/all/modules/geophp/geoPHP/lib/adapters/GeoJSON.class.php).
The website encountered an unexpected error. Please try again later.

ReadyState: undefined"

If I set geocoord with the widget (as it became possible), then I can suppress and replace the logo.

I hope this feedback will help and I stay available to go forward.

vlooivlerke’s picture

Thanks this works for me.
Without this patch it has detrimental effects on node save if the geofield is left empty

mvlabat’s picture

Version: 7.x-2.0-beta1 » 7.x-2.x-dev
Status: Active » Needs review
FileSize
519 bytes

Created a patch using the code from the topic. Adapted it for the latest dev version. It works.

Valentine94’s picture

Status: Needs review » Reviewed & tested by the community

Works for me, I happy to change issue status to RTBC :)

Thanks.

suffering drupal’s picture

Hello, I had the problem of the error message as well. The added line did solve that problem for me.

However, it does not solve the problem that an empty, completely grey map appears on the content page, stating "leaflet" in the lower right corner, when you don't give any location data (put some marker on the map).
Any suggestions?

Thanks.

N20’s picture

#3 works for me.

I read here that not all maps working with leaflet_widget module. I worked around that using "osm-landscape - layer" map in backend to draw. Frontend i assigned a Google map. Works like a charm.

suffering drupal’s picture

Tnx, will try.

jorges’s picture

The patch in #3 still caused the error described in #1. So I made a better patch. Instead of returning FALSE, I return an array with an empty FeatureCollection.

This doesn't cause an error in my project anymore.

slash3b’s picture

FileSize
1.25 KB

Hi. I had an issue with images upload and form submission, unfortunately suggested solutions above did not help me. I've made another patch which solves my problem, may be it is going to help someone else.
Critics and comments are welcome.
Thank you.

MatthijsG’s picture

I think, in my case was the LAT/LON-configuration in the setup not correct: it contained a ,

@slash3b
patched your patch. Is (original) line 251

return FALSE;
  }

ment to stay? The patch gives me an error on the line } else {
There is something wrong with the block. Not sure what exactly.

MatthijsG’s picture

Is this issue the same problem as https://www.drupal.org/node/2399733 ??

The solution over there is a bit simpler: only adding 3 extra lines.

fonant’s picture

FileSize
690 bytes

Here's an alternative solution, which simply wraps the geoPHP::load() method call in try/catch block. This will solve any problems with invalid geometry coming from the form, not just empty collections.