根據指定經緯度創建地圖並且定位

  //地圖邊框的實現

    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];

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章