Title: JavaScript Error when no API key is given
Last modified: September 1, 2016

---

# JavaScript Error when no API key is given

 *  Resolved [Air.](https://wordpress.org/support/users/air-1/)
 * (@air-1)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/javascript-error-when-no-api-key-is-given/)
 * Hello guys.
 * When I have map added in shortcode, but not added API key to site yet, map return
   JavaScript error that breaks site
    `TypeError: a is undefined` [http://maps.google.com/maps/api/js?v=3.exp&&libraries=places](http://maps.google.com/maps/api/js?v=3.exp&&libraries=places)
 * Can you do something about it, to not load google files, when API key is not 
   added yet?
 * This is breaking pages when we import sites made for clients to their servers.
 * With kind regards.
 * [https://wordpress.org/plugins/wp-google-maps/](https://wordpress.org/plugins/wp-google-maps/)

Viewing 7 replies - 1 through 7 (of 7 total)

 *  [Jarryd Long](https://wordpress.org/support/users/jarryd-long/)
 * (@jarryd-long)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/javascript-error-when-no-api-key-is-given/#post-7693992)
 * Hi there.
 * Sorry for only getting back to you now.
 * Unfortunately we don’t have any control over what the Google Maps API returns
   if the API key has not been entered.
 * At the moment, you will need to enter an API key to make full use of the map.
   So sorry about that.
 *  Thread Starter [Air.](https://wordpress.org/support/users/air-1/)
 * (@air-1)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/javascript-error-when-no-api-key-is-given/#post-7694024)
 * That is not what I am asking about.
 * You know when API key was given, and you know that is now mandatory to use API
   key to use google maps. So couldn’t you just to not enqueue google scripts when
   you don’t have API key provided by user?
 * Activating your plugin rises JavaScript error in certain circumstances now – 
   that is not something that should be happening with plugin.
 *  [Jarryd Long](https://wordpress.org/support/users/jarryd-long/)
 * (@jarryd-long)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/javascript-error-when-no-api-key-is-given/#post-7694033)
 * Hi there
 * I apologize for the confusion caused on my part.
 * Please advise what sort of errors you are getting when activating our plugin?
 * By not loading the Google Maps API on the page, that would cause a variety of
   additional JavaScript errors as Google Maps API functions would still be called.
 *  Thread Starter [Air.](https://wordpress.org/support/users/air-1/)
 * (@air-1)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/javascript-error-when-no-api-key-is-given/#post-7694042)
 * I gave you error already, and scenario when it will happen.
 * Like I said, problem is, that in certain conditions(mentioned above), plugin 
   will cause JavaScript error, by loading library it uses.
 * I thought that you could make such solution(for shortcodes, or places that asks
   your plugin for map):
 * If there is API key provided – proceed as usual.
 * If there is NO API key provided – don’t load anything external, don’t do anything
   fancy just display “Please provide map API key”.
 * What problems do you see with such approach?
 * If issues is with grandfathered maps, then you could add option to load API regardless
   of API key.
 * I don’t know your plugin, I just thought it would be logic approach for current
   situation with google politics.
 * With kind regards.
 *  Plugin Author [NickDuncan](https://wordpress.org/support/users/nickduncan/)
 * (@nickduncan)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/javascript-error-when-no-api-key-is-given/#post-7694043)
 * Thanks Air
    Makes sense. I’ll add this to the road map and figure out how best
   we can move forward with this.
 * Ultimately, what we would like to happen is to fall back to Open Street Maps 
   as a fail-over when there is no API key. Additionally, OSM can be another option
   for users not wanting to go through the rigorous steps of getting an API key.
 * Thank you for your suggestion!
 *  Thread Starter [Air.](https://wordpress.org/support/users/air-1/)
 * (@air-1)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/javascript-error-when-no-api-key-is-given/#post-7694044)
 * Thanks for taking this in consideration.
 * OSM approach feels like lot of additional work for this temporary situation, 
   when people don’t know yet about need of API key. However it is very nice idea.
 * Have a good day:-)
 *  [Jarryd Long](https://wordpress.org/support/users/jarryd-long/)
 * (@jarryd-long)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/javascript-error-when-no-api-key-is-given/#post-7694055)
 * Not a problem, Air. Thank you, and same to you 🙂

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘JavaScript Error when no API key is given’ is closed to new replies.

 * ![](https://ps.w.org/wp-google-maps/assets/icon-256x256.png?rev=3058363)
 * [WP Go Maps (formerly WP Google Maps)](https://wordpress.org/plugins/wp-google-maps/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-google-maps/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-google-maps/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-google-maps/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-google-maps/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-google-maps/reviews/)

## Tags

 * [javascript error](https://wordpress.org/support/topic-tag/javascript-error/)

 * 7 replies
 * 3 participants
 * Last reply from: [Jarryd Long](https://wordpress.org/support/users/jarryd-long/)
 * Last activity: [9 years, 8 months ago](https://wordpress.org/support/topic/javascript-error-when-no-api-key-is-given/#post-7694055)
 * Status: resolved