Newer Version Available
DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!
Let us know so we can improve!
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.ObjectThe Location class is intended solely for use with items and isn’t applicable to other entities or functionalities.
Important
| Field | Description | Modifier and Type |
|---|---|---|
city | Name of the city. | java.lang.String |
latitude | Latitudinal coordinate of the location. The value must be from -90 to 90. | java.lang.Double |
longitude | Longitudinal coordinate of the location. The value must be from -180 to 180. | java.lang.Double |
postalCode | Postal code of the location. | java.lang.String |
stateProvinceCode | Name of the state or province. | java.lang.String |
1@Nullable
2@FloatRange(from=-90.0,
3 to=90.0)
4public Double latitudeLatitudinal coordinate of the location. The value must be from -90 to 90.
1@Nullable
2@FloatRange(from=-180.0,
3 to=180.0)
4public Double longitudeLongitudinal coordinate of the location. The value must be from -180 to 180.
1@Nullable
2public String cityName of the city.
1@Nullable
2public String stateProvinceCodeName of the state or province.
1@Nullable
2public String postalCodePostal code of the location.
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:
| Parameter | Description |
|---|---|
latitude | Latitudinal coordinate. The value must be from -90 to 90 |
longitude | Longitudinal coordinate. The value must be from -180 to 180 |
Creates a location with city and state.
1public Location(@NonNull
2 String city,
3 @NonNull
4 String stateProvinceCode)Parameters:
| Parameter | Description |
|---|---|
city | City name |
stateProvinceCode | State or Province Code (for example, MA) |
Creates a location with postal code.
1public Location(@NonNull
2 String postalCode)Parameters:
| Parameter | Description |
|---|---|
postalCode | Postal code |
| Method | Modifier and Type |
|---|---|
fromJSONObject(org.json.JSONObject json) | static Location |
1public static Location fromJSONObject(org.json.JSONObject json)Newer Version Available