Fx.location: an API related to querying the location
1. Query the attribution of a single number
Fx.location.findByMobile(<String mobile>)
Parameter Description
| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| mobile | String | mobile phone number |
return type
APIResult
Return value description
Map
Java example
APIResult ret = Fx.location.findByMobile("11111111111");
if (ret. isError()) {
log.info(ret.message());
} else {
log.info(ret.getData());
}
Groovy example
def(Boolean error, Map result, String errroMessage) = Fx. location. findByMobile("11111111111")
// Add two parameters to the return value
//province_code String type, the area code of the province
//city_code String type, the area code of the city
2. Batch query number attribution
Fx.location.findByMobiles(<List mobile>)
Parameter Description
| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| mobile | List | mobile phone number list |
return type
APIResult
Return value description
List
Java example
APIResult ret = Fx.location.findByMobiles(Lists.newArrayList("11111111111", "12252225222"));
if (ret. isError()) {
log.info(ret.message());
} else {
log.info(ret.getData());
}
Groovy example
def(Boolean error, Map result, String errroMessage) = Fx. location. findByMobiles(["11111111111", "12252225222"])
3. According to latitude and longitude, calculate the distance between two points
Fx.location.distance(<BigDecimal longitude1>, <BigDecimal latitude1>, <BigDecimal longitude2>, <BigDecimal latitude2>)
Parameter Description
| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| longitude1 | BigDecimal | Longitude of the first point |
| latitude1 | BigDecimal| the latitude of the first point |
| longitude2 | BigDecimal | Longitude of the second point |
| latitude2 | BigDecimal | latitude of the second point |
return type
APIResult
Return value description
BigDecimal
Java example
BigDecimal longitude1 = BigDecimal.valueOf(116.374409); //The precision of location 1
BigDecimal latitude1 = BigDecimal.valueOf(39.942939); //Latitude of location 1
BigDecimal longitude2 = BigDecimal.valueOf(116.375721); //The precision of location 2
BigDecimal latitude2 = BigDecimal.valueOf(39.942925); //Latitude of location 2
APIResult ret = Fx.location.distance(longitude1,latitude1,longitude2,latitude2);
if (ret. isError()) {
log.info(ret.message());
} else {
log.info(ret.getData());
}
Groovy example
BigDecimal longitude1 = 116.374409 //The precision of location 1
BigDecimal latitude1 = 39.942939//Latitude of location 1
BigDecimal longitude2 = 116.375721//accuracy of location 2
BigDecimal latitude2 = 39.942925 //Latitude of location 2
def (Boolean error,Long result,String errorMessage) = Fx.location.distance(longitude1,latitude1,longitude2,latitude2)
if( error ){
Fx.log.info("calculation error: " + errorMessage)
}else{
Fx.log.info(result)
}
4. According to the area code, query the Chinese language of the provinces and cities in the area
Fx.location.findCountryAreaLabel(<String code>, <String type>)
Parameter Description
| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| code | String | region code |
| type | String | country country province province city city district district town district |
return type
String
Return value description
String (returns the name of the country, province, city, or city, and returns empty if the query cannot be found)
Java example
String label = Fx. location. findCountryAreaLabel("249","province");
Groovy example
String label = Fx. location. findCountryAreaLabel("249","province")
5. According to the region, province and city Chinese, query the region code
Fx.location.findCountryAreaCode(<String label>, <String type>)
parameter saysBright
| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| label | String | region, province and city |
| type | String | country country province province city city district district town district |
return type
String
Return value description
String (returns the area code of the country, province, city, city, or region, if it cannot be found, it returns empty)
Java example
String provinceCode = Fx.location.findCountryAreaCode("Heilongjiang","province");
Groovy example
String provinceCode = Fx.location.findCountryAreaCode("Heilongjiang","province")
6. Query country, province, city
Fx.location.getCountryAreaOptions()
return type
APIResult
Return value description
Map
Java example
APIResult ret = Fx.location.getCountryAreaOptions();
if (ret. isError()) {
log.info(ret.message());
} else {
log.info(ret.getData());
}
Groovy example
def(Boolean error, Map data, String mesage) = Fx. location. getCountryAreaOptions()
if (error) {
log.info("error: " + message)
}
log.info(data['country'])
log.info(data['province'])
log. info(data['city'])
log. info(data['district'])
7. Check the standard administrative division code according to the Label of the province and city
Fx.location.getZoningCodeByLabel(<String type>, <String label>)
Parameter Description
| parameter | type | description |
| ------------ | ------------ | ----------------------- ----------------------------------------- |
| type | String | District type: only supports province: province, city: city, district: district |
| label | String | region name |
return type
APIResult
Return value description
Map
Java example
APIResult ret = Fx.location.getZoningCodeByLabel("city", "Beijing");
if (ret. isError()) {
log.info(ret.message());
} else {
log.info(ret.getData());
}
Groovy example
def(Boolean error, Map data, String mesage) = Fx.location.getZoningCodeByLabel("city", "Beijing")
if (error) {
log.info("error: " + message)
}
log. info(data)