2016-03-24 6 views
2
私は私のチェックアウトページに2つのスクリプトをロードしてい

Gmaps NoAPIKeyエラー

function wpb_adding_scripts() { 
    if (function_exists('is_woocommerce')) { 
     if (is_woocommerce() && is_checkout()) { 
      wp_register_script('google-maps-api', 'https://maps.googleapis.com/maps/api/js?key=[iprovidemykeyhere]&callback=initMap'); 
      wp_register_script('location_tracker', get_stylesheet_directory_uri() . '/js/track_location.js', array('google-maps-api')); 

      wp_enqueue_script('google-maps-api'); 
      wp_enqueue_script('location_tracker'); 

     } 
    } 
} 
add_action('wp_enqueue_scripts', 'wpb_adding_scripts', 999); 

...しかし、私は正確に上記のURLにキーを提供しておりますが、私は以下の取得:

GoogleマップのAPIの警告:NoApiKeys https://developers.google.com/maps/documentation/javascript/error-messages#no-api-keys

Google MapsのAPI警告:SensorNotRequired https://developers.google.com/maps/documentation/javascript/error-messages#sensor-not-required

+0

URLがダブルエンコードされている可能性があります(生成されたHTMLに表示されるURLを貼り付けることはできますか)。そうであれば、私の答え[ここ](http://stackoverflow.com/a/9504653/1714)が役に立ちます – Hobo

答えて

3

ステップ1:あなたGoogle Consoleに移動し、[概要]タブからGoogle Maps JavaScript APIを可能にするので、Credentials]タブに移動し、プロジェクトのAPIキーを作成してください。

手順2:下記の行をhtmlに追加し、yourKEYhereをapiキーで変更します。

<script src="https://maps.googleapis.com/maps/api/js?key=yourKEYhere"></script> 

ステップ3:使用gmaps.jsplugin

幸運を祈る!

関連する問題