On my live site, the Google Map field is not working and I get the following errors in the console:
js_hxo8LLjpT7DhXzsSYgz75xh_wE18eJ7A_erzYCkYTZA.js:107 Uncaught ReferenceError: google is not defined(anonymous
js_hxo8LLjpT7DhXzsSYgz75xh_wE18eJ7A_erzYCkYTZA.js:107 Uncaught ReferenceError: google is not defined(anonymous function)
util.js:208 Google Maps API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys
util.js:208 Google Maps API warning: SensorNotRequired https://developers.google.com/maps/documentation/javascript/error-messages#sensor-not-required
js?sensor=false&_=1467561611964:32 Google Maps API error: MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-errorMy environment: Drupal 8.1.2 with caching and css/js compression enabled.
Currently, I don't have found a way to add my api key. To overwrite/extend the "google-map-apis" library works only for the maps displayed in the frontend theme. But not if I edit a node.
Also, I think the integration of the "google-map-apis" is too late and whereby the "google not defined" js error occurs.
| Comment | File | Size | Author |
|---|---|---|---|
| #15 | setting-for-google-api-key-2759953-15.patch | 7.6 KB | pauloamgomes |
| #13 | setting-for-google-api-key-2759953-13.patch | 7.6 KB | pauloamgomes |
| #3 | setting-for-google-api-key-2759953.patch | 7.69 KB | ashwinsh |
Comments
Comment #2
cbeier commentedThe way that I currently use to get the module to run on production is to modify the library js path via hook_library_info_alter() :
And then add you Google API key to your settings.php:
Comment #3
ashwinshHello @cbeier,
I have attached a patch for this issue, please review it.
Now users can choose whether they want to use an api key or a 'for Work' client id. It will also provides a warning on the status report page if an api key or client id is not provided so that users are aware it.
Also added configuration link for this module. (Reference Path: admin/config/gmap_field_settings)
Note: Please clear cache while reviewing these changes.
Thank you,
AshwinSh
Comment #4
ashwinshComment #5
ashwinshComment #6
cbeier commentedMaybe a general discussion: What is the best practice to integrate a external library/js with variable params in Drupal 8?
In the drupal documentation I don't have find a proper answer. Maybe it is a better way to integration the gmap js file not via a library, because we always have to manipulate the path via hook.
Comment #7
ashwinshHello @cbeier,
Did you review above patch file?
See : https://www.drupal.org/theme-guide/8/assets for assets management in Drupal 8.
As per drupal standards, we can integrate external js/css library through library.yml file and override as per requirements. If you have any other reference links or any other way to handle this then please share it.
Thank you,
Comment #8
javivf commentedIt works as expected and I think is the correct way to setup js library
@ashwin.shaharkar Thanks :)
Comment #9
sokru commentedWorks as planned, but should there be link in configuration page
/admin/configto settings pageadmin/config/gmap_field_settings?Comment #10
ashwinshHello @sokru,
Thank you for review.
I have already added a link for 'admin/config/gmap_field_settings' in google_map_field.info.yml file as 'configure: gmap.field.settings' in patch file. Also please check google_map_field.routing.yml for routing.
Thank you,
Comment #11
tanmuhittin commentedI still get error. I use drupal 7. Patch file doesnt work. Cannot add the keywrong question sorryComment #12
kbentham commentedThis works great! I agree with @sokru, it would be helpful if the config page was discoverable through configuration page. There should be a links.menu.yml file that adds the link to the web services menu item "system.admin_config_services".
Comment #13
pauloamgomes commentedHi, just followed previous suggestion and updated @ashwinsh patch to include the link. Also changed the menu path by replacing the underscore with dashes.
Comment #14
pauloamgomes commentedComment #15
pauloamgomes commentedRemoved blank space.
Comment #16
kmoll commentedI have reviewed the patch. I am able to add a key through UI page added and all warnings/errors are gone once a key is added.
+1 RTBC.
Comment #17
kmoll commentedComment #18
Carlos Miranda Levy commentedNot wanting to delay this commit any further, but per convention and as common practice shared by other modules, the API key definition should be at least listed at:
/admin/config/services.Comment #20
pauloamgomes commentedPatch applied to dev version, please review.
Comment #21
pauloamgomes commentedComment #22
pauloamgomes commentedComment #23
moshe weitzman commentedThis module has no default config in a /config folder. It should just like most modules in core. There should additionally be a contrib schema file. See https://www.drupal.org/docs/8/creating-custom-modules/defining-and-using...
Comment #24
pauloamgomes commentedThanks @moshe-weitzman, created a new issue and patch at #2849944