2017-04-27 46 views
1

我得到角和谷歌距離矩陣沒有訪問控制報頭

的XMLHttpRequest不能加載 https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=bl79yt&destinations=cw73bz&key=mykey。 請求的 資源上沒有「Access-Control-Allow-Origin」標題。

在我的角應用程序。我有我的HTTP請求到這樣谷歌的距離矩陣:

var url = 'https://maps.googleapis.com/maps/api/distancematrix/json?units=imperial&origins=' + pcodefrom + '&destinations=' + pcodeto + '&key=mykeyhere'; 
    console.log(url); 
    $http({method: 'GET', url: url,headers: { 
      "X-Content-Type-Options": "nosniff", 
      "X-Frame-Options": "SAMEORIGIN", 
      "X-Rack-CORS": "preflight-hit; no-origin" 
     }}).success(function(data) { 
      }; 
        }).error(function(data){ 

        }); 

伊夫允許在谷歌API控制檯中的網站鏈接,但它仍然沒有工作。

回答