跳至內容

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 年前檢視次數 141 次

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 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。