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
  • 相关阅读:
    layui分页获取数据,回显checkbox
    批量选中 及下载
    Module Federation原理剖析
    EMP-面向未来微前端方案正式开源了!
    Vue3 也能用上 Vue2 组件 From EMP
    对比多种微前端方案
    EMP微前端之教你如何搭建共享站
    EMP微前端实战之cocos2d线上项目
    微前端是什么,可以带来什么收益
    Elasticsearch操作实践手册|建议收藏篇
  • 原文地址:https://www.cnblogs.com/lihaibo-Leao/p/3688649.html
Copyright © 2011-2022 走看看