跳至内容

Location service timezoneId

0

Hi, I am calling Location service with address longitude and latitude and time zoneId in response returns null. timeZone object is null. Could you please tell me if this is the correct api to use.

public String getTimeZoneId(double latitude, double longitude) throws Exception {
    String timeZoneId = null;
    SearchPlaceIndexForPositionRequest request = SearchPlaceIndexForPositionRequest.builder()
        .indexName("myPlacesIndex")
        .position(Arrays.asList(longitude, latitude)) // [longitude, latitude]
        .build();

    SearchPlaceIndexForPositionResponse response = locationClient.searchPlaceIndexForPosition(request);
    for (SearchForPositionResult result : response.results()) {
      if (result.place().timeZone() != null) {
        timeZoneId = result.place().timeZone().name();
        break;
      }
    }
return timeZoneId
  }

已提问 1 年前142 查看次数

3 回答
0
  • Just wondering if placesIndex required for this request?

0

Somehow I am getting error when using sdk java2 ReverseGeocodeRequest. Can not set indexName etc, and GeoPlacesClient is throwing endpoint provider error etc. I will stick with my original request, I changed from Esri to HERE and now able to get result. Was planning to use new api as suggested above but no lock.

已回答 1 年前

  • Placeindex is not required with the new APIs. Can you post the code here for your new request?

0

Hello.

Most likely the reason is because you are using a PlaceIndex that is configured with Esri as the data provider.

However we have released a new version of the API with a new Reverse Geocode API: https://docs.aws.amazon.com/location/latest/APIReference/API_geoplaces_ReverseGeocode.html

We recommend using this as it has better performance and more information about a given location.

Thanks!

AWS
专家

已回答 1 年前

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。