Problem/Motivation

We already have google maps api key stored using the key module (https://www.drupal.org/project/key). When configuring geofield_map we would like to reuse it.

Steps to reproduce

install https://www.drupal.org/project/key

configure geofield field form to use Geofield Map widget

Configure "Gmap Api Key"

Proposed resolution

Allow user to set the key module key id as the "Gmap Api Key" (this is what geolocation_google_places_api does)

Remaining tasks

Fix patch and expand functionality

User interface changes

Gmap Api Key field description chanage

API changes

NA

Data model changes

NA

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

  • 3281279-store-google-maps Comparechanges, plain diff MR !33
  • 11.1.x Comparecompare
  • 8.x-2.x Comparecompare

Comments

rakugaki created an issue. See original summary.

rakugaki’s picture

Ended up extending GeofieldMapWidget and changing the key there instead.

  public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {
    $element = parent::formElement($items, $delta, $element, $form, $form_state);
    $gmap_api_key = $element['value']['#gmap_api_key'];
    $key = $this->keyRepository->getKey($gmap_api_key);
    if ($key) {
      $element['value']['#gmap_api_key'] = $key->getKeyValue();
    };
    return $element;
  }

This was a bit simpler then patching.

Is there is any appetite to add this functionality to the module?

gcb’s picture

StatusFileSize
new6.11 KB

This feature is very desirable. I've updated the patch to be a little more robust and apply against the latest release.

gcb’s picture

Version: 8.x-2.x-dev » 3.0.12
Status: Needs work » Needs review
rakugaki’s picture

Version: 3.0.12 » 11.1.x-dev

rakugaki’s picture

updated MR to include @gcb's patch

itamair made their first commit to this issue’s fork.

itamair’s picture

Title: store google maps api key using key module » Support to Key module for storing Google Maps Api Key
itamair’s picture

Status: Needs review » Fixed

Thanks ...
My latest commit added the following general improvements and integrations:
- Readme.md and Drupal.org documentation files
- GoogleMapsService: correct (optional) dependency injection of the key.repository Service
- GeofieldMapSettingsForm: better conditional GMap API Key settings component description, on the existence of the Key module

All this looks fine and solid to me.
Going to Merge and deploy a new Geofield Map 11.1.9 release with this Feature (Support to Key module for storing Google Maps Api Key)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

  • itamair committed 9368c6fa on 11.1.x authored by rakugaki
    Resolve #3281279 "store google maps api key using key module"
    

Status: Fixed » Closed (fixed)

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