xml地图|网站地图|网站标签 [设为首页] [加入收藏]

CoreLocation MKMapView 地图,corelocation

来源:http://www.ccidsi.com 作者:呼叫中心培训课程 人气:88 发布时间:2019-11-28
摘要:CoreLocation MKMapView 地图,corelocation 系统自带地图  框架: CoreLocation Map基特 CLLocationManager -- 定位管理者  CL吉优coder -- 地理编码器MKMapView -- 地图view 同意顾客定位     [_locationManager req

CoreLocation MKMapView 地图,corelocation

系统自带地图  框架: CoreLocation Map基特

CLLocationManager --> 定位管理者  CL吉优coder --> 地理编码器 MKMapView --> 地图view

同意顾客定位
    [_locationManager requestAlwaysAuthorization];//总是允许
    [_locationManager requestWhenInUseAuthorization];//客户用时允许

客商移动100米的时候才会重新调用地方代理方法
    _locationManager.distanceFilter = 100.0;

初阶定点

  [_locationManager startUpdatingLocation];

CLLocationManager 代理方法:(获取到消息室管理)

  - (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
  }

开创比例周全  展现在哪个点上
   MKCoordinateRegion region = MKCoordinateRegionMake(userLocation.coordinate, MKCoordinateSpanMake(0.1, 0.1));
   比例全面赋值
   _mapView.region = region;

CLGeocoder:

编码:提供某些字符串 来恒定地方:- (void)geocodeAddressString:(NSString *)addressString completionHandler:(CLGeocodeCompletionHandler)completionHandler;

反编码:据悉职分呈现该地方的名字等等[_geocoder reverseGeocodeLocation:placemark.location  completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {}];

加上海高校头针:

  AGAnnotion *agAnnotion = [[AGAnnotion alloc]init];
    agAnnotion.coordinate = CLLocationCoordinate2DMake(36.0, 120.0);
    agAnnotion.title = @"coco";
    [_mapView addAnnotation:agAnnotion];
自定义气泡

  继承 NSObject , 遵守 MKAnnotation 协议

  成立三个个性

  @property (nonatomic, assign) CLLocationCoordinate2D coordinate;
  @property (nonatomic, copy) NSString *title;
  @property (nonatomic, copy) NSString *subtitle;

 高德:

 1. 验证key
    [MAMapServices sharedServices].apiKey = @“申请的key”;
 2. 初始化
    mapView = [[MAMapView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.frame), CGRectGetHeight(self.view.bounds))];
    mapView.delegate = self;
    mapView.language = MAMapLanguageEn; // 设置地图显示语言
    mapView.mapType = MAMapTypeStandard; // 地图类型
    /*
     MAMapTypeSatellite:卫星地形图
     MAMapTypeStandard:规范地图
     */

    mapView.showTraffic = YES; // 展现实时交通路况
    [self.view addSubview:mapView];
澳门皇家赌场娱乐,    mapView.showsUserLocation = YES;

mapView的恒久情势: userTrackingMode

  MAUserTrackingModeNone:不跟随顾客地方,仅在地图上显得。

  MAUserTrackingModeFollow:跟随顾客地方移动,并将定位点设置成地图大旨点

  MAUserTrackingModeFollowWithHeading:跟随客商的任务和角度移动

系统的地图和 高德地图 的分别

 

MKMapView 地图,corelocation 系统自带地图 框架: CoreLocation MapKit CLLocationManager -- 定位管理者 CL吉优coder --地理编码器 MKMapView -- 地图vie...

iOS 利用CoreLocation和MapKit开荒寻找相近的商店作用,corelocationmapkit

代码如下:

//
//  SearchNearbyShopViewController.m
//  SearchNearbyShop
//
//  Created by Linzhixiao on 16/2/14.
//  Copyright © 2016年 B5m. All rights reserved.
//

#import "SearchNearbyShopViewController.h"
#import <CoreLocation/CoreLocation.h>
#import <MapKit/MapKit.h>
#define KSearchAreaMeters 100

@interface SearchNearbyShopViewController () <CLLocationManagerDelegate,MKMapViewDelegate>
{
    MKCoordinateRegion currentRegion;
}
@property (nonatomic, strong) CLLocationManager *locationManager;
@property (nonatomic, strong) MKMapView *mapView;
@property (nonatomic, strong) CLGeocoder *geocoder;
@property (nonatomic,strong) NSMutableArray *nearbyInfoArray;

@end

@implementation SearchNearbyShopViewController

  • (void)viewDidLoad {
        [super viewDidLoad];
        self.title = @"搜索左近商场";
        self.view.backgroundColor = [UIColor whiteColor];
        [self configNavigation];
        [self locationManager];
        [self requestLocationAutoorize];
       
       
        [self GetCurrentLocation];
        [self geocoder];
        [self.view addSubview:self.mapView];
    }

  • (void)didReceiveMemoryWarning {
        [super didReceiveMemoryWarning];
        // Dispose of any resources that can be recreated.
    }

