苹果6升10原生花4升级地图不知道怎么删除了,再从新怎么安装回原生花4升级地图

1、什么是LBS
LBS: 基于位置的服务 Location Based Service
实际应用:大众点评,陌陌,微信,美团等需要用到地图或定位的App
2、定位方式
1.GPS定位 2.基站定位 3.WIFI定位
MapKit:地图框架,显示地图
CoreLocation:定位框架,没有地图时也可以使用定位.
4、如何使用原生地图 和定位
1) 初始化MapView
_mapView = [[MKMapView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:_mapView];
2) 设置代理
_mapView.delegate =
3) 设置地图类型
_mapView.mapType = MKMapTypeS
4) 允许显示自己的位置
_mapView.showsUserLocation = YES;
5) 设置地图中心坐标点
CLLocationCoordinate2D centerCoordinate = CLLocationCoordinate2DMake(22..951832);
_mapView.centerCoordinate = centerC
6) 设置地图显示区域
a) 设置缩放
MKCoordinateSpan span = MKCoordinateSpanMake(0.1, 0.1);
b) 设置区域
MKCoordinateRegion region = MKCoordinateRegionMake(centerCoordinate, span);
c) 显示区域
_mapView.region =
CoreLocation:
7) 初始化定位管理器
_manager = [[CLLocationManager alloc] init];
_manager.delegate =
8) iOS8定位
在info.plist中添加 Privacy - Location Usage Description , NSLocationAlwaysUsageDescription
在代码中加入
if ( [UIDevice currentDevice].systemVersion.floatValue &= 8.0 ) {
[_manager requestAlwaysAuthorization];
9) 开启定位
[_manager startUpdatingLocation];
10) 定位成功代理
(void)locationManager:(CLLocationManager )manager didUpdateLocations:(NSArray )locations
NSLog(@&定位成功&);
//获取定位的坐标
CLLocation *location = [locations firstObject];
//获取坐标
CLLocationCoordinate2D coordinate = location.
NSLog(@&定位的坐标:%f,%f&, coordinate.longitude, coordinate.latitude);
//停止定位
//[_manager stopUpdatingLocation];
11) 定位失败代理
(void)locationManager:(CLLocationManager )manager didFailWithError:(NSError )error
NSLog(@&定位失败”);
12) 屏幕坐标转经纬度坐标
CLLocationCoordinate2D cl2d = [_mapView convertPoint:point toCoordinateFromView:_mapView];
13) 反地理编码
CLGeocoder *geocoder = [[CLGeocoder alloc] init];
[geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
//获取地标对象
CLPlacemark *mark = [placemarks firstObject];
大头针(标注):
14) 添加大头针
//创建大头针
MKPointAnnotation *pointAnn = [[MKPointAnnotation alloc] init];
//设置坐标
pointAnn.coordinate = CLLocationCoordinate2DMake(23.3.346877);
//设置标题
pointAnn.title = @&我的第一个大头针&;
//设置副标题
pointAnn.subtitle = @&副标题&;
//显示大头针,把大头针加入到地图上
[_mapView addAnnotation:pointAnn];
15) 大头针的复用及定制
pragma mark - mapView 代理方法
//大头针View
-(MKAnnotationView )mapView:(MKMapView )mapView viewForAnnotation:(id)annotation
//如果是自己当前位置的大头针,则不定制
if ( [annotation isKindOfClass:[MKUserLocation class]]) {
// 1、自带的大头针视图
MKPinAnnotationView *pinAnnView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@&ID&];
if ( !pinAnnView ) {
pinAnnView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@&ID&];
//设置大头针的颜色
pinAnnView.pinColor = MKPinAnnotationColorP
//设置掉落动画
pinAnnView.animatesDrop = YES;
//是否弹出气泡
pinAnnView.canShowCallout = YES;
//设置左视图
UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
leftView.backgroundColor = [UIColor blueColor];
pinAnnView.leftCalloutAccessoryView = leftV
//设置右视图
UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinAnnView.rightCalloutAccessoryView = rightB
//2、自定义大头针视图
* 区别于MKPinAnnotationView
* 1、可以设置大头针图片
* 2、不可以设置大头针颜色和掉落动画
MKAnnotationView *customView = [mapView dequeueReusableAnnotationViewWithIdentifier:@&ID2&];
if ( !customView ) {
customView = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@&ID2&];
//设置点击大头针可以显示气泡
customView.canShowCallout = YES;
//设置大头针图片
customView.image = [UIImage imageNamed:@&marker&];
//设置左视图
UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
leftView.backgroundColor = [UIColor blueColor];
customView.leftCalloutAccessoryView = leftV
//设置右视图
UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
customView.rightCalloutAccessoryView = rightB
16) 移除大头针
[_mapView removeAnnotations:_mapView.annotations];
17) 添加长按手势,实现在地图的长按点添加一个大头针
//4、长按地图显示大头针
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
[_mapView addGestureRecognizer:longPress];
pragma mark - 长按手势
-(void)longPress:(UILongPressGestureRecognizer *)gesture
//避免多次调用 只允许开始长按状态才添加大头针
if (gesture.state != UIGestureRecognizerStateBegan) {
//获取长按地图上的某个点
CGPoint point = [gesture locationInView:_mapView];
//把point转换成在地图上的坐标经纬度
CLLocationCoordinate2D coordinate = [_mapView convertPoint:point toCoordinateFromView:_mapView];
//添加长按的大头针
MKPointAnnotation *annotation = [[MKPointAnnotation alloc] init];
annotation.coordinate =
annotation.title = @&长按的大头针&;
annotation.subtitle = @&副标题&;
[_mapView addAnnotation:annotation];
1、高德地图申请Appkey流程:
a) 在浏览器中打开网址:
c) 2.在“KEY管理”页面点击上方的“获取key”按钮,依次输入应用名,选择绑定的服务为“iOS平台SDK”,输入Bundle Identifier(Bundle Identifier获取方式为Xcode-&General-&Identity)
2、高德地图配置工程流程:
a)下载高德地图iOS SDK
b)添加高德地图的库文件MAMapKit.framework
c)添加8个关联库QuartzCore, CoreLocation, SystemConfiguration, CoreTelephony, libz, OpenGLES, libstdc++6.09, Security(MAMapView)
d)添加AMap.bundle(MAMapKit.framework-&Resources)
e) TARGETS-Build Settings-Other Linker Flags 中添加内容: -ObjC;
f)在代码中添加用户Key: [MAMapServices sharedServices].apiK
3、单独使用搜索服务包:
a)添加搜索库文件AMapSearchKit.framework
b)添加关联库SystemConfiguration, CoreTelephony, libz, libstdc++6.09
c)在代码中添加AMapSearchAPI *search = [[AMapSearchAPI alloc] initWithSearchKey: @&您的key& Delegate:self];
4、如何使用高德地图 和 搜索
MAMapKit:
0) 配置高德地图API
define APIKEY @&e848d391f9c4b98dbf99d2&
[MAMapServices sharedServices].apiKey = APIKEY;
1) 初始化MAMapView
_maMapView = [[MAMapView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:_maMapView];
2) 设置代理
_maMapView.delegate =
3) 设置地图类型
_maMapView.mapType = MAMapTypeS
4) 允许显示自己的位置(如使用定位功能,则必须设置为YES)
_maMapView.showsUserLocation = YES;
5) 设置logo位置
_maMapView.logoCenter = CGPointMake(100, 100);
6) 显示罗盘
_maMapView.showsCompass = YES;
7) 显示交通
_maMapView.showTraffic = YES;
8) 是否支持旋转
_maMapView.rotateEnabled = YES;
9) 是否支持拖动
_maMapView.scrollEnabled = YES;
10) 是否支持缩放
_maMapView.zoomEnabled = NO;
11) 设置地图显示区域
a) 设置坐标
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(23.3.346877);
b) 设置缩放
MACoordinateSpan span = MACoordinateSpanMake(0.1, 0.1);
c) 设置区域
MACoordinateRegion region = MACoordinateRegionMake(coordinate, span);
d) 显示区域
_maMapView.region =
#pragma mark - 定位 回调方法
-(void)mapView:(MAMapView )mapView didUpdateUserLocation:(MAUserLocation )userLocation updatingLocation:(BOOL)updatingLocation
NSLog(@&定位成功&);
CLLocation *location = userLocation.
CLLocationCoordinate2D coordinate = location.
NSLog(@&我的坐标位置:%f, %f&, coordinate.longitude, coordinate.latitude);
// 定位后,可设置停止定位
// _maMapView.showsUserLocation = NO;
13) 添加标注(大头针)
//添加标注
MAPointAnnotation *annotation = [[MAPointAnnotation alloc] init];
annotation.coordinate = //设置标注的坐标
annotation.title = @&高德地图标题&; //设置标题
annotation.subtitle = @&副标题&; //设置副标题
[_maMapView addAnnotation:annotation]; //将标注添加在地图上
14) 标注的复用及定制
#pragma mark - 定制标注视图(和原生地图定制方式类似)
(MAAnnotationView )mapView:(MAMapView )mapView viewForAnnotation:(id)annotation
//不定制自己位置的标注视图
if ( [annotation isKindOfClass:[MAUserLocation class]]) {
// 1、自带的标注视图
MAPinAnnotationView *pinAnnView = (MAPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:@&ID&];
if ( !pinAnnView ) {
pinAnnView = [[MAPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@&ID&];
// 是否可弹出视图
pinAnnView.canShowCallout = YES;
// 设置掉落动画
pinAnnView.animatesDrop = YES;
// 设置标注颜色
pinAnnView.pinColor = MAPinAnnotationColorG
// 设置左视图
UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
leftView.backgroundColor = [UIColor blueColor];
pinAnnView.leftCalloutAccessoryView = leftV
//设置右视图
UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
pinAnnView.rightCalloutAccessoryView = rightB
return pinAnnV
//2、自定义标注视图
MAAnnotationView *customView = [mapView dequeueReusableAnnotationViewWithIdentifier:@&ID2&];
if ( !customView ) {
customView = [[MAAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@&ID2&];
//设置点击大头针可以显示气泡
customView.canShowCallout = YES;
//设置大头针图片
customView.image = [UIImage imageNamed:@&marker&];
//设置左视图
UIView *leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 50, 50)];
leftView.backgroundColor = [UIColor blueColor];
customView.leftCalloutAccessoryView = leftV
//设置右视图
UIButton *rightBtn = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
customView.rightCalloutAccessoryView = rightB
15) 添加长按手势
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longPress:)];
[_maMapView addGestureRecognizer:longPress];
#pragma mark -- 长按手势Action
-(void)longPress:(UILongPressGestureRecognizer *)longPress
if (longPress.state != UIGestureRecognizerStateBegan) {
//获取点位置
CGPoint point = [longPress locationInView:_maMapView];
//将点位置转换成经纬度坐标
CLLocationCoordinate2D coordinate = [_maMapView convertPoint:point toCoordinateFromView:_maMapView];
//在该点添加一个大头针(标注)
MAPointAnnotation *pointAnn = [[MAPointAnnotation alloc] init];
pointAnn.coordinate =
pointAnn.title = @&长按的大头针&;
pointAnn.subtitle = @&副标题&;
[_maMapView addAnnotation:pointAnn];
AMapSearchKit:
1) 搜索周边
0) 创建AMapSearchAPI对象,配置APPKEY,同时设置代理对象为self
searchAPI = [[AMapSearchAPI alloc] initWithSearchKey:APIKEY Delegate:self];
a) 创建搜索周边请求类
AMapPlaceSearchRequest *searchRequest = [[AMapPlaceSearchRequest alloc] init];
b) 设置搜索类型(按关键字搜索)
searchRequest.searchType = AMapSearchType_PlaceK
c) 设置关键字
searchRequest.keywords = keywordsTextField.
d) 设置搜索城市
searchRequest.city = @[@&广州&];
e) 开始搜索
[searchAPI AMapPlaceSearch:searchRequest];
2) 搜索周边回调方法
a) 搜索失败
(void)searchRequest:(id)request didFailWithError:(NSError *)error
NSLog(@&搜索失败&);
b) 搜索成功
-(void)onPlaceSearchDone:(AMapPlaceSearchRequest )request response:(AMapPlaceSearchResponse )response
//清空原来的标注(大头针)
[_maMapView removeAnnotations:_maMapView.annotations];
//判断是否为空
if (response) {
//取出搜索到的POI(POI:Point Of Interest)
for (AMapPOI *poi in response.pois) {
//poi的坐标
CLLocationCoordinate2D coordinate =
CLLocationCoordinate2DMake(poi.location.latitude, poi.location.longitude);
NSString *name = poi.
NSString *address = poi.
//用标注显示
MAPointAnnotation *pointAnn = [[MAPointAnnotation alloc] init];
pointAnn.coordinate =
pointAnn.title =
pointAnn.subtitle =
[_maMapView addAnnotation:pointAnn];
3) 添加折线
pragma mark - 画折线
-(void)drawPolyLine
//初始化点
NSArray *latitudePoints =[NSArray arrayWithObjects:
@&23.172223&,
@&23.163385&,
@&23.155411&,
@&23.148765&,
@&23.136935&, nil];
NSArray *longitudePoints = [NSArray arrayWithObjects:
@&113.348665&,
@&113.366056&,
@&113.366128&,
@&113.362391&,
@&113.356785&, nil];
// 创建数组
CLLocationCoordinate2D polyLineCoords[5];
for (int i=0; i&5; i++) {
polyLineCoords[i].latitude = [latitudePoints[i] floatValue];
polyLineCoords[i].longitude = [longitudePoints[i] floatValue];
// 创建折线对象
MAPolyline *polyLine = [MAPolyline polylineWithCoordinates:polyLineCoords count:5];
// 在地图上显示折线
[_maMapView addOverlay:polyLine];
pragma mark - 定制折线视图
-(MAOverlayView )mapView:(MAMapView )mapView viewForOverlay:(id)overlay
if ([overlay isKindOfClass:[MAPolyline class]]) {
MAPolylineView *polyLineView = [[MAPolylineView alloc] initWithPolyline:overlay];
polyLineView.lineWidth = 2; //折线宽度
polyLineView.strokeColor = [UIColor blueColor]; //折线颜色
polyLineView.lineJoinType = kMALineJoinR //折线连接类型
return polyLineV
阅读(...) 评论()搜索 新闻 资讯 游戏
您现在的位置:&&>>&&>>&&>>&&>>&正文
iOS&9地图重大更新上手体验:这回终于翻身了
编辑:baohongjie && 来源:iPhone中文网 && 发布时间: 16:46:44
  【巴士数码】iOS 9 中苹果终于对地图应用来了一次重大更新,而这次更新也让地图应用在用户的实际使用中真正发挥作用。  三年的时间苹果地图应用一直被这名用户丢在角落里,这回它终于可以名正言顺出现在主屏幕上了。
  iOS 9 中苹果终于对地图应用来了一次重大更新,而这次更新也让地图应用在用户的实际使用中真正发挥作用:
  三年前苹果原生地图应用发布之后就被我扔到一个名为垃圾的文件夹中,当时我住在旧金山,而如今我搬到纽约了,它还在垃圾文件夹里,很大的一个原因就是它没有公共交通导航。如果我出行使用苹果地图应用来导航的话,它就会告诉我去 Embark、谷歌地图或者其他第三方应用上查找地铁信息,但是我需要的是一个多合一解决方案。不管是走路、开车或者坐地铁谷歌地图都能够给我想要的答案。
  不过在 iOS 9 中苹果给地图增加了公共交通导航,瞬间它就变成强有力的竞争者,至少在目前看来,它的准确度和谷歌的一样,还有其他方面的完善,比如与 Mac 设备互通等。从我的体验来看,我觉得它前途无量,基本上可以从那个垃圾文件夹中出来了。
  公共交通
  我试验了几次设定我熟悉的几个地方为目的地,看看苹果地图给我建议的路线和车次是否是最快的,果然没有让我失望。它有一个能帮你节省时间的特性:在 flyover 模式下告诉你地铁入口在哪里。毕竟纽约中央车站还有几个出口,如果你找不到最近的那意味着你可能要绕好远的路,所以我觉得这点挺实用。
  苹果地图还会突出显示长岛铁路公路和北线通勤铁路等,谷歌地图不会。曼哈顿每天有超过 600,000 的通勤者,我想应该不会就我一个人觉得这些特性有用。
  Nearby
  苹果利用 Yelp 增加了一个新特性 Nearby,显示你附近的导航点、餐厅、咖啡厅或者其他商家店铺。
  可以在地图中查看附近商家对很多用户来说帮助很大,可惜的是 Nearby 用起来没有那么直观。你在搜索栏输入地址之后,大头针就会出现在目的地上,然后你需要再次点击搜索栏中的地址才可以看到 Nearby 界面。
  它有弹出菜单给你显示更多详细信息,你可以查看附近有什么美食店或者超市等。我是非常喜欢苹果这样整合了 Yelp,这样我也可以知道自己从没有去过的店在消费者口中评价怎么样。总的来说苹果添加 Nearby 很受欢迎,但是能够进一步完善就更好。
  Handoff
  在 OS X El Capitan Mac 和 iOS 9 设备之间进行 Handoff 与此前在 OS X Yosemite 和 iOS 8 之间的基本相同。只要双击 iPhone 或 iPad 的 home 键,进入任务管理器在屏幕底部找到地图应用的小弹窗即可获得存储在 Mac 上的地图信息。
  如果你是在 Mac 设备上,找到 Dock 左下角的弹出窗口,打开存储在 iOS 设备上的地图信息。无缝体验,支持地图应用的所有功能,酷毙了。
  欠缺之处
  苹果地图还没有街景服务,不过这个服务也不是一朝一夕就能推出来的。还有就是用户不能选择保存数据以备离线使用。但是,iOS 9 终于让苹果地图应用有可能在我的主屏幕上占有一席之地了。
扫描左侧二维码,可以订阅iPhone中文网官方微信。每天除了推送最新的苹果产品资讯,我们还将不定期举行有奖活动,广大网友可以积极参与,幸运随时会降临!当然,你也可微信搜索“iPhone中文网”或“apple4cn”,关注iPhone中文网官方微信,第一时间获取更多苹果资讯。
iOS越狱破解
苹果产品信息查询
热门新闻排行
皖公网安备05 皖网文许字[3号
TGBUS Corporation, All Rights Reserved

我要回帖

更多关于 知道不知道 的文章

 

随机推荐