Location

Use the Location class to associate location information with an Item. It serves use cases such as filtering products based on availability in specific areas.

1public class Location
2extends java.lang.Object

The Location class is intended solely for use with items and isn’t applicable to other entities or functionalities.

Important

Fields 

FieldDescriptionModifier and Type
cityName of the city.java.lang.String
latitudeLatitudinal coordinate of the location. The value must be from -90 to 90.java.lang.Double
longitudeLongitudinal coordinate of the location. The value must be from -180 to 180.java.lang.Double
postalCodePostal code of the location.java.lang.String
stateProvinceCodeName of the state or province.java.lang.String

latitude 

1@Nullable
2@FloatRange(from=-90.0,
3            to=90.0)
4public Double latitude

Latitudinal coordinate of the location. The value must be from -90 to 90.

longitude 

1@Nullable
2@FloatRange(from=-180.0,
3            to=180.0)
4public Double longitude

Longitudinal coordinate of the location. The value must be from -180 to 180.

city 

1@Nullable
2public String city

Name of the city.

stateProvinceCode 

1@Nullable
2public String stateProvinceCode

Name of the state or province.

postalCode 

1@Nullable
2public String postalCode

Postal code of the location.

Constructors 

Location with Geographic Coordinates 

Creates a location with geographic coordinates.

1public Location(@FloatRange(from=-90.0,to=90.0)
2                double latitude,
3                @FloatRange(from=-180.0,to=180.0)
4                double longitude)

Parameters:

ParameterDescription
latitudeLatitudinal coordinate. The value must be from -90 to 90
longitudeLongitudinal coordinate. The value must be from -180 to 180

Location with City and State 

Creates a location with city and state.

1public Location(@NonNull
2                String city,
3                @NonNull
4                String stateProvinceCode)

Parameters:

ParameterDescription
cityCity name
stateProvinceCodeState or Province Code (for example, MA)

Location with Postal Code 

Creates a location with postal code.

1public Location(@NonNull
2                String postalCode)

Parameters:

ParameterDescription
postalCodePostal code

Methods 

MethodModifier and Type
fromJSONObject(org.json.JSONObject json)static Location

fromJSONObject 

1public static Location fromJSONObject(org.json.JSONObject json)