您的位置:首页 > 其它

根据指定经纬度创建地图并且定位

2012-12-12 22:22 330 查看
//地图边框的实现

UIView *view =[[UIView alloc]initWithFrame:CGRectMake(10, 120, 300, 240)];
view.layer.cornerRadius =12;
view.backgroundColor=[UIColor whiteColor];
view.layer.masksToBounds=YES;
[self.view addSubview:view];
[view release];

//添加地图
map = [[[MKMapView alloc] initWithFrame:view.bounds] autorelease];
map.showsUserLocation =YES;
map.mapType=MKMapTypeStandard;//地图样式
[view addSubview:map];
//将传过来的经纬度转换成doubel
double fourth = [_fourth doubleValue];
double fourth2 = [_fourth2 doubleValue];
//设置定为器 和指定经纬度
CLLocationCoordinate2D coords = CLLocationCoordinate2DMake(fourth,fourth2);
//缩放级别
float zoomLevel =0.02;
MKCoordinateRegion region=MKCoordinateRegionMake(coords, MKCoordinateSpanMake(zoomLevel,zoomLevel));
[map setRegion:[map regionThatFits:region]animated:YES];本文出自 “yangjun” 博客,谢绝转载!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: