日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

iOS 地图制作讲义

發布時間:2024/3/13 编程问答 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 iOS 地图制作讲义 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

.系統原生地圖?

1.什么是LBS

LBS:基于位置的服務 ? Location Based Service

實際應用:大眾點評,陌陌,微信,百度地圖

2.定位原理

1.GPS定位? ? ? ? 2.基站定位? ? 3.WIFI定位

3.定位使用框架

MapKit:顯示地圖

CoreLocation:定位框架,沒有地圖時也可以定位.

4.如何使用系統地圖

1).初始化MapView

_mapView = [[MKMapViewalloc]initWithFrame:self.view.bounds];

? ? [self.viewaddSubview:_mapView];

2).設置地圖中心坐標點

CLLocationCoordinate2D cl2d =CLLocationCoordinate2DMake(22.540396,113.951832);

? ? _mapView.centerCoordinate = cl2d;


3)設置地圖顯示區域

MKCoordinateSpan span =MKCoordinateSpanMake(0.01,0.01);

? ? MKCoordinateRegion region =MKCoordinateRegionMake(cl2d, span);

? ? _mapView.region = region;

4).設置地地圖類型

_mapView.mapType =MKMapTypeStandard;


5).允許顯示自己的位置

_mapView.showsUserLocation =YES;


6).初始化定位管理器

_manager = [[CLLocationManageralloc]init];

_manager.delegate =self;


7).ios8如何定位

1.在info.plist中添加? Privacy - Location Usage Description? ,? NSLocationAlwaysUsageDescription

2.在代碼中? [_manager requestAlwaysAuthorization];

8).定位成功代理

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations


9).定位失敗代理

- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error


10).自定義大頭針

? ? - (CLLocationCoordinate2D)coordinate;

- (NSString *)title;

- (NSString *)subtitle;

- (id)initWithCoordinate:(CLLocationCoordinate2D )cl2d andTitle:(NSString *)title andSubTitle:(NSString *)subTitle;


- (id)initWithCoordinate:(CLLocationCoordinate2D)cl2d andTitle:(NSString *)title andSubTitle:(NSString *)subTitle

{

? ? if (self = [superinit]) {

? ? ? ? _cl2d = cl2d;

? ? ? ? _title = title;

? ? ? ? _subTitle = subTitle;

? ? }

?? returnself;

}

11).大頭針的復用及定制

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation

{

? ? staticNSString *reused = @"reused";

? ? MKPinAnnotationView *pin = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:reused];

? ? if (pin ==nil) {

? ? ? ? pin = [[MKPinAnnotationViewalloc]initWithAnnotation:annotationreuseIdentifier:reused];

? ? ? ? pin.canShowCallout =YES;

? ? ? ? pin.pinColor =MKPinAnnotationColorGreen;

? ? ? ? pin.animatesDrop =YES;

?? ? ? ?

? ? ? ? UIView *v = [[UIViewalloc]initWithFrame:CGRectMake(0,0, 35, 35)];

? ? ? ? v.backgroundColor = [UIColorredColor];

? ? ? ? pin.leftCalloutAccessoryView = v;

?? ? ? ?

? ? ? ? UIButton *b = [UIButtonbuttonWithType:UIButtonTypeSystem];

? ? ? ? b.frame =CGRectMake(0,0, 35, 35);

? ? ? ? [b setTitle:@"按鈕"forState:UIControlStateNormal];

? ? ? ? pin.rightCalloutAccessoryView = b;

? ? }

? ? return pin;

}

12).屏幕坐標轉經緯度坐標

CLLocationCoordinate2D cl2d = [_mapViewconvertPoint:point toCoordinateFromView:_mapView];


13).反地理編碼

CLLocation *location = [[CLLocationalloc]initWithLatitude:cl2d.latitudelongitude:cl2d.longitude];

? ? ? ? CLGeocoder *geocoder = [[CLGeocoderalloc]init];

? ? ? ? [geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks,NSError *error) {

? ? ? ? ? ? CLPlacemark *mark = [placemarks lastObject];

? ? ? ? ? ? myPin *pin = [[myPinalloc]initWithCoordinate:cl2dandTitle:mark.countryandSubTitle:mark.name];

? ? ? ? ? ? [_mapViewaddAnnotation:pin];

? ? ? ? }];

14).移除大頭針

[_mapViewremoveAnnotations:_mapView.annotations];

二.高德地圖的使用


?http://lbs.amap.com

? 根據文檔實現


1:地圖的顯示

?? ? 2:POI 搜索


總結

以上是生活随笔為你收集整理的iOS 地图制作讲义的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。