Map Development-Geocoding & geo-coding

Source: Internet
Author: User

1. Geocoding: The conversion of a ' place name string ' to ' latitude and longitude ' [Geocoder geocodeaddressstring:<# (NSString *) #> completionhandler:<#^ (Nsarray *placemarks, Nserror *error) Completionhandler#> 2. Anti-geocoding: Converting ' latitude and longitude ' to ' place name string ' [Geocoder reversegeocodelocation:< # (Cllocation *) #> completionhandler:<#^ (Nsarray *placemarks, Nserror *error) Completionhandler#>] 3. Specific method invocation: ://(1). geocoding
-(void) geocoder{
1. Creating the encoding/anti-encoding manager
Clgeocoder *geocoder = [[Clgeocoder alloc]init];

2. Geocoding: Convert ' place name string ' to ' latitude and longitude '
[Geocoder geocodeaddressstring:@ "Beijing" completionhandler:^ (Nsarray *placemarks, Nserror *error) {

Placemarks is the ' landmark ' array tag location
Clplacemark *plmark = Placemarks.firstobject;

Get User location information
Cllocation *loc = plmark.location;

Get the latitude and longitude of a user
NSLog (@ "place name:%@ Longitude:%f Latitude:%f", plmark.name,loc.coordinate.longitude,loc.coordinate.latitude);
NSLog (@ "error%@", error);
}];

}

2. Anti-geo-coding
-(void) reversegeocoder{
1. Creating the encoding/anti-encoding manager
Clgeocoder *geocoder = [[Clgeocoder alloc]init];

2. Anti-coding: is to have ' clear latitude and longitude of the location information ' into the corresponding ' place name string '
Cllocation *loc = [[Cllocation alloc]initwithlatitude:39 longitude:116];
[Geocoder reversegeocodelocation:loc completionhandler:^ (Nsarray *placemarks, Nserror *error) {

Receive the ' landmark array ' returned with ' landmarks '
Clplacemark *plmark = [Placemarks firstobject];

Get the returned place name
NSLog (@ "Place name:%@", plmark.name);
}];

}

Map Development-Geocoding & geo-coding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.