2012-05-02 3 views
0

Googleプレイスのデータをフィルタリングして、各場所をマップビューに表示しています。現在、私はすべてのポイントを地図上に表示しています。私はどのように表示するかを理解する必要がありますannotationPoint.title = place.name;これらの場所ごとにMapKitで一連の場所の注釈のタイトルを表示するには

どのように私は場所の場所の配列全体のためにこれを行うに行くだろうか?

ご協力いただきありがとうございます!

//UPDATE - to handle filtering 
    - (void)googlePlacesConnection:(GooglePlacesConnection *)conn didFinishLoadingWithGooglePlacesObjects:(NSMutableArray *)objects 
    { 

     if ([objects count] == 0) { 
      UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"No matches found near this location" 
                  message:@"Try another place name or address" 
                  delegate:nil 
                cancelButtonTitle:@"OK" 
                otherButtonTitles: nil]; 
      [alert show]; 
     } else { 
      locations = objects; 
      //UPDATED locationFilterResults for filtering later on 
      locationsFilterResults = objects; 
      [tableView reloadData]; 

      [mapView removeAnnotations:mapView.annotations]; 
      [mapView addAnnotations:objects]; 

     } 
    } 

答えて

0

このコードを試してみてください。

if ([myArr containsObject:@"Germany"]) 
{ 
    gerArr = [[NSMutableArray alloc]init]; 
    [gerArr addObject:@"Berlin"]; 
    [gerArr addObject:@"Dresden"]; 


    [mapView setMapType:MKMapTypeStandard]; 
    [mapView setZoomEnabled:YES]; 
    [mapView setScrollEnabled:YES]; 
    MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } }; 
    region.center.latitude = 52.524268 ; 
    region.center.longitude = 13.40629; 
    region.span.longitudeDelta = 0.01f; 
    region.span.latitudeDelta = 0.01f; 
    [mapView setRegion:region animated:YES]; 

    [mapView setDelegate:self]; 

    DisplayMap *gann = [[DisplayMap alloc] init]; 
    gann.title = @"Berlin"; 
    gann.subtitle = @"Germany"; 
    gann.coordinate = region.center; 
    [mapView addAnnotation:gann]; 


    MKCoordinateRegion region1 = { {0.0, 0.0 }, { 0.0, 0.0 } }; 
    region1.center.latitude = 51.050991 ; 
    region1.center.longitude = 13.733634; 
    region1.span.longitudeDelta = 0.01f; 
    region1.span.latitudeDelta = 0.01f; 
    [mapView setRegion:region1 animated:YES]; 


    DisplayMap *gann1 = [[DisplayMap alloc] init]; 
    gann1.title = @"Dresden"; 
    gann1.subtitle = @"Germany"; 
    gann1.coordinate = region1.center; 
    [mapView addAnnotation:gann1]; 


    MKCoordinateRegion region2 = { {0.0, 0.0 }, { 0.0, 0.0 } }; 
    region2.center.latitude = 50.111445 ; 
    region2.center.longitude = 8.680615; 
    region2.span.longitudeDelta = 0.01f; 
    region2.span.latitudeDelta = 0.01f; 
    [mapView setRegion:region2 animated:YES]; 


    DisplayMap *gann2 = [[DisplayMap alloc] init]; 
    gann2.title = @"Frankfurt"; 
    gann2.subtitle = @"Germany"; 
    gann2.coordinate = region2.center; 
    [mapView addAnnotation:gann2]; 

} 


else if([myArr containsObject:@"Austria"]) 
{ 

    ausArr = [[NSMutableArray alloc]init]; 
    [ausArr addObject:@"Vienna"]; 
    [ausArr addObject:@"Danube River"]; 


    [mapView setMapType:MKMapTypeStandard]; 
    [mapView setZoomEnabled:YES]; 
    [mapView setScrollEnabled:YES]; 
    MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } }; 
    region.center.latitude = 48.208174 ; 
    region.center.longitude = 16.373819; 
    region.span.longitudeDelta = 0.01f; 
    region.span.latitudeDelta = 0.01f; 
    [mapView setRegion:region animated:YES]; 

    [mapView setDelegate:self]; 

    DisplayMap *ausann = [[DisplayMap alloc] init]; 
    ausann.title = @"Vienna"; 
    ausann.subtitle = @"Austria"; 
    ausann.coordinate = region.center; 
    [mapView addAnnotation:ausann]; 


    MKCoordinateRegion region1 = { {0.0, 0.0 }, { 0.0, 0.0 } }; 
    region1.center.latitude = 48.266667 ; 
    region1.center.longitude = 16.366667; 
    region1.span.longitudeDelta = 0.01f; 
    region1.span.latitudeDelta = 0.01f; 
    [mapView setRegion:region1 animated:YES]; 


    DisplayMap *ausann1 = [[DisplayMap alloc] init]; 
    ausann1.title = @"Danube River"; 
    ausann1.subtitle = @"Austria"; 
    ausann1.coordinate = region1.center; 
    [mapView addAnnotation:ausann1]; 


} 
+0

感謝。問題は、地域に含まれる都市や緯度/経度がわからないことです。それはユーザーの場所とGoogleプレイスの検索結果に依存しています。 – hanumanDev

+0

次に特定の都市に特定の緯度と経度を渡してから、直接またはユーザーの現在地を緯度と経度に渡します。 – Dev

関連する問題