mustardBees/cmb_field_map

API Key activated but maps asking for ownership

Closed this issue · 2 comments

I have set up a new rules google cloud account because Im trying my theme on live server, I have generated API key, enqueued google-js with API key but I'm still getting in CMB2 form (Admin site) message "This page can't load Google Maps correctly" "Do you own this website?" After using Google Transition Tool result is positive and ownership is confirmed. I really don't know how to fix it. Can someone help me to sort it out?
I have tried
wp_enqueue_script('google_js','http://maps.google.com/maps/api/jskey=MY_API_KEY&sensor=false&callback=initMap')

wp_enqueue_script('google_js','//maps.googleapis.com/maps/api/jskey=MY_API_KEY&callback=initMap');

and other variations but no success. Before google new rules was all working fine If I cmd + click on link in enqueue_script it will run and open new window with google map loaded code.

Update: I have been on this issue spending all day. I can get maps only if I run web on terminal this mean http://192.168.1.1:8080/mywebsite and maps are running even without enqueueing google map script. Hmm. Anyway on localhost:8888/ and live server maps are not working at all. I have two different API Keys, one for live server and one for local dev. I find that maps.google.com is old call of v2 so Im using only googleapis.com .
wp_enqueue_script('google-maps', '//maps.googleapis.com/maps/api/js?key=MYAPIKEY');

EDIT 2: EDIT 2: I have installed Google plugin API checker . I have two results in
Admin Area : (not working)
ERROR: This site doesn't seem to be using an API key. Keyless usage will soon be deprecated. Please set up and secure a key for your project.
https://maps.googleapis.com/maps/api/js?libraries=places
and in JS console is warning.
util.js:226 Google Maps JavaScript API warning: NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys

on Page - front end (ok):
SUCCESS: Woohoo! This site is correctly using an API key when loading the Maps JavaScript API v3.

INFO: We could not find a visible Google Map within 2 seconds of loading the page. To optimize performance, only load the Maps JavaScript API if you plan on using the API.

https://maps.googleapis.com/maps/api/js?key=AIza*****0if0&ver=4.9.6

Still I can figure out where problem is :( Map is still not showing because of admin site problem.

Sorted by adding API key into cmb-fiels-map.php. Not elegant but it solved for now.