Problem/Motivation

There is a Javascript warning being shown when the lib is loaded:
Google Maps API warning: SensorNotRequired https://developers.google.com/maps/documentation/javascript/error-messages#sensor-not-required
This parameter is not required and can be removed.

Google Maps API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys
Google API key needs to be added in the URL

Proposed resolution

  • Removal of sensor parameter from API
  • Addition of key parameter

Remaining tasks

N/A

User interface changes

N/A

API changes

N/A

Data model changes

N/A

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rodrigoeg created an issue. See original summary.

rodrigoeg’s picture

Status: Active » Needs review
FileSize
608 bytes

Patch attached

das-peter’s picture

Looks good to me. But how about tackling the warning Google Maps API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys at the same time?
Attached patch:

  • Introduces the new variable gsl_google_api_key which can hold the API key.
  • Introduces the new function google_store_locator_get_google_api_key() - shamelessly copied from gmap module. The function returns the API key and integrates with the keys_api and keys module.
  • Adds a configuration option to set the API key. Including a link to the Google documentation.
  • Removes the sensor parameter and adds the key parameter to the JS loading

Since the patch is still pretty readable, even with all the additions, I'm bold and sort of hijack this issue ;)

rodrigoeg’s picture

Title: Javascript warning "Google Maps API warning: SensorNotRequired" » Cleanup Javascript warnings
Issue summary: View changes
FileSize
41.41 KB

Very good additions, @das-peter.
I updated the title and summary of this issue to reflect these updates.

I noticed the Geocoder modules already have a field with Google API key. I am not sure if it would be better to use this other variable, since this module is a dependency of Google Store Locator:

Also, this new field of API key is required. If the user is using the module keys_api or keys, I think this field should not be required in this case, but I am not sure how other modules handle this integration. Maybe adding in the description of the field more information about this integration available with keys_api and keys modules will also help.

rodrigoeg’s picture

Status: Needs review » Needs work
rodrigoeg’s picture

Category: Task » Bug report
Priority: Normal » Major

Changing the priority because this module does not work without an API key anymore.

orkineo’s picture

Hello Rodrigo,

Have you managed to run the link ave API for Google?
I have a site blocked for a month and if there is no chance to restore the system I have to put up another.

Thank you for your effort and your work!

rodrigoeg’s picture

Status: Needs work » Needs review
FileSize
3.41 KB

Rerolling the patch on the newest dev version of the module.

Also I have removed the integration with keys_api module. It seems this module was renamed to keys and now only the keys module exists. Since it is a new integration being added here, I think it is better to use only the new name of the module (for reference: #1899086: references to "keys_api" module?)

I have also added a verification in the configuration page (also based in gmap module) to hide the field and show some others instructions if keys module is enabled.

One more step was added for the module installation in README file to mention this API key configuration. Probably the documentation page of the module needs to be updated after a new version is released (I will try to remember of doing it).

rodrigoeg’s picture

Hi @orkineo, try this latest patch to check if it resolves your issue.

orkineo’s picture

Hello Rodrigo,
A big thank you for this work, the patch worked instantly.
It's a great module and community

AkiBro’s picture

Hi All,

I have installed the dev version and added an API key to my Geocoder but I still get an "Oops! Something went wrong. This page didn't load Google Maps correctly. See the JavaScript console for technical details." error.

Any help or suggestions?

I am not sure how to add any patches

orkineo’s picture

Hi, the best way to apply a patch is to follow the community guidelines detailed here: https://www.drupal.org/patch/apply

In the case of this pacth which is very simple, I advise you to open the corresponding files (README.txt, google_store_locator.install and google_store_locator.module) and add the lines preceded by a + in the Rodrigo file . To find out where to place each line, simply look in your files for the previous lines that are already there. Do not forget to remove the + to the lines you are going to add so that the new code is taken into account.

This will solve the problem if you have the correct versions of each module required as well as the corresponding libraries.

howdytom’s picture

#8 worked for me too. Thank you!

Is it required to add the Google Maps API key twice?

I have added the API key to:
admin/config/search/google_store_locator
admin/config/content/geocoder

orkineo’s picture

Hello,
You actually need to enter the key twice:
- The Geocoder module needs it to generate the coordinates of the address from your store location
- And the store locator module to display the general map.

  • rodrigoeg committed a373331 on 7.x-1.x
    Issue #2776133 by rodrigoeg, das-peter: Cleanup Javascript warnings
    
rodrigoeg’s picture

Thanks everyone for improving and testing the patch and also give support to the community.

I have committed the changes in dev version of the module. If you could please test this version to check if everything if working fine.

roberthpchao’s picture

It still not showing the map, still missing key. I have updated with dep verion and I have key entered into both geo and store locator. Please help.

rodrigoeg’s picture

@roberthpchao,

Are you still seeing the same warnings in the console of your browser?

Sorry if it was done before, but could you please try to clear drupal caches and also your browser caches?

howdytom’s picture

@rodrigoeg: I just want to let you know that 7.x-1.x-dev works for me, too. This is a huge improvement. Thank you for your patch.

Any plans for committing the changes to the stable Google Store Locator release 7.x-1.2?

howdytom’s picture

Status: Needs review » Closed (won't fix)
howdytom’s picture

Status: Closed (won't fix) » Fixed
roberthpchao’s picture

I am using Kickstart, tried 3 times clear caches, all returns "gateway timeout". Changed API (no restriction) in between. Cleared browser caches, but still encounter the same problem.

rodrigoeg’s picture

Hi, @howdytom,

It will released in the next version (probably number 7.x-1.3) in a few days.

rodrigoeg’s picture

Hi @roberthpchao,

Were you facing this same problem even before upgrading this module to 1.x-dev?

It seems to be a PHP timeout issue. Maybe your PHP timeout is too small.

roberthpchao’s picture

Hi Rodrigoeg,
Yes, same issue (java console say missing api key) before installing 1.x-dev. After installed 1.x-dev. I entered api key in both store locator and geocoder module. (before had only geo)
Thank you.

gajanannehul’s picture

After applying the patch getting error
TypeError: marker is null ()
marker.setVisible(false); (google_store_locator.js line number 606).

because of above issue search box is not working. After console.log(marker); I ma getting "null" every time.

rodrigoeg’s picture

Hi, @gajanannehul,

I think your new problem is related with the issue #2473595: "Where are you?" location doesn't do anything.... Please try to apply that other patch also to see it works.

orkineo’s picture

Sure enough, I had this problem if I used GeoJSON 7.x-1.0-beta3 with Google Store Locator 7.x-1.2 and the pacth quoted by Rodrigo # 27 solved the problem.

rodrigoeg’s picture

New release created with these changes: 7.x-1.3

Status: Fixed » Closed (fixed)

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