Top City
Get a list of popular cities around the world.
| Interface code | Interface | Class |
|---|---|---|
| geoCityTop | Top city | GeoCityTopResponse |
Parameters
GeoCityTopParameter
-
rangeSet to search only within a certain country or region. The country and region name needs to use country code ISO 3166. If this parameter is not set, the search range will be all cities. Example:range=cn -
numberNumber of the results in response, from 1 to 20, 10 is the default. -
langMulti-language setting, please see Language to find out how our multi-language works and how to set up.
Sample code
Swift
Task{
do {
let response = try await QWeather.instance
.geoCityTop(.init(range: Range.CN))
print(response)
} catch QWeatherError.errorResponse(let error) {
print(error)
} catch {
print(error)
}
}
Objective-C
GeoCityTopParameter *parameter = [GeoCityTopParameter instanceWithRange:@(RangeCN) number:@(10) lang:@(LangZH_HANS)];
[QWeatherObjc geoCityTop:parameter completionHandler:^(GeoCityTopResponse * _Nullable response, NSError * _Nullable error) {
if (response) {
NSLog(@"%@", response.description);
}
if (error) {
NSLog(@"%@", error.localizedDescription);
}
}];
Response
GeoCityTopResponse
-
codeSee Status Code -
topCityList.nameLocation Name -
topCityList.idLocation ID -
topCityList.latLatitude of the location -
topCityList.lonLongitude of the location -
topCityList.adm2Name of the superior administrative division of the location -
topCityList.adm1The first-level administrative area of the location -
topCityList.countryCountry name of the location -
topCityList.tzLocation timezone -
topCityList.utcOffsetThe number of hours offset between local time and UTC time, refer to UTC Offset -
topCityList.isDstIs the location currently on daylight saving time.1for daylight saving time and0for not in daylight saving time -
topCityList.typeLocation type -
topCityList.rankLocation Rank -
topCityList.fxLinkResponsive web page of this location, easy to embed in your website or APP -
refer.sourcesData source and other statements, may be null -
refer.licenseData license, may be null