Notice: Undefined index: in geoPHP::load() (line 62 of /Users/pablocc/Sites/bluesparklabs/PDGA/www/sites/all/modules/contrib/geophp/geoPHP/geoPHP.inc).
Exception: geoPHP could not find an adapter of type in geoPHP::load() (line 65 of /Users/pablocc/Sites/bluesparklabs/PDGA/www/sites/all/modules/contrib/geophp/geoPHP/geoPHP.inc). Backtrace:

geoPHP::load(NULL) geofield.widgets.openlayers.inc:167
openlayers_field_widget_form(Array, Array, Array, Array, 'und', Array, 0, Array) field.form.inc:112

This happens due the $items variable is received with empty lat/lon, E.x.:

Array
(
    [0] => Array
        (
            [geom] => 
            [geo_type] => 
            [lat] => 
            [lon] => 
            [left] => 
            [top] => 
            [right] => 
            [bottom] => 
            [srid] => 
            [accuracy] => 
            [source] => 
        )
)

An attempt to initialize an geoPHP object with empty lat/lon raise the exception.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

citlacom’s picture

I fixed the previous issue adding a empty check on line 166 of geofield.widgets.openlayers.inc file:


   if (array_key_exists('geom', $item) && !empty($item['geom'])) {
      $geoms[] = geoPHP::load($item['geom']);
    }

But the then I get other exception due the else block that continue after this condition attempt to execute auto-detect of $item format that is an array instead of string that is what geoPHP expects:

Warning: fwrite() expects parameter 2 to be string, array given in geoPHP::detectFormat() (line 213 of /Users/pablocc/Sites/bluesparklabs/PDGA/www/sites/all/modules/contrib/geophp/geoPHP/geoPHP.inc).
Notice: Undefined index: in geoPHP::load() (line 62 of /Users/pablocc/Sites/bluesparklabs/PDGA/www/sites/all/modules/contrib/geophp/geoPHP/geoPHP.inc).
Exception: geoPHP could not find an adapter of type in geoPHP::load() (line 65 of /Users/pablocc/Sites/bluesparklabs/PDGA/www/sites/all/modules/contrib/geophp/geoPHP/geoPHP.inc). Backtrace:

geoPHP::load(Array) geofield.widgets.openlayers.inc:178

citlacom’s picture

I did a patch at level of geofield module that fix the problem, I created the issue here although I think is more in the side of Geofield.

Pol’s picture

Project: Openlayers » Geofield
Component: OL UI » Code

Just forwarding a bug that has been posted in the OpenLayers project.

GaborTorok’s picture

Status: Active » Needs review

The patch fixed the problem form me on current dev.
Setting to review so someone with more knowledge would review it.

Simon Georges’s picture

kiwimind’s picture

I don't think that this is a duplicate of that issue as I've applied the patch in that issue and the error mentioned in the initial post here still remains.

I can't get this patch to apply to current dev version, so am assuming it's going to need rerolling against that. It won't apply either after the patch in #1881056: Exception: geoPHP could not find an adapter of type in geoPHP::load() (line 54) or by itself.

If I get half a chance I'll re-roll it, but not sure when that's likely to happen.

kiwimind’s picture

Seems I made time. :)

Re-rolled against current dev.

Brandonian’s picture

Status: Needs review » Fixed

I believe this is fixed in the latest dev version of Geofield. Please reopen if the issue persists.

Status: Fixed » Closed (fixed)

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

jmdeleon’s picture

Was still seeing the exception in the logs with the latest July dev version referred to in #8, preventing content from being saved. Adding empty-check patch described in #1 to July dev resolved the exception.

palamida’s picture

download the new geoPHP library (version 1.1) from https://github.com/phayes/geoPHP
put it in sites/all/libraries/

so far so good - back on horse again

johnhanley’s picture

@palamida,

Thanks for the tip. I added geoPHP as you suggested using 7.x-2.0 and the exception went away.

Cheers,
John

heshanlk’s picture

Adding the 1.1 version of geoPHP as sites/all/libraries/geophp fixed the issue for me too. I'm not sure if geoPHP or Geofields module are looking for that site/all/libraries path (Geofield says it depends on the geoPHP) and geoPHP ships with 1.1 as well. Little confusing but this fixed the issue. Thanks.

heshanlk’s picture

This patch helped me to fix the formatter issue I had with the Geofield Map module.

heshanlk’s picture

Status: Closed (fixed) » Needs review
muschpusch’s picture

Status: Needs review » Needs work

Sorry tried #14 #7 and #11 all no luck with current dev and geofield map widget enabled...

ledbelly2142’s picture

I am really excited to get geoPHP and openlayers working with GIS data types, this will be a great set of mapping modules.

I realize this issue was closed, but...
I am still have the same issue as well. I thought this might be a library issue pointed out in other posts, but the updated geoPHP lib is in both the module and in 'libraries'.

Here is the error [notice]
Notice: Undefined index: in geoPHP::load() (line 51 of /...../sites/all/libraries/geoPHP/geoPHP.inc).

Exception: geoPHP could not find an adapter of type in geoPHP::load() (line 54 of /....../sites/all/libraries/geoPHP/geoPHP.inc).

I did not apply the patch and did not add an 'empty check' in the geofiled.widgets.openlayers.inc file (seems like this was fixed in the code in the latest geofield module release).

