Skip to content

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
  }

asked a year ago134 views

3 Answers
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.

answered a year ago

  • 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
EXPERT

answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.