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 is not applicable to other entities or functionalities.

Important

Fields 

FieldDescriptionModifier and Type
cityName of the city.java.lang.String
latitudeLatitudinal coordinate of the location, should be from -90 to 90.java.lang.Double
longitudeLongitudinal coordinate of the location, should 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
2public java.lang.Double latitude

Latitudinal coordinate of the location, should be from -90 to 90.

longitude 

1@Nullable
2public java.lang.Double longitude

Longitudinal coordinate of the location, should be from -180 to 180.

city 

1@Nullable
2public java.lang.String city

Name of the city.

stateProvinceCode 

1@Nullable
2public java.lang.String stateProvinceCode

Name of the state or province.

postalCode 

1@Nullable
2public java.lang.String postalCode

Postal code of the location.

Constructors 

Location(latitude, longitude) 

Creates a location with geographic coordinates.

1public Location(double latitude,
2                double longitude)

Parameters:

ParameterDescription
latitudeLatitudinal coordinate, should be from -90 to 90
longitudeLongitudinal coordinate, should be from -180 to 180

Location(city, stateProvinceCode) 

Creates a location with city and state.

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

Parameters:

ParameterDescription
cityCity name
stateProvinceCodeState or Province Code (e.g. MA)

Location(postalCode) 

Creates a location with postal code.

1public Location(@NonNull
2                java.lang.String postalCode)

Parameters:

ParameterDescriptionRequired?
postalCodePostal codeNo

Methods 

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

fromJSONObject 

1@Nullable
2public static Location fromJSONObject(@NonNull
3                                                org.json.JSONObject json)