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
  • 相关阅读:
    T-sql for xml path使用
    解决 SQL Server2012附加出错的问题
    安装应用程序 报“ 997 重叠 I/O 操作在进行中”错解决办法
    使用QQ互联登录应用
    monogdb windows环境下 安装及使用简单示例
    idle-实现清屏
    colorscheme-如何vim颜色风格
    android-从官网下拉源码(ubuntu)
    hq-源码编译
    文件目录进入终端
  • 原文地址:https://www.cnblogs.com/lihaibo-Leao/p/3688649.html
Copyright © 2011-2022 走看看