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

  //地图边框的实现

    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” 博客,谢绝转载!

你可能感兴趣的:(经纬度,定位,地图)