2013-06-26 137 views
-1

一個xib有兩個地圖視圖可能嗎?如果有可能如何在每個地圖視圖上顯示不同的數據?我搜索了很多,但找不到任何鏈接。如何在一個xib中處理兩個地圖視圖?

if (myMapviewLala.tag==1) { 
    MKCoordinateRegion region; 
    MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc] init]; 
    coordinate.latitude = place.longitude; 
    coordinate.longitude = place.longitude; 
    region = MKCoordinateRegionMakeWithDistance(coordinate2,1000,1000); 
    MKCoordinateRegion adjustRegion = [myMapviewLala regionThatFits:region]; 
    [myMapviewLala setRegion:adjustRegion animated:YES]; 
    [annotationPoint setCoordinate:coordinate]; 
    [myMapviewLala addAnnotation:annotationPoint]; 
    } 
if (myMapviewBNI.tag==0) { 
    MKCoordinateRegion region; 
    MKPointAnnotation *annotationPoint = [[MKPointAnnotation alloc] init]; 
    coordinate.latitude = 51.638373; 
    coordinate.longitude = -0.46944; 
    region = MKCoordinateRegionMakeWithDistance(coordinate,15000,15000); 
    MKCoordinateRegion adjustRegion = [myMapviewBNI regionThatFits:region]; 
    [myMapviewBNI setRegion:adjustRegion animated:YES]; 
    [annotationPoint setCoordinate:coordinate]; 
    [myMapviewBNI addAnnotation:annotationPoint]; 
    } 
+0

請在問題中添加您的代碼,而不是在評論中。 – AtWork

+0

@Abhishek加入 –

+0

檢查myMapviewLala.tag == 1 ..中座標2的經度和緯度。 – AtWork

回答

1

是的,你可以在單個視圖上顯示兩張地圖。您可以使用不同的插座和標籤在viewcontroller上訪問。

Muhammad Usman

1

是的,你可以在同一個xib中處理兩張地圖。

只給兩個mapview不同的IBOutlets

並在不同的地圖上顯示相應的位置。

+0

MKCoordinateRegion地區; MK01Annotation * annotationPoint = [[MKPointAnnotation alloc] init]; coordinate.latitude = 51.638373; coordinate.longitude = -0.46944; region = MKCoordinateRegionMakeWithDistance(coordinate,15000,15000); MKCoordinateRegion adjustRegion = [myMapviewBNI regionThatFits:region]; [myMapviewBNI setRegion:adjustRegion animated:YES]; [annotationPoint setCoordinate:coordinate]; [myMapviewBNI addAnnotation:annotationPoint]; 這是一個地圖視圖 –

+0

在視圖中加載方法 –

+0

coordinate.latitude = place.longitude; coordinate.longitude = place.longitude; region = MKCoordinateRegionMakeWithDistance(coordinate2,1999000,1999000); adjustRegion = [myMapviewLala regionThatFits:region]; [myMapviewLala setRegion:adjustRegion animated:YES]; [annotationPoint setCoordinate:coordinate]; [myMapviewLala addAnnotation:annotationPoint]; –

相關問題