2016-11-21 30 views
0

でオートコンプリートを置くために、私は、このリンクとその作業を使用していますが、それはAPIが必須である場合は、Googleがangularjs

リンク警告を示しています。https://maps.googleapis.com/maps/api/js?libraries=places

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

助けてください。事前におねがいします。

routerApp.directive('googleplace', function() { 
 
    return { 
 
     require: 'ngModel', 
 
     link: function(scope, element, attrs, model) { 
 
      var options = { 
 
       types: [], 
 
       componentRestrictions: {} 
 
      }; 
 
      scope.gPlace = new google.maps.places.Autocomplete(element[0], options); 
 
      
 
      google.maps.event.addListener(scope.gPlace, 'place_changed', function(e) { 
 
       scope.$apply(function() { 
 
        model.$setViewValue(element.val()); 
 
        // 
 
        scope.secondplacebox = scope.chosenPlace; 
 
        var latitude = scope.gPlace.getPlace().geometry.location.lat().toFixed(6); 
 
\t    var longitude = scope.gPlace.getPlace().geometry.location.lng().toFixed(6); 
 
\t    //alert(latitude); 
 
\t \t  scope.Fn_SearchFood(latitude,longitude,scope.date); \t \t 
 
\t \t \t \t \t }); 
 
      }); 
 
     } 
 
    }; 
 
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.min.js"></script>

答えて

0

は、GoogleのAPIを使用したい場合は、あなたのAPIキーを設定する必要があります。 APIキーを作成し、そのキーをスクリプトに入れる必要があります。 GoogleApiを使用するための

Google Developer API

<script src="http://maps.google.com/maps/api/js?sensor=false&key=myKey"></script> 
+0

が、私はエラーを得た---- JSライブラリ=場所&センサー=偽&= AIzaSyDb_sP-jlvEvKsS6_7QTBwgXt0I4qCv1JYキー:?34 GoogleマップAPIエラー:RefererNotAllowedMapError https://developers.google.com/maps/documentation/javascript /エラーメッセージ#referer-not-allowed-map-error 許可するサイトのURL: –

0

あなたはfoofleデベロッパーコンソールでのアカウントを作成する必要があり、あなたは、GoogleのAPIを使用しますれているサイトのURLを言及する必要があります。

アカウント作成後、Google APIスクリプトに配置されるトークンキーを取得します。私は私のAPIを置い

関連する問題