Google 地点 API - 状态:"REQUEST_DENIED" 在移动设备上

Google Places API - status: "REQUEST_DENIED" on mobile

我正在使用距离矩阵服务来获取两点之间的步行持续时间。它在桌面上运行良好,但在我的移动设备上,我从回调中获得了 REQUEST_DENIED 状态。关于如何使其也适用于移动设备的任何想法?

function calculateDistance(origin, destination) {
  var service = new google.maps.DistanceMatrixService();
  service.getDistanceMatrix(
  {
    origins: [origin],
    destinations: [destination],
    travelMode: google.maps.TravelMode.WALKING,
    unitSystem: google.maps.UnitSystem.METRIC,
    avoidHighways: false,
    avoidTolls: false
  }, callback);
}

您需要在项目的 info.plist 文件中添加 <key>NSExceptionAllowsInsecureHTTPLoads</key>