The current foreach statement around line 166 in geofield.widgets.openlayers.inc looks like:

foreach ($items as $delta => $item) {
    if (is_array($item) && array_key_exists('geom', $item)) {
      $geoms[] = geoPHP::load($item['geom']);
    }
    else {
      $geoms[] = geoPHP::load($item);
    }
  }

And the Undefined index in geoPHP.inc points to line 51 and 54, looks like this:


    $processor_type = $type_map[$type];

    if (!$processor_type) {
      throw new exception('geoPHP could not find an adapter of type '.htmlentities($type));
      exit;
    }

Line 51 is $processor_type = $type_map[$type];
and $type_map = geoPHP::getAdapterMap(); is on line 49

The static function getAdapterMap() just returns the adapter array in the adapter folder in the geoPHP lib. I am not sure if the getAdapterMap() function is finding the lib folder, although the lib is in two places (in the module geoPHP folder and in the libraries folder).
looks like:

<?PHP
static function getAdapterMap() {
return array (
'wkt' => 'WKT',
'ewkt' => 'EWKT',
'wkb' => 'WKB',
'ewkb' => 'EWKB',
'json' => 'GeoJSON',
'kml' => 'KML',
'gpx' => 'GPX',
'georss' => 'GeoRSS',
'google_geocode' => 'GoogleGeocode',
'geohash' => 'GeoHash',
);
}
?>

Not sure what the problem is, unless there is never any initial adapter type being specified...
One interesting clue is that when I tried to make a content type, I could not check the "required" field and save. When the required box was checked, the error (when trying to save the content type) was This field [content type name] cannot be left blank.

Any help is greatly appreciated. I running the drupal 7.23 with all the required openlayers modules.

Thanks in advance

ledbelly2142’s picture

Version: 7.x-2.x-dev » 7.x-2.0

I tried to use the patch in #14, but the patch failed with dry run. I patched the geofield_map.module manually with the patch. Still had the same problem when trying to create a node.

I also tried to create a node using the OpenLayers Example Content, with the same failure notice as above.

I would really like to get this working. If there is anything I can do to help, please let me know.

Thank you

muschpusch’s picture

Priority: Normal » Major

Setting this to major since it really breaks stuff...

ezman’s picture

Is this issue something to do with permissions?

I've encountered a similar error message after downloading the latest geoPHP lib to /sites/all/libraries and sticking with the stable versions of the modules.
I then upgraded geofield, geophp, and openlayers to their most recent dev versions, to see if the error had been fixed.
Then I got the error in the title of this report.
I have not tried any of the patches in this report though.
I have moved geoPHP from /sites/all/libraries to the module directory (read this as a possible solution in an old bug report) but all that changed was the path to the source of the error.

When I visit the erroring pages as admin, however, then it works without error.
This makes me wonder if there's a permission that needs setting somewhere. I tried giving all users permission to geocode using all services, but still get the error.

(This may or may not be relevant, but the erroring page only loads the following OpenLayers javascript files:
/sites/all/libraries/openlayers/OpenLayers.js
/sites/all/modules/openlayers/js/openlayers.js
/sites/all/modules/openlayers/plugins/layer_types/openlayers_layer_type_google.js
//maps.googleapis.com/maps/api/js?sensor=false&v=3.5
/sites/all/modules/openlayers/modules/openlayers_views/plugins/layer_types/openlayers_views_vector.js

When viewed as admin (ie when it works) there are more javascript files loaded, starting with:
/sites/all/modules/openlayers/plugins/layer_types/openlayers_layer_type_google.js

I will continue investigating and report any findings back)

ezman’s picture

to add, it doesn't actually work for admin. It goes a step further, by displaying the map and the geocode button on the node add/edit form, but throws the same error when geocoding, and when trying to save the form.

ezman’s picture

Ok I found my problem. Hope this may apply to others?

When I updated the GeoPHP library to its latest version, I clicked the github link in #11.

On the github page, if you scroll down, you see:
"Getting Started

The lastest stable version can always be downloaded at: https://github.com/downloads/phayes/geoPHP/geoPHP.tar.gz "

This is not version 1.1 (at the time of me posting this) but version 1.0.

It was only when debugging and comparing geoPHP.inc to the github version that I spotted the mistake.

Instead, download the .zip file linked on the right-hand side of the page.
https://github.com/phayes/geoPHP/archive/master.zip is version 1.1 at the moment.

So, actually putting the correct 1.1 in the /sites/all/modules/geophp/geoPHP directory fixed it for me.

ledbelly2142’s picture

ezman,
Thanks for posting. The 'correct' ver 1.1 got me to the next step in creating a node. Thanks for finding the issue. I guess the latest stable version is not 1.1.

Note to self: don't trust links.

Cheers

FrancescoQ’s picture

Using last geoPHP works! Anyway i've created this patch, it works with geoPHP provided with module without updating the library

geek-merlin’s picture

Issue summary: View changes

OK, here's how this worked for me:
* updateing geophp module to latest dev
* OR getting current library from https://github.com/phayes/geoPHP/archive/master.zip and put it into sites/all/libraries/geoPHP (case matters!)

basvredeling’s picture

I concur that #25 works

Brandonian’s picture

Status: Needs work » Fixed

Marking issue as fixed.

Status: Fixed » Closed (fixed)

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