#pragma mark - Custom Accessors

  • (CLLocationManager *)locationManager {
        if (!_locationManager) {
            _locationManager = [[CLLocationManager alloc] init];
            _locationManager.delegate = self;
        }
        return _locationManager;
    }
  • (MKMapView *)mapView {
        if (!_mapView) {
            _mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
            _mapView.mapType = MKMapTypeStandard;
            _mapView.userTrackingMode = MKUserTrackingModeFollow;
            _mapView.delegate = self;
        }
        return _mapView;
    }
  • (CLGeocoder *)geocoder {
        if (!_geocoder) {
            _geocoder = [[CLGeocoder alloc] init];    }    return _geocoder;}#pragma mark - Private- (void)configNavigation {    UIButton *topSearchButton = [UIButton buttonWithType:UIButtonTypeSystem];    topSearchButton.frame = CGRectMake(0, 0, 50, 50);    [topSearchButton setTitle:@"搜索" forState:UIControlStateNormal];    [topSearchButton addTarget:self action:@selector(searchNearbyShopAction:) forControlEvents:UIControlEventTouchUpInside];    UIBarButtonItem *rightButtonItem = [[UIBarButtonItem alloc] initWithCustomView:topSearchButton];    self.navigationItem.rightBarButtonItem = rightButtonItem;}- (void)requestLocationAutoorize {    CGFloat systemVersion = [[UIDevice currentDevice].systemVersion floatValue];    if (systemVersion >= 8) {        [_locationManager requestAlwaysAuthorization];    }}- (void)GetCurrentLocation {    if ([CLLocationManager locationServicesEnabled]) {        NSLog(@"定位服务已张开");        [_locationManager startUpdatingLocation];        self.locationManager.distanceFilter = kCLDistanceFilterNone;    }else {        NSLog(@"定位功效无法张开");    }      }- (void)searchNearbyShopWithRegion: (MKCoordinateRegion )region {    // 获得左近的音信    self.nearbyInfoArray = [NSMutableArray array];    MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc] init];    request.region = region;    request.naturalLanguageQuery = @"school";    MKLocalSearch *localSearch = [[MKLocalSearch alloc] initWithRequest:request];    [localSearch startWithCompletionHandler:^(MKLocalSearchResponse * _Nullable response, NSError * _Nullable error) {        if (!error) {            [self.nearbyInfoArray addObjectsFromArray:response.mapItems];            for (MKMapItem *item in _nearbyInfoArray) {                NSLog(@"name = %@, ",item.name);            }        }else {            NSLog(@"搜索错误, %@",error);        }    }];}#pragma mark - IBActions- (void)searchNearbyShopAction: (UIButton *)searchButton {    NSLog(@"重新寻觅左近市集");    if (currentRegion.span.latitudeDelta == 0.0) {        return;    }else {        [self searchNearbyShopWithRegion:currentRegion];    }}#pragma mark - CLLocationManagerDelegate//- (void)locationManager:(CLLocationManager *)manager//     didUpdateLocations:(NSArray<CLLocation *> *)locations {//    CLLocation *location = [locations firstObject];//    NSLog(@"纬度=%f, 精度=%f",location.coordinate.latitude,location.coordinate.longitude);//}#pragma mark - MKMapViewDelegate- (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation {    [self.geocoder reverseGeocodeLocation:userLocation.location completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {        CLPlacemark *placeMark = [placemarks firstObject];        NSLog(@"获取地理地方成功 name = %@, locality = %@",placeMark.name,place马克.locality);        userLocation.title = place马克.name;        userLocation.subtitle = place马克.locality;    }];       // 当前地点呈现到地图    CLLocationCoordinate2D center = userLocation.location.coordinate;    MKCoordinateSpan span = MKCoordinateSpanMake(0.009310, 0.007812);    MKCoordinateRegion region = MKCoordinateRegionMake(center, span);    MKCoordinateRegion searchRegion = MKCoordinateRegionMakeWithDistance(userLocation.coordinate, KSearchAreaMeters,KSearchAreaMeters);    currentRegion  = searchRegion;       [self.mapView setRegion:region animated:YES];      } @end

利用CoreLocation和MapKit开垦寻找相近的商场功用,corelocationmapkit 代码如下: // // SearchNearbyShopViewController.m // SearchNearbyShop // // Created by Linz...

本文由68399皇家赌场发布于呼叫中心培训课程,转载请注明出处:CoreLocation MKMapView 地图,corelocation

关键词: 68399皇家赌场

最火资讯