I'm not sure if this is just a documentation issue or something else — first time using the v3 version.

I tried several solutions here. Finally #56 worked for me. I believe that adding the right provider module from the beginning is essential.

I've required a couple of providers via composer (here-provider and google-maps-provider). Are they supposed to show up the the dropdown on the provider page (alongside FIle, GPX File, etc), or do I need to do another step? I've cleared cache. The readme states to "Create and configure one or more providers in the UI" but it's not obvious to me what that entails.

Apologies if I'm missing something obvious, any help is appreciated!

Comments

mrogers created an issue. See original summary.

itamair’s picture

Status: Active » Needs review

yes exactly ... they should show up exactly there (@see attached image), and will better show after a proper cache clear.

Note that the (thought supportable) the geocoder implementation of the geocoder-php/here-provider hasn't yet been provided.

Here are the actual implemented:
https://git.drupalcode.org/project/geocoder/-/tree/8.x-3.x/src/Plugin/Ge...

Feel free to provide a (not regressive, and drupal/php codeing standards compliant) patch for it.

mrogers’s picture

Ah, that was the problem — I assumed all providers linked to in the packagist link in the help text under the dropdown were provided.

Thanks for your help.

timkroehler’s picture

I'm installing geocoder and having the same difficulty selecting providers. I used composer to install geocode, geolocation, geolocation-leaflet, geocode-address, address, geocode-field. Then I used composer to install willdurand/geocoder, cydrickn/geocoder-php-geocodexyz, and finally geocoder-php/google-maps-provider. But nothing changed. Did a performance/cache-clear. Nothing changed. I have two options on the dropdown on admin/config/system/geocoder/geocoder-provider - "File" and "Random". Selecting "File" I get to edit its label title, and then it appears in the list below. Then it also appears in the Field Settings for my Geolocation field, but it doesn't do anything, and it doesn't seem at all connected to the libraries I installed.

itamair’s picture

Just read and follow the documentation in the Readme.md file.
That is updated on how to add and enable providers.
The providers actually supported & implemented are the ones listed here in the moudule itself:
https://git.drupalcode.org/project/geocoder/-/tree/8.x-3.x/src/Plugin/Ge...

PS: The composer require willdurand/geocodercommand is NOT strictly needed,
as the previous composer require drupal/geocoder should have already installed willdurand/geocoder version 4.
If it is not, probably you have still the willdurand/geocoder version 3 version installed that would block/prevent the drupal/geocoder 3.x branch being installed ...

Thus you have to remove willdurand/geocoder version 3 before, and then again: composer require drupal/geocoder ...

itamair’s picture

Status: Needs review » Closed (outdated)
Bagz’s picture

For anyone else who falls into the trap described in #4 - this happens if you install the geocoder module before installing the provider library. The README instructions show the correct sequence where enabling the geocoder module is the last step AFTER requiring the providers. If your provider does not appear in the dropdown then you probably need to uninstall and then re-install the geocoder module.

giorgio79’s picture

Thx Bagz. This was a big wtf moment.

itamair I see no attached image.

drupalfan2’s picture

I have the same problem using Drupal 9 and geocoder 8.x-3.14.

But #7 does not solve the problem! Same problem as in #4.

I installed 3 geocoder-php providers with composer.

Afterwards I installed geocoder module with composer and enabled it.

On /admin/config/system/geocoder/geocoder-provider I can not find the provider list. In the select list I can choose "file" or "random" and click on the "add" button. Button this does nothing, providers called file or random do not exists and if I activate them, nothing works, no geocoding is done.

This seems to be a problem of 3.14 version of geocoder. I tested latest 2.x version, in this case the provider list on
/admin/config/system/geocoder/geocoder-provider
was available. But the 2.x version is not compatible with other components I am using, so 2.x I can not use.

How can I solve this problem?
Although I have geocoder-php providers installed, they are not listed. Please help.

drupalfan2’s picture

Solution found:

I had install the Geofield module and I hat to activate the Geocoder Geofield submodule although I do not use the Geofield module nor the Geofiled submodule of Geocoder!!
Without this submodule I did not see any geocoding provider.

I am using the address module therefore the Geocoder Geofield submodule is not needed. But nobody told me (no error message, no hint, no documentation) that this submodule MUST be enabled in order to see the geocoder provider list and be able to configure it.

itamair’s picture

