iphone 程序内调用谷歌地图
来源:互联网 发布:软件开发流程规范 编辑:程序博客网 时间:2024/06/15 21:34
使用CLLocationManager类,MKMapView。并且实现<MKMapViewDelegate,CLLocationManagerDelegate>
//初始化CLLocationManager,CLLocationManager获得当前地理坐标
locmanager=[[CLLocationManageralloc]init];
[locmanager setDelegate:self];
//设置精确度
[locmanagersetDesiredAccuracy:kCLLocationAccuracyBest];
[locmanagerstartUpdatingLocation];
执行完以后,会自动调用代理方法:
在代理方法:
- (void)locationManager:(CLLocationManager *)managerdidUpdateToLocation:(CLLocation*)newLocation fromLocation:(CLLocation *)oldLocation{
//初始化矩形大小
CGRect rect=CGRectMake(0,0,320,460);
//设置地图大小为矩形大小
map=[[MKMapView alloc] initWithFrame:rect];
CLLocationCoordinate2Dloc=[newLocation coordinate];
lat=loc.latitude;
lon=loc.longitude;
//coordinate坐标
CLLocationCoordinate2DtheCoordinate;
CLLocationCoordinate2DtheCenter;
//theCoordinate.latitude=lat;
//theCoordinate.longitude=lon;
theCoordinate=loc;
[map setDelegate:self];
//设置地图显示的类型,有卫星地图,道路,等
[map setMapType:MKMapTypeStandard];
//[mapsetMapType:MKMapTypeSatellite];
//区域坐标Region(区域,地域)
MKCoordinateRegiontheRegin;
//theCenter.latitude=lat;
//theCenter.longitude=lon;
theCenter=loc;
theRegin.center=theCenter;
//坐标间距(span:间隔,间距)
MKCoordinateSpantheSpan;
theSpan.latitudeDelta=0.1;
theSpan.longitudeDelta=0.1;
//设置地图显示的区域,
theRegin.span=theSpan;
//[mapsetRegion:theRegin];
[mapregionThatFits:theRegin];
map.showsUserLocation=YES;
[self.viewaddSubview:map];
}
- (MKAnnotationView *)mapView:(MKMapView *)mapViewviewForAnnotation:(id<MKAnnotation>)annotation{
NSLog(@"-------viewForAnnotation-------");
//此类可以显示针一样的图标
MKPinAnnotationView*newAnnotation=[[MKPinAnnotationViewalloc]initWithAnnotation:annotationreuseIdentifier:@"annotation1"];
//newAnnotation.animatesDrop=YES;
//newAnnotation.animatesDrop=NO;
newAnnotation.pinColor=MKPinAnnotationColorPurple;
//显示标志提示
newAnnotation.canShowCallout=YES;
return newAnnotation;
}
原文地址:http://www.cocoachina.com/bbs/read.php?tid=73570&page=4
- iphone 程序内调用谷歌地图
- iphone程序内调用谷歌地图
- iphone程序内调用谷歌地图
- iphone程序内调用谷歌地图
- 调用谷歌地图
- iphone 程序 调用系统程序
- 调用谷歌地图js显示地图
- iphone或Android服务器端调用百度地图
- iphone调用系统电话、浏览器、地图…
- 调用iPhone地图显示指定的点
- iOS 应用内跳转到百度地图、苹果地图、谷歌地图、高德地图等
- js调用谷歌地图
- C#调用谷歌地图
- iphone程序启动互相调用
- iphone程序启动互相调用
- iphone程序启动互相调用
- iphone程序间互相调用
- iphone程序启动互相调用
- HTML
- Java中Input和Output操作
- 安装Ubuntu 10.04系统
- 常用的div ul li css样式 详细的UL-LI样式三种形式
- ZOJ 1115-Digital Roots
- iphone 程序内调用谷歌地图
- 统计数字小应用
- 程序员应该专注于提高技术
- Android之Intent
- 随机出现的图片小程序
- iphone UIPageControl实现自定义按钮
- combobox 添加value值和Text值
- 最笨的统计字符串中数字的个数(控制台程序)
- linux_ERROR