3

I have a ZK (Java Spring) application using Google Maps (gmaps). The version of ZK I am using is 7.0.3 EE.

In my application I didn't use a google API key, and since some time ago things seemed to work fine (I could correctly visualize the map).

It seems that since last july the use of an API key has become necessary, so I am trying to insert an API key.

So, I created a Browser API Key for my application, following the instruction at this https://support.google.com/cloud/answer/6158862?hl=en&ref_topic=6262490. Then, following the example at https://www.zkoss.org/zkdemo/reporting/google_map I added the following tag in my .zul page:

<script type="text/javascript" content="zk.googleAPIkey='my api key'" />
<gmaps ...> 
</gmaps>

Note that if I access the web application from a local IP the map is correctly shown. If, on the other hand I access it through a registered domain name portal.mydomain.eu instead of the map I see a gray box with the following error message (note that in "Accept requests from these HTTP referrers (web sites)" I inserted my domain name as "*.mydomain.eu/"):

Oops! Something went wrong.
This page didn't load Google Maps correctly. See the JavaScript console for technical details.

The following are the Javascript console error messages (the messages are in Italian, I've inserted the english translation below each line where relevant):

GET 
http://portal.mydomain.eu/images/portal_footer.jpg [HTTP/1.1 404 Not Found 23ms]
L’API Fullscreen con prefisso è deprecata, al suo posto utilizzare l’API senza prefisso. Per ulteriori informazioni consultare https://developer.mozilla.org/en-US/docs/Web/API/Fullscreen_API controls.js:23:54
***the Fullscreen API with prefix is deprecate, use insteass the API without a prefix. For further information ... ***

"Google Maps API error: MissingKeyMapError https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error" js:35:350
"Google Maps API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys" util.js:221:12
"Google Maps API warning: RetiredVersion https://developers.google.com/maps/documentation/javascript/error-messages#retired-version" util.js:221:12
"Google Maps API warning: SensorNotRequired https://developers.google.com/maps/documentation/javascript/error-messages#sensor-not-required" util.js:221:12
"Google Maps API warning: InvalidClientId https://developers.google.com/maps/documentation/javascript/error-messages#invalid-client-id" util.js:221:12
L’utilizzo di getPreventDefault() è deprecato. Al suo posto utilizzare defaultPrevented.
***the usage of getPreventDefault() is deprecated. Use instead defaultPrevented.***

Any idea on what can I be doing wrong? Is it ok to have a "Browser Key" or do I need a different type of key?

edit:

I tried to replace the script tag with the one found at the link Whats the API Key for in Google Maps API V3?

<script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY" type="text/javascript"></script>

With this I see a white box instead of the gray one, and on the javascript console the error is now Google Maps API error: RefererNotAllowedMapError

Community
  • 1
  • 1
chrx
  • 2,169
  • 5
  • 24
  • 45
  • Did you try latest version of gmaps? Just out v 3.0.4 : https://www.zkoss.org/download/zkgmaps – chillworld Sep 01 '16 at 04:10
  • I updated the version to 3.0.4 and it works. Thank you very much: please repost this suggestion as an answer so that I can accept it – chrx Sep 01 '16 at 08:34

3 Answers3

2

Your answer to the updated question can be found on the documentation. Basically, RefererNotAllowedMapError indicates that the URL loading the API is not added to the list of referrers.

The current URL loading the Google Maps JavaScript API has not been added to the list of allowed referrers. Please check the referrer settings of your API key on the Google API Console.

See API keys in the Google API Console. For more information, see Best practices for securely using API keys.

Community
  • 1
  • 1
adjuremods
  • 2,938
  • 2
  • 12
  • 17
1

There is a new version of gmaps just released

Try this version : 3.0.4. https://www.zkoss.org/download/zkgmaps

chillworld
  • 4,207
  • 3
  • 23
  • 50
0

You can try this code :

<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"/> <gmaps>....</gmaps>

Also you have to upgrade your API from v2 to v3. Because Google Map up to Version 2 required API Key.

Get more details on this link.

  • I tried your suggestion but so I keep getting `Google Maps API warning: NoApiKeys`, `Google Maps API warning: SensorNotRequired ` and `Google Maps API error: MissingKeyMapError` errors in Javascript console. Moreover, it seems that as of June 22, 2016 Google Maps V3 no longer supports keyless access. http://stackoverflow.com/questions/2769148/whats-the-api-key-for-in-google-maps-api-v3 – chrx Aug 31 '16 at 09:33
  • I tryied to change the script according to what suggested in the thread i linked in my previous comment: see edit on the post – chrx Aug 31 '16 at 09:44