zoukankan      html  css  js  c++  java
  • iOS定位服务与地图开发(6)---使用程序外地图之调用谷歌Web地图

    也可以借助于谷歌的web地图API进行开发地图应用程序,但这里所涉及的技术都是Web技术了,而非本地技术。

    谷歌提供的地图查询URL形式如下:http://maps.google.com/maps?q=参数

    示例实现:

    - (IBAction)geocodeQuery:(id)sender {
        
        // 从界面文本框获取查询地址字符串
        if (_txtQueryKey.text == nil || [_txtQueryKey.text length] == 0) {
            return ;
        }
        
        CLGeocoder *geocoder = [[CLGeocoder alloc] init];
        
        [geocoder geocodeAddressString:_txtQueryKey.text completionHandler:^(NSArray *placemarks, NSError *error) {
            
            NSLog(@"查询记录数:%i",[placemarks count]);
            
            if([placemarks count] > 0){
                
                CLPlacemark * placemark = placemarks[0];
                
                CLLocationCoordinate2D coordinate = placemark.location.coordinate;
                
                NSString *urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?q=%f,%f",coordinate.latitude,coordinate.longitude];
                
                NSURL *url = [NSURL URLWithString:urlString];
                
                [[UIApplication sharedApplication] openURL:url];
                
                // 关闭键盘
                [_txtQueryKey resignFirstResponder];
    
            }
            
        }];
    }
  • 相关阅读:
    input标签上传文件处理。
    Radio单选框元素操作。
    CompletableFuture方法
    传播学 2
    传播学 1
    0
    紅軍不怕遠征難
    ~~~~~~~~~
    什么是企业战略
    论述提供公共咨询服务的两种主要方式。
  • 原文地址:https://www.cnblogs.com/yaoxc/p/3723171.html
Copyright © 2011-2022 走看看