小编Din*_*esh的帖子

使用谷歌地图api iOS反向地理编码

我正在使用以下代码进行反向地理编码

- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
    {   
    curLoc=newLocation;
    if (curLoc != nil) {
        latitude=curLoc.coordinate.latitude;
        longitude=curLoc.coordinate.longitude;
        //[self loadMap:latitude second:longitude];
        [self MarkerPoint:latitude+0.04 second:longitude+0.1 third:latitude-0.04 forth:longitude-0.1];

        NSError *error;
        NSString *lookupString = [NSURL URLWithString:[NSString stringWithFormat:@"http://maps.googleapis.com/maps/api/geocode/json?latlng=%f,%f&sensor=false",latitude,longitude]];
        NSLog(@"URL: %@",lookupString);
        lookupString = [lookupString stringByReplacingOccurrencesOfString:@" " withString:@"+"];

        NSData *jsonResponse = [NSData dataWithContentsOfURL:[NSURL URLWithString:lookupString]];

        NSDictionary *jsonDict = [NSJSONSerialization JSONObjectWithData:jsonResponse options:kNilOptions error:&error];

        self.locationArray = [[jsonDict valueForKey:@"results"] valueForKey:@"formatted_address"];
        int total = self.locationArray.count;
        NSLog(@"locationArray count: %d", self.locationArray.count);

        for (int i = 0; i < total; i++)
        {
            NSString *statusString = …
Run Code Online (Sandbox Code Playgroud)

reverse geocoding objective-c ios

7
推荐指数
2
解决办法
5372
查看次数

标签 统计

geocoding ×1

ios ×1

objective-c ×1

reverse ×1