@drupalfan2 you are mistaken ... and risk to mislead the community.
You just need to follow the Readme.md instructions (as stated in the #7 comment), or simply refresh the Drupal cache (drush cr) when/if your Geocoder module is already enabled and you are adding (composer require) new providers afterwords.
The "Geocoder Geofield" is not a dependency of the above (at all): in your case its enabling just triggered a drupal cache clean ...

drupalfan2’s picture

No, this is wrong.

I cleared the cache dozens of times!! You can reproduce the problem on a fresh/clean installation of Drupal 9.

I have seen #7 and it tried #7 dozens of times!

I am using Drupal 9. If you are not using Drupal 9, maybe you do not have this problem.

itamair’s picture

Issue summary: View changes

There is no assuming, or guessing or "maybe" here.
Geocoder 8.x-3.x is using the same code both for Drupal 8 and Drupal 9 ... and it is building the list of available Geocoder Providers from here:

https://git.drupalcode.org/project/geocoder/-/blob/8.x-3.x/src/Form/Geoc...

from the main Geocoder module, and there is no dependency from any Geocoder submodule in doing that.

@drupalfan2 this looks so far a specific issue of you (your setup, your workflow, whatever else ...) if nobody else steps here in reporting your same/similar issue or until you clearly find and prove what is causing your issue in the Geocoder module code (without any "maybe" or "could be") ... )

drupalfan2’s picture

The problem exists and I found few other issues where people had the same problem.

gaydabura’s picture

On my side composer dumpautoload helped

msypes’s picture

I've tried uninstalling and reinstalling geocoder after requiring a provider, running composer dump-autoload and drush cr several times, with no luck until I hit this sequence:

  1. uninstall all Geocoder-related modules
  2. drush cr
  3. composer dump-autoload
  4. drush cr, cause hell, it's Drupal, why not?
  5. re-enable just the Geocoder module
  6. Visit the config page, and there's the provider listed. Add it
  7. Now go back and enable the other Geocode modules you need

Well, almost. Now I get fatal errors that the plugin doesn't exist, but at least it's a different problem, right? Watchdog reports that "Valid plugin IDs for Drupal\geocoder\ProviderPluginManager are: random, file, kmlfile, geojsonfile, gpxfile"

Near as I can tell, clearing the cache after enabling the geocoder_geofield module causes this issue. If I can get that repeatably, I'll file a new issue.

itamair’s picture

@msypes it just means there is still something that you are missing then.
All is fine (and has been found) with this task, and there is no bug around here. Just something that you are missing ...

Did you also got rid of any pre-existing version of willdurand/geocoder:3.x version? running the following:
composer remove willdurand/geocoder
... before starting a clean drupal geocoder 3.x new installation.

msypes’s picture

I would love to know what is missing, having followed the directions in the readme multiple times with no luck.

