zoukankan      html  css  js  c++  java
  • iOS百度地图

     1 //
     2 //  ViewController.m
     3 //  MapDemo
     4 //
     5 //  Created by Chocolate. on 14-4-25.
     6 //  Copyright (c) 2014年 redasen. All rights reserved.
     7 //
     8 
     9 #import "ViewController.h"
    10 
    11 @interface ViewController ()<BMKMapViewDelegate,BMKSearchDelegate>
    12 @property (strong, nonatomic) BMKMapView *mapView;
    13 @property (strong, nonatomic) BMKSearch *search;
    14 @property (strong, nonatomic) BMKUserLocation *location;
    15 @end
    16 
    17 @implementation ViewController
    18 
    19 - (void)viewDidLoad
    20 {
    21     [super viewDidLoad];
    22     // Do any additional setup after loading the view, typically from a nib.
    23     self.mapView = [[BMKMapView alloc]initWithFrame:self.view.bounds];
    24     self.view = _mapView;
    25     _mapView.showsUserLocation = YES;
    26     self.search = [[BMKSearch alloc]init];
    27 }
    28 
    29 - (void)viewWillAppear:(BOOL)animated
    30 {
    31     [_mapView viewWillAppear];
    32     _mapView.delegate = self;
    33     _search.delegate = self;
    34 }
    35 
    36 - (void)viewWillDisappear:(BOOL)animated
    37 {
    38     [_mapView viewWillDisappear];
    39     _mapView.delegate = nil;
    40     _search.delegate = nil;
    41 }
    42 
    43 - (void)mapView:(BMKMapView *)mapView didUpdateUserLocation:(BMKUserLocation *)userLocation
    44 {
    45     if (userLocation != nil) {
    46         NSLog(@"%f %f", userLocation.location.coordinate.latitude, userLocation.location.coordinate.longitude);
    47         _location = userLocation;
    48         mapView.showsUserLocation = NO;
    49     }
    50 }
    51 
    52 - (void)mapViewDidStopLocatingUser:(BMKMapView *)mapView
    53 {
    54     [_search reverseGeocode:_location.coordinate];
    55 }
    56 
    57 - (void)onGetAddrResult:(BMKAddrInfo *)result errorCode:(int)error
    58 {
    59     NSString *str = [NSString stringWithFormat:@"我的位置:%@",result.strAddr];
    60     NSLog(@"%@",str);
    61 }
    62 
    63 - (void)didReceiveMemoryWarning
    64 {
    65     [super didReceiveMemoryWarning];
    66     // Dispose of any resources that can be recreated.
    67 }
    68 
    69 @end
  • 相关阅读:
    JAVA_Collection容器
    ArrayList实现分组功能
    scrapy 安装出错 [err2] no such file or directory: 'README.rst'【已解决】
    python spyder 今天突然打不开了【已解决】
    SVN使用教程总结
    MVC框架浅析(基于PHP)
    Web性能优化方案
    野生程序员的故事
    js控制页面跳转,清缓存,强制刷新页面
    js中json处理总结之JSON.parse
  • 原文地址:https://www.cnblogs.com/lihaibo-Leao/p/3688649.html
Copyright © 2011-2022 走看看