use Baidu Map location in iOS to get city coordinates, city name, city number information
/** when you get the coordinates of the position, the callback function */
-(void) Didupdatebmkuserlocation: (bmkuserlocation *) userlocation{
Bmkcoordinateregion region;
Region.center.latitude = UserLocation.location.coordinate.latitude;
Region.center.longitude = UserLocation.location.coordinate.longitude;
Region.span.latitudeDelta = 0;
Region.span.longitudeDelta = 0;
NSLog (@ "Current coordinates are:%f,%f", userlocation.location.coordinate.latitude,userlocation.location.coordinate.longitude);
Clgeocoder *geocoder = [[Clgeocoder alloc] init];
[Geocoder reverseGeocodeLocation:userLocation.location completionhandler:^ (Nsarray *array, Nserror *error) {
if (Array.count > 0) {
Clplacemark *placemark = [array objectatindex:0];
if (placemark! = nil) {
NSString *city = placemark.locality;
NSLog (@ "Current city name------%@", cities);
Bmkofflinemap * _offlinemap = [[Bmkofflinemap alloc] init];
_offlinemap.delegate = self;//can not
nsarray* records = [_offlinemap searchcity:city];
bmkolsearchrecord* Onerecord = [Records objectatindex:0];
City code such as: Beijing for 131
Nsinteger Cityid = Onerecord.cityid;
NSLog (@ "Current City number-------->%zd", Cityid);
Close service after finding the current location in the city
[_locservice Stopuserlocationservice];
}
}
}];
}
Use Baidu Map location in iOS to get city coordinates, city name, city number information