私は自分のlocalhostマシンからget要求を出しています(そして私のアプリケーションはローカルホスト上にとどまります)ので、場所に関する情報を得ることができます。Google Places APIのコード
ただし、CORS(XMLHttpRequest cannot load https://maps.googleapis.com/maps/api/place/details/json?placeid=[placeid]&key=[key]. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
)のため、Google Places APIおよび/またはChromeでこのリクエストを行うことはできません。
GoogleプレイスAPIからアクセスする方法はありますか(CORS Chromeプラグインなし)ですか?
私はちょうどVue2 & VueのリソースとJavaScriptでの単純なGETリクエストを使用しています:
this.$http.get(`https://maps.googleapis.com/maps/api/place/details/json?placeid=${googleplacesPlace}&key=${googleplacesToken}`).then(response => {
})
同じ問題私のために、Googpe地図JavascriptのAPIでこのようにそれを解決: VAR要求= { 場所:新google.maps.LatLng(LAT、LNG)、// gogleマップ緯度経度オブジェ 半径: '5000'、 タイプ:['airport'] }; let service = new google.maps.places.PlacesService(this.map); service.nearbySearch(request、this.Fncallback); } Fncallback(結果ステータス){ 場合(ステータス== google.maps.places.PlacesServiceStatus.OK){(VAR i = 0; iはresults.length <; iは++)用 {VAR場所=結果[私]; } } } –