ios开发 地图上显示大头针和标注简单教程
2015-03-09 19:45
381 查看
1.首先导入框架 MapKit.framework和
CoreLocation.framework
2.再导入头文件
#impor
#impor
3.//创建MKMapView的实例
MKMapView
*mapView = [[MKMapView alloc]initWithFrame:CGRectMake(0.0,0.0,
320.0,[UIScreen
mainScreen].bounds.size.height-20-44)];
[self.view
addSubview:mapView];
self.mapView = mapView;
[mapView
release];
//
为了干预annotationview的创建过程,设置mapview的delegate
self.mapView.delegate =
self;
4.//显示某个region
//
中心点坐标()self.latitude经度,self.longitude纬度,这是自己定义的float类型属性
self.latitude=31.43715199999999;
self.longitude=121.13612;
CLLocationCoordinate2D
coordinate =CLLocationCoordinate2DMake(self.latitude,
self.longitude);
//
显示尺寸span
MKCoordinateSpan
span = MKCoordinateSpanMake(0.04,0.04);
self.mapView.region =
MKCoordinateRegionMake(coordinate,span);
以上步骤已经可以显示一个地图(高德),下面是显示大头针形式的标注
创建一个timer让它1.5秒后显示出来
[NSTimerscheduledTimerWithTimeInterval:1.5target:self
selector:@selector(zoomToAnnotations) userInfo:nilrepeats:NO];
实现方法
-(void)zoomToAnnotations
{
MKPointAnnotation
*annotation =[[MKPointAnnotation
alloc]init];
annotation.coordinate=CLLocationCoordinate2DMake(self.latitude,
self.longitude);
annotation.title =
@"东仓花园";
annotation.subtitle =@"中国机械加工网";
// 指定新的显示区域
[self.mapView setRegion:MKCoordinateRegionMake(annotation.coordinate,
MKCoordinateSpanMake(0.02,0.02)) animated:YES];
//选中标注
[self.mapView selectAnnotation:annotation animated:YES];
[annotation release];
}
CoreLocation.framework
2.再导入头文件
#impor
#impor
3.//创建MKMapView的实例
MKMapView
*mapView = [[MKMapView alloc]initWithFrame:CGRectMake(0.0,0.0,
320.0,[UIScreen
mainScreen].bounds.size.height-20-44)];
[self.view
addSubview:mapView];
self.mapView = mapView;
[mapView
release];
//
为了干预annotationview的创建过程,设置mapview的delegate
self.mapView.delegate =
self;
4.//显示某个region
//
中心点坐标()self.latitude经度,self.longitude纬度,这是自己定义的float类型属性
self.latitude=31.43715199999999;
self.longitude=121.13612;
CLLocationCoordinate2D
coordinate =CLLocationCoordinate2DMake(self.latitude,
self.longitude);
//
显示尺寸span
MKCoordinateSpan
span = MKCoordinateSpanMake(0.04,0.04);
self.mapView.region =
MKCoordinateRegionMake(coordinate,span);
以上步骤已经可以显示一个地图(高德),下面是显示大头针形式的标注
创建一个timer让它1.5秒后显示出来
[NSTimerscheduledTimerWithTimeInterval:1.5target:self
selector:@selector(zoomToAnnotations) userInfo:nilrepeats:NO];
实现方法
-(void)zoomToAnnotations
{
MKPointAnnotation
*annotation =[[MKPointAnnotation
alloc]init];
annotation.coordinate=CLLocationCoordinate2DMake(self.latitude,
self.longitude);
annotation.title =
@"东仓花园";
annotation.subtitle =@"中国机械加工网";
// 指定新的显示区域
[self.mapView setRegion:MKCoordinateRegionMake(annotation.coordinate,
MKCoordinateSpanMake(0.02,0.02)) animated:YES];
//选中标注
[self.mapView selectAnnotation:annotation animated:YES];
[annotation release];
}
相关文章推荐
- iOS 输入地点 显示当前位置地图并用大头针标注
- iOS原生地图开发指南续——大头针与自定义标注
- iOS原生地图开发指南续——大头针与自定义标注
- iOS版MapABC的简单显示地图的Demo
- 【iOS开发】 CoreText 使用教程:以创建一个简单的杂志应用为例
- ios 地图大头针自定义显示图片 MKAnnotationView
- IOS中显示自带地图(高德地图)的大头针
- IOS开发之---地图显示
- Arcgis for Androd API开发系列教程(一)——地图显示与GPS定位
- iOS使用Google Map Api创建地图-显示标注-轨迹回放
- iOS移除地图标注大头针
- IOS游戏源码下载之简易版雷电(2.2.3版本)源码完整下载和简单开发教程
- 招聘信息显示苹果开发iOS地图应用
- ios地图开发之-Bing Maps地图基础教程
- iphone开发 地图 长按显示大头针
- IOS开发-地图注解(地图上的大头针)
- iOS 6 开发---开发定位服务的App-在地图上标注位置
- Flex开发ArcGIS问题集锦四:怎样显示地图(简单小例子)
- iOS开发】 CoreText 使用教程:以创建一个简单的杂志应用为例
- iOS定位服务与地图开发(4)---显示地图