Geocoder was never installed prior this (I'm working with a fresh D9 installation.), and the only willdurand/geocoder listed in composer.lock is ^4.4.0, as required by this module.

I've listed the steps I've taken here and in the bug report I created on my own (https://www.drupal.org/project/geocoder/issues/3205922). If there's a step missing, I've certainly provided enough information for someone to say something along the lines of "You forgot to do X between steps 2 & 3," if that's the case.

itamair’s picture

@msypes ... this is my last comment (and hope final) on this: https://www.drupal.org/project/geocoder/issues/3205922#comment-14047416
Geocoder 3.x module is working correctly and as designed on its providers addictions, and accordingly to its documentation.

itamair’s picture

Title: How to add providers » How to add Gecoder 3.x providers
Status: Closed (outdated) » Reviewed & tested by the community
liquidcms’s picture

Version: 8.x-3.7 » 8.x-3.20
Component: Documentation » Code
Category: Support request » Bug report
Status: Reviewed & tested by the community » Active

Sorry, not sure RTBC means the maintainer reviewed it.

I have to agree there is a piece missing in your documentation or something simply is broken. These are steps i took using D9.0.11 and 8.x-3.20

drush pmu geocoder_address
- this uninstalls geocoder and geocoder_field
- shouldnt matter; but to be safe

composer require drupal/geocoder:^3.0
- nothing to do as already installed
composer require geocoder-php/google-maps-provider
- nothing to do as already installed
- to be fair, not 100% clear this one is supported, above you point to the list on github, but that doesnt state what the composer require path is for each - but i am using the value you state in your READme and that does install ver 4.6 of that plugin
drush en geocoder_address
- which also enables geocoder, geocoder_field

drush cr

going to Providers page and the only items listed are still File and Random.

from this: dpm(\Drupal::service('plugin.manager.geocoder.provider')->getDefinitions());

Array
(
    [random] => Array
        (
            [arguments] => Array
                (
                )

            [id] => random
            [name] => Random
            [class] => Drupal\geocoder\Plugin\Geocoder\Provider\Random
            [provider] => geocoder
        )

    [file] => Array
        (
            [arguments] => Array
                (
                )

            [id] => file
            [name] => File
            [handler] => \Drupal\geocoder_field\Geocoder\Provider\File
            [class] => Drupal\geocoder_field\Plugin\Geocoder\Provider\File
            [provider] => geocoder_field
        )

)

Something's broken here.

itamair’s picture

Status: Active » Reviewed & tested by the community

@liquidcms something is probably broken in your workflow ...
Or do you really assume you are the only one catching a so critical issue on a branch that has more than 6k proven adoptions?

Are you sure you are on the Geocoder 3.x branch?
Did you eventually remove (composer remove) your previous geocoder 2.x branch?

Did you follow what pointed out in the #19 previous comment?

Remove any previous Geocoder presence (may be 2.x version) with the following 2 commands:

composer remove drupal/geocoder
composer remove willdurand/geocoder
(the last one shouldn't be needed as already comprised in the first one, but just to make 100% sure ... )

These following are the command I run (relevant to this issue) to require and install all the Geocoder 3.x module & submodules with just the geocoder-php/free-geoip-provider (besides the ones already embedded in the module):

composer require drupal/address
composer require drupal/geocoder
composer require geocoder-php/free-geoip-provider
drush en address geocoder geocoder_field geocoder_geofield geocoder_address -y

... and all goes well, super charm, and I end up with a Geocoder module enabled and the capability to select and generate a free-geoip-provider

This issue has been already "Reviewed and Tested by the community", and you shouldn't reopen it without providing clear evidence of what is buggy (your assumptions are not enough ... sorry).

liquidcms’s picture

possibly RTBC but no evidence of that here. Besides you, only people saying it doesn't work.

I have never had 2.x branch as i have never used this. This is a clean install.. but will go through and remove everything and try again.

thanks for the additional guide (but this is not the README that you say works).

liquidcms’s picture

also, i never enabled: geocoder_geofield as i think this is supposed to be only for the geofield option. the readme is a bit confusing and all these modules called "field" when they aren't field modules adds to this. Readme states "geocoder_geofield / gecoder_address" which i assume means either:

geofield and geocoder_geofield OR
address and geocoder_address - which i think also doesn't work and i needed to add geolocation as well

but these are all before the provider comes in to play (according to the README) so unlikely this is the bigger issue here.

and woo hoo.. this is now fixed,,, for others coming across this, hopefully it helps you as well.

the README states composer require for the gmaps provider; so this is what i have been trying and no luck getting it to show in the providers list. But from itamair guide in #22 he uses a different provider.

the ONLY change i have made is to run this: composer require geocoder-php/free-geoip-provider

and sure enough it shows in the list of providers (as do the Google ones which did not show before).

itamair’s picture

Well. Besides few people (5? 10? No more … ) reporting here some issues (and supported ...) there are thousands adopting this 3.x branch that didn’t step in and didn't report any bug or issue here.
BTW @liquidcms … this is a free opensource community, and it is always good to balance your “taking” attitude with some “giving” also.
If you feel the documentation is misleading and you identify some improvements, also from others places, or others' contributions, feel free (as you are really welcome) to provide your proposed enhancements … hopefully with a well formed patch (to the Readme.md file itself).
This is the proper way to interact here, besides complaining for something not perfect, or assuming very personal bugs 😉
Thanks a lot

davidjguru’s picture

Hi,
I was checkin' geocoder but I can't see the providers in the dropdown button. I follow the steps in README but I don't know what I have to do.

Steps:
-----------
$ composer require drupal/geocoder:^3.0
$ drush cr
$ composer require geocoder-php/geoip2-provider
$ drush cr
$ drush en geocoder -y
$ drush cr
Go to: /admin//config/system/geocoder/geocoder-provider

Not showing the provider. What Can I do?

Versions
-------------------
Drupal core: 9.1.8
Geocoder: 3.20.0

liquidcms’s picture

i had tried the README which mentions the Google provider and it also didn't work. Then from comment in #22 i tried:
composer require geocoder-php/free-geoip-provider

and this magically now showed both those providers as well as the google ones which i had installed earlier but which didnt show up. But itamair also says there is no issue here; so perhaps you are seeing something else.

andyg5000’s picture

I came across this issue because the providers list wasn't being updated after running `composer require geocoder-php/google-maps-provider` (this is an upgrade from 2.x). Clearing the PHP ApcU and Opcaches looks to have resolved the issue for me (full restart of phpfpm).

Hopefully this helps others.

mpotter’s picture

I ran into this issue also. The key step I was missing was:
drush en geocoder_geofield -y
This also enables the geocoder_field module. I'm using the google maps provider and before enabling these modules, no amount of cache clear (even Opcache, memcache, etc) would show the providers.

The project page only says: "Enable the module (and its sub-modules) via Drush". But the README file contains more detailed instructions.

Notice that in #22 none of the submodules are being enabled. So perhaps just the main project page just needs a bit more info on "and its sub-modules".

cossovich’s picture

Posting here in case it helps someone else in the same situation. I ran into this issue (provider list not updating) but was able to take steps to remedy it. To be clear, if I had followed the installation instructions more closely I would not have had this issue (but it was an easy trap to fall into - especially if you want to add providers after you've already installed the module).

The website was a clean Drupal 9.x install with a node using fields from Address and Geofield. I then installed Geocode 3.20 to automatically populate my geofield from the address field.

My initial steps to install the module were wrong:

$ composer require drupal/geocoder
$ drush en geocoder_address geocoder_geofield (geocoder and geocoder_field were automatically enabled)
visited /admin/config/system/geocoder/geocoder-provider and used external link to list of all available providers
$ composer require geocoder-php/google-maps-provider
visited /admin/config/system/geocoder/geocoder-provider but new provider not in the drop-down.

No amount of cache-clears or uninstalling and reinstalling the modules fixed the issue for me, I had to reinstall the dependencies before enabling the modules.

Steps I took to fix my install:

$ drush pmu geocoder geocoder_field geocoder_address geocoder_geofield
$ composer remove geocoder-php/google-maps-provider
$ composer remove drupal/geocoder
$ composer require drupal/geocoder
$ composer require geocoder-php/google-maps-provider
$ drush en geocoder geocoder_field geocoder_address geocoder_geofield
visited /admin/config/system/geocoder/geocoder-provider and relevant Google providers now in the list.

Perhaps there might have been a simpler was to fix my mistake but that's what worked for me.

blacklabel_tom’s picture

Status: Reviewed & tested by the community » Needs work

Hi All,

Stumbled across this issue because I too couldn't get providers to show in the list. Turns out after running composer install to get the provider I wanted I then had to run a cache clear to get them to appear.

This is NOT detailed in the Readme and I can see why. The Readme has the next steps as enabling modules which will trigger a cache clear and so the issue will never crop up.

I did things in the "wrong" order:

- Enabled the address module
- Added an address field to my content type
- Enabled the geocoder, geocoder_field and geocoder_address modules
- Added geofield to my content type
- This wouldn't let me save without enabling without a provider setup
- Added the Random provider thats available by default
- Hooked up the geofield to run from the address field and using the Random provider

At this point I pushed my work as another developer in my team needed the content type in this state to do their work.

Next task was to hook up the geolocation for real so I:

- Composer installed geocoder-php/google-maps-provider
- When I went to the providers list I had a few new options like File, GPX file, etc

To get GoogleMaps to appear I had to clear the cache. If I'd done things in the specific order of the Readme then I wouldn't have bumped into this, but as I'm not the first person to run into this issue, it might be worth adding a note to the Readme or admin page to say a cache clear might be required?

My setup:

Core: 9.1.6
Geocoder: 3.20.0

Cheers

Tom

ekes’s picture

This was hurting my brain, and bloody inconvenient as I was trying to write some consistent documentation for how to add geocoders to an existing site, with existing installed geocoder, uninstalling gecoder (and dependencies) isn't going to be an option. So I fired up the debugger:-

When plugin discovery is done the plugins are filtered in a geocoder hook if their class doesn't exist:-

  // Remove plugins for which the providers are not installed.
  $plugins = array_filter($plugins, function (array $plugin): bool {
    return empty($plugin['handler']) || class_exists($plugin['handler']);
  });

https://git.drupalcode.org/project/geocoder/-/blob/7cf55eac7d723592fdb56...

`class_exists` is returning `FALSE` for the classes that have been installed using composer, are there in the file system, even after a `drush cr` - WTF - step-into until it's trying to `function findFile()` in `Composer\Autoload`.

        if (null !== $this->apcuPrefix) {
            $file = apcu_fetch($this->apcuPrefix.$class, $hit);
            if ($hit) {
                return $file;
            }
        }

https://github.com/composer/composer/blob/8559279025cd6f04854757681a0c54...

It's returning the results from the APCu data store, and yes, this says it's not there. But I cleared caches right? I can even run a script with `acpu_clear_cache()`, it's of no help.

/**
     * Rebuild a Drupal 8 site.
     *
     * This is a copy of core/rebuild.php. Additionally
     * it also clears Drush cache and Drupal's render cache.
     *
     * @command cache:rebuild
...
    public function rebuild($options = ['cache-clear' => true])
    {
        if (!$options['cache-clear']) {
            $this->logger()->info(dt("Skipping cache-clear operation due to --no-cache-clear option."));
            return true;
        }
        chdir(DRUPAL_ROOT);

        // We no longer clear APC and similar caches as they are useless on CLI.
        // See https://github.com/drush-ops/drush/pull/2450

https://github.com/drush-ops/drush/blob/61349c2e55f09621da9139a558ea7e58...

"We no longer clear APC and similar caches as they are useless on CLI."

So `drush cr` isn't actually good enough here. Just use the one under system > performance? Nope. It's not a CacheBin. Something must clear it right? As mentioned in the Drush code above `core/rebuild.php` does - so running that fixes things. However, as explained in https://git.drupalcode.org/project/drupal/-/blob/9.3.x/core/lib/Drupal/C... it's probably too blunt for everyday use. You think it gets rebuilt when a module is installed right:

    // Add the APCu prefix to use to cache found/not-found classes.
    if (Settings::get('class_loader_auto_detect', TRUE) && method_exists($this->classLoader, 'setApcuPrefix')) {
      // Vary the APCu key by which modules are installed to allow
      // class_exists() checks to determine functionality.
      $id = 'class_loader:' . crc32(implode(':', array_keys($this->container->getParameter('container.modules'))));
      $prefix = Settings::getApcuPrefix($id, $this->root);
      $this->classLoader->setApcuPrefix($prefix);
    }

https://git.drupalcode.org/project/drupal/-/blob/02bf7534778566d9c00e0ea...

Nope! That's almost too sneaky. It has a different cache prefix when you change the modules installed. Not much help if all you are doing is installing things in vendor with composer and there is no additional module. What happens when vendor dependencies update, without a change in modules (or the core version, which is used in the deployment identifier used in `Settings::getAcpuPrefix()`)? There must be somewhere else - maybe a question for core?

Looking at the issue at hand now, adding and possibly more importantly (fatal 'class not found' at a cached location) removing geocoder-php/* providers with APCu enabled isn't going to be noticed by the Autoloader unless we can delete the cached value for that class before checking to see if it exists. The geocoder plugin alter hook is only run when the plugin cache is being rebuilt, so that seems as fair place as any to do it. Something like:-

/**
 * Implements hook_geocoder_provider_info_alter().
 *
 * @param array $plugins
 *   The list of plugin definitions to alter, passed by reference.
 */
function geocoder_geocoder_provider_info_alter(array &$plugins): void {
  // If composer is caching plugin locations remove them.
  $class_loader = \Drupal::service('class_loader');
  if (($class_loader instanceof ClassLoader) &&
    (($apcu_prefix = $class_loader->getApcuPrefix()) !== NULL)
  ) {
    $apcu_cache_keys = [];
    foreach ($plugins as $plugin) {
      if (!empty($plugin['handler'])) {
        $apcu_cache_keys[] = $apcu_prefix . ltrim($plugin['handler'], '\\');
      }
    }
    $results = apcu_delete($apcu_cache_keys);
  }

  // Remove plugins for which the providers are not installed.
  $plugins = array_filter($plugins, function (array $plugin): bool {
    return empty($plugin['handler']) || class_exists($plugin['handler']);
  });
}

Which works! Although it does rather feel like getting into internals that shouldn't be necessary.

Am I missing an easier route in my travels above? Or should I make a patch out of it? And an issue on core?

itamair’s picture

Thanks @ekes ... it looks you really went much through all this,
and I should confess I will need all my focus and quietness to gain the proper commitment to review all of it.
In synthesis, yes please, also forward what is your best proposal and fix (a patch to the Geocoder module or to the Drupal core?)

ekes’s picture

Status: Needs work » Needs review
StatusFileSize
new1.23 KB

I've put an issue in for core, but if anything happens it'll no doubt take time https://www.drupal.org/project/drupal/issues/3230708 So patch for this specific issue till there is.

The patch based on my conclusion of #3153678-33: How to add Gecoder 3.x | 4.x providers, only change is to do a method_exists rather than checking the class, this is consistent with what core does when it sets the prefix.

chris.guilliams’s picture

@ekes patch from #35 worked for me on a site with an existing Geocoder install where newly added providers weren't showing up after running any combination of composer install, drush cr, or drush dump-autoload.

After adding the patch to my composer.json and running composer install and drush cr to be safe my newly added provider, OpenCage showed up.

Existing install version of willdurand/geocoder was 4.4.0.

Thanks for the investigation @ekes as uninstalling/reinstalling `drupal/geocoder` and it's dependencies would have been a massive time sink for my use case!

maskedjellybean’s picture

The patch in #35 works great for me! As described in #36 I added the patch to composer.json, ran composer install and then drush cr and GoogleMaps showed up in the select.

marcosdr’s picture

Hi,

I am trying to add the google maps provider and also run into this issue.

I installed a fresh D9 site with the following modules/packages:

  • Address
  • Geolocation
  • Geocoder
  • "geocoder-php/google-maps-provider": "^4.6"

I have followed steps on #16 and the provider shows up when I re-enable just the Geocoder module. I can configure and save the settings in the Provider form without a problem.

However, when I enable the geocoder_address module, the GoogleMaps provider is no longer found. I can only see the File and Random providers listed. If I click on the Edit button of the GoogleMaps provider I previously created I get the error:

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "googlemaps" plugin does not exist. Valid plugin IDs for Drupal\geocoder\ProviderPluginManager are: random, file

This issue is still present after applying patch #35.

  • itamair committed 2f33808 on 8.x-3.x authored by ekes
    Issue #3153678 by ekes: How to add Gecoder 3.x providers
    
itamair’s picture

Thanks a lot @ekes, amazing work!
I committed your #35 patch into dev 3.x branch, and issuing a new release with it ...

itamair’s picture

Version: 8.x-3.20 » 8.x-3.21

New geocoder 8.x-3.21 just released with #35 patch.
It would be great to have reviews if still Geocoder Providers adds issues occur ...

willids’s picture

StatusFileSize
new91.08 KB

@itamair - Having read the README file, I did the following and it worked

composer require drupal/geocoder:^3.0

composer require geocoder-php/google-maps-provider

Clear Cache in Performance then reload providers

imclean’s picture

Here's another twist. I've installed Nominatim, ArcGisOnline and Mapbox. I cleared the cache after all steps below.

  1. With geocoder and geocoder_field enabled I only have File, Nominatim, OpenStreetmap and Random available
  2. After uninstalling geocoder_field, all providers are listed (except File)
  3. After reinstalling geocoder_field the same list as in 1 appears
  4. Uninstalling all geocoder modules then reinstalling just geocoder, I get the full list of providers
  5. Reinstalling geocoder_field I'm back to the list in 1

So in this case, the module geocoder_field is preventing the detection of some plugins.

imclean’s picture

#42 might align with #38 as enabling the geocoder_address would enable geocoder_field as well.

imclean’s picture

In geocoder.module:

 $plugins = array_filter($plugins, function (array $plugin): bool {
    return empty($plugin['handler']) || class_exists($plugin['handler']);
  });

With geocoder_field installed, class_exists($plugin['handler']) is returning false for some providers which have been installed. Without geocoder_field installed, it returns true for all installed plugins.

imclean’s picture

I was running an older version of Drupal 9.2. Updating Drupal to 9.2.10 fixed the problem I was having.

damienmckenna’s picture

FYI in #3048597 maskedjellybean said it was working.

jlemosy’s picture

I can confirm the issue reported in #38 and #45. I have a clean install of Drupal 9.3.9 and Geocoder 8x-3.28, and enabling the geocoder_field submodule breaks the use of the geocoder-php/google-maps-provider plugin.

It can be restored by either:

  1. Uninstalling the geocoder_field submodule or...
  2. Installing and enabling the Geofield module, then enabling the geocoder_geofield submodule
grgcrlsn321’s picture

I've managed to install the google maps library on other sites in the past, but I'm not able to get the library to load using Drupal 9.4.8 recommend. I'm following the steps to install all modules and then the google maps library provider and clear cache, but still not loading the library. Maybe I'm not getting the order right on how to install?

eswiderski’s picture

Clean 9.4 install. I've tried every possible order of installing, uninstalling, cc, etc. #48 option 1 works, but then makes the module useless. Option 2 changes nothing for me.

Uncaught PHP Exception Drupal\\Component\\Plugin\\Exception\\PluginNotFoundException: "The "googlemaps" plugin does not exist. Valid plugin IDs for Drupal\\geocoder\\ProviderPluginManager are: random, file, gpxfile, kmlfile, geojsonfile"

grgcrlsn321’s picture

Just an update on my comment #49.

I updated the geofield module from 1.44 -> 1.46 and the Google Maps library starting to work on the geocode config page, /admin/config/system/geocoder/geocoder-provider.

So make sure before going through the whole uninstall and reinstall you are up-to-date with your modules.

nchase’s picture

I can confirm #48 and #38 with the same setup. Uninstalling the geocoder_field submodule makes and the installed providers appear.

nchase’s picture

it is actually the geocoder_address integration that breaks it.

kensae’s picture

I have the same issue after enabling geocoder_geofield submodule.

Without installing geocoder_geofield

Provider list without installing geocoder_geofield

After installing geocoder_geofield

Provider list after installing geocoder_geofield

After installing the submodule, it seems the plugins added through composer are not loaded anymore, as class_exists in geocoder_geocoder_provider_info_alter returns false for these plugins. Maybe it has something to do with autoloading and caching.

Update: it seems it has something to do with the order in which you install composer dependencies and install the submodules. It's working now.

loopy1492’s picture

The fact that you have to install the dependencies in order is a huge problem. If you've already got data in your site, you can't just uninstall modules and expect the data to survive. Why isn't there an install hook to implement these changes?

loopy1492’s picture

After messing around a bit, I found that disabling geocoder_field and geocoder_address, then re-enabling it did do the trick and it did not seem to negatively impact the fields themselves.

brulain’s picture

Same as #54 but didnt find the correct order (lol)
Core 9.4.9
Geocoder 3.31

bogdog400’s picture

Issue summary: View changes
imclean’s picture

Issue summary: View changes

Restoring the issue summary. @bogdog400, use the "Comment" field to reply rather than the issue summary.

@bogdog400:

I tried several solutions here. Finally #56 worked for me. I believe that adding the right provider module from the beginning is essential.

Thanks for all of your help.

bogdog400’s picture

Issue summary: View changes

Doh. Sorry.

imclean’s picture

Issue summary: View changes

This time you completely wiped the "Issue summary" field. Only post in the comment field, don't change anything else.

jeff.a’s picture

StatusFileSize
new214.04 KB

Tried everything here besides the patch. Number #56 seems to be the simplest. Running D10.1 with PHP 8.1 and apache (with Seven theme.. don't judge 😏)

Steps that worked for me-
1. Uninstall geocoder_field, geocoder_address and geocoder_geofield
2. If provider is installed it should now show at /admin/config/system/geocoder/geocoder-provider
3. Edit > configure > save provider
4. Reinstall geocoder_field, geocoder_address and geocoder_geofield

The provider is missing again in the select list but is showing under Active Providers as seen in the screenshot. Hope this gets a permanent fix in case I need to switch providers in the future!

itamair’s picture

Title: How to add Gecoder 3.x providers » How to add Gecoder 3.x | 4.x providers
khaldoon_masud’s picture

Tried #56, I was able to select Google maps provider but when I tried to configure the geofield, I got the error:
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "googlemaps" plugin does not exist. Valid plugin IDs for Drupal\geocoder\ProviderPluginManager are: random, file, kmlfile, geojsonfile, gpxfile in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of /app/web/core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php)

Solution is to change weight of the module geocoder.
Edit the core.extension.yml file and update geocoder to below:
geocoder: 1
then run drush cim command

Note: geocoder weight should be higher than geocoder_address module.

fonant’s picture

Phew, this one is still fun to fix if you install geocoder before composer-requiring the providers. I was using just geocoder, and none of the other modules (using the geocoder field in Leaflet maps).

I think the method that finally worked for me was:

  1. drush pm:uninstall geocoder
  2. drush cr
  3. Restart Webserver and PHP processes (Apache, php-fpm, OpenLitespeed, lsphp, etc.)
  4. drush pm:enable geocoder
mykola dolynskyi’s picture

Tried everything.
Only #64 works, thanks @khaldoon_masud

Geocoder 3.47

henrik23’s picture

Talking about the order of installing relevant geo modules my experience was the following:
First step: Install geofield and create a new field of type geofield in your content type.
Second step: After that install/activate geocoder, choose and save a geocoder provider.
Third step: Modify the field created in step one and activate geocoding from the source you apreciate.

jonnytoomey’s picture

Having the same or related issue

Followed instruction in readme, enabling the geocoder_address module removes the options to add a provider (other than Random and File)

Adding the provider before enabling geocoder_address keeps the config but again removes the additional providers from the select options

However, then trying to use the provider on a geolocation field, I get the fatal error

The "googlemaps" plugin does not exist. Valid plugin IDs for Drupal\geocoder\ProviderPluginManager are: random, file

edvanleeuwen’s picture

I had this problem as well. For me, restarting php did the trick.

itamair’s picture

StatusFileSize
new209.01 KB

Because of some (really few) issues still being posted that relate to some difficulties in adding Gecoder 3.x | 4.x providers, and assuming that possibly related to the conflicting enabling of geocoder_field, geocoder_geofield and geocoder_address submodules (such this latest one: https://www.drupal.org/project/geocoder/issues/3518956)

I further performed a deep insight and QA & test that could try to replicate the reported problematic scenario,
and still I couldn't experience any issues in enabling those Gecoder Providers that I required, and still having them enabled after subsequently enabled those geocoder submodules.

In particular I accomplished the following tasks in the following sequence:

1. I installed a fresh Drupal 10 (or Drupal 11) instance (locally with DDEV);
2. Required and enabled the Geocoder module with the following commands:
ddev composer require drupal/geocoder
ddev drush en drupal/geocoder
all good ... the Geocoder 8.x-4.28 release is installed and enabled.
3. I required the google-maps-provider and arcgis-online-provider Geocoder providers with the following commands (--with-all-dependencies):
ddev composer require geocoder-php/google-maps-provider -W
ddev composer require geocoder-php/arcgis-online-provider -W
ddev drush cr (always better to clear the drupal cache)
all good ... I could then find the required geocoder providers in the Geocoder provider options list, at the admin/config/system/geocoder/geocoder-provider settings page (@see the attached screenshot)
4. I enabled the geocoder submodules geocoder_geofield (after requiring the geofield module) with the following commands:
ddev composer require drupal/geofield
ddev drush en geocoder_geofield
ddev drush cr (always better to clear the drupal cache)
and still all good ... I could still correctly find the required geocoder providers in the Geocoder provider options list, at the same geocoder-providers settings page (@see the same attached screenshot)
5. I also enabled the geocoder submodule geocoder_address (after requiring the address module) with the following commands:
ddev composer require drupal/address
ddev drush en geocoder_address
ddev drush cr (always better to clear the drupal cache)
and still all good ... I could still correctly find the required geocoder providers in the Geocoder provider options list, at the same geocoder-providers settings page (@see the same attached screenshot).

My further established conclusions on this are that all is working fine with the expected workflow to require and add Geocoder Providers with actual Geocoder 8.x-4.28 release

ekes’s picture

The issue I described in comment #33 https://www.drupal.org/project/geocoder/issues/3153678#comment-14203727 where you install the plugin using composer, but the autoloader is not rebuilt, so it's not detected, should I think be fixed with:

#3509069: Use a better container cache key

itamair’s picture

Indeed this issue (finally) happened to me also, and I was able to solve it following the suggestion #64:

Solution is to change weight of the module geocoder.
Edit the core.extension.yml file and update geocoder to below:
geocoder: 1
then run drush cim command

Note: geocoder weight should be higher than geocoder_address module.

ressa’s picture

Yes, the #3509069: Use a better container cache key issue will probably take care of stale APCu cache-related problems, since Composer should then also clear the APCu cache, after a contrib project is added or removed.

If you cannot restart the web server to clear APCu caches, the other alternative is to add $settings['class_loader_auto_detect'] = FALSE; in settings.php and rebuild caches.

From https://www.drupal.org/docs/administering-a-drupal-site/troubleshooting-...

solideogloria’s picture

Version: 8.x-3.21 » 8.x-4.x-dev