Actions on google 在谷歌的行动中,用粗略的位置信息获取用户所在国家的推荐方法是什么?

Actions on google 在谷歌的行动中,用粗略的位置信息获取用户所在国家的推荐方法是什么?,actions-on-google,Actions On Google,如果曲面提供精确的位置信息,则调用可能返回lat/lon坐标,或者返回邮政编码和城市以获取粗略的位置信息 对于前者,用户可以使用谷歌地图API对坐标进行反向地理编码,但是,后者可能不明确,因为没有提供国家信息。如果只提供粗略的权限,是否有建议的方法消除设备位置的歧义 举一个更具体的例子: const requestedPermission = app.data.requestedPermission; const permissions = app.SupportedPermissions; i

如果曲面提供精确的位置信息,则调用可能返回lat/lon坐标,或者返回邮政编码和城市以获取粗略的位置信息

对于前者,用户可以使用谷歌地图API对坐标进行反向地理编码,但是,后者可能不明确,因为没有提供国家信息。如果只提供粗略的权限,是否有建议的方法消除设备位置的歧义

举一个更具体的例子:

const requestedPermission = app.data.requestedPermission;
const permissions = app.SupportedPermissions;
if (requestedPermission === permissions.DEVICE_COARSE_LOCATION) {
  // Not available! We've only got .zipCode and .city.
  const countryCode = app.getDeviceLocation().countryCode;
  doSomethingBasedOnCountry(countryCode);
}
if (requestedPermission === permissions.DEVICE_PRECISE_LOCATION) {
  const { coordinates } = app.getDeviceLocation();
  return coordinatesToCountryCode(mapsClient, coordinates.latitude, coordinates.longitude)
    .then(doSomethingBasedOnCountry);
}

您是否查看了请求中的区域设置信息?你认为这对你有帮助吗


为什么要使用firebase标签?对不起,你说得对。这与这个问题无关。在locale标记中,绝对不能保证用户来自该国。助手还不支持许多语言,如果他们的语言不受支持,大多数人将默认使用en-US语言环境。