2013-02-15 1 views
1

지도에서 여러 핀을 떨어 뜨릴 때 위도와 경도 값이 달라집니다. 모든 핀을 얻는 메신저가 한 곳에 있습니다.지도에서 여러 핀을 놓을 때 위도와 경도 값이 달라집니다. 메신저 한 곳에서 모든 핀을 받고

여러 핀을 삭제하는 데이 코드를 작성했습니다.

dealerMapView.mapType = MKMapTypeStandard; 
    dealerMapView.zoomEnabled =YES; 
    [dealerMapView setDelegate:nil]; 
    dealerMapView.scrollEnabled = YES; 
    dealerMapView.showsUserLocation = NO; 
    CLLocationCoordinate2D location; 

     for (int i =0; i<[delarsInfoArray count]; i++) { 

      NSString *lattitudeValue = [[delarsInfoArray objectAtIndex:i]objectForKey:@"LATITUDE" ]; 

      NSString *longitudeValue = [[delarsInfoArray objectAtIndex:i]objectForKey:@"LONGITUDE" ]; 
      CLLocationCoordinate2D pCoordinate ; 
    pCoordinate.latitude = [lattitudeValue floatValue]; 
    pCoordinate.longitude = [longitudeValue floatValue]; 
    MKCoordinateRegion region; 
    MKCoordinateSpan span; 
    span.latitudeDelta = 0.005; 
    span.longitudeDelta = 0.005; 
    region.span = span; 
    region.center = location; 
    [dealerMapView setRegion:region animated:YES]; 
    myAnnotation1 = [[MyAnnotation alloc] init]; 
    myAnnotation1.coordinate = location; 
    myAnnotation1.title = [[delarsInfoArray objectAtIndex:i]objectForKey:@"STORE"]; 
    [dealerMapView addAnnotation:myAnnotation1]; 
} 

답변

0

이 코드를보십시오 :

MKCoordinateSpan span; 
span.latitudeDelta = 0.2; 
span.longitudeDelta= 0.2; 

if([delarsInfoArray count] > 0){ 

    CLLocationCoordinate2D start; 
    NSString *lattitudeValue = [[delarsInfoArray objectAtIndex:0]objectForKey:@"LATITUDE" ]; 

    NSString *longitudeValue = [[delarsInfoArray objectAtIndex:j]objectForKey:@"LONGITUDE" ]; 

// create region, consisting of span and location 
    MKCoordinateRegion mapRegion; 
    mapRegion.span = span; 
    mapRegion.center = start; 
//Move the map to our location // 
    [dealerMapView setRegion:mapRegion animated:YES]; 
} 
// do not show pins and annotations more then 200 in the map at a time. 
for (int j = 0; j< ([delarsInfoArray count] < 200?[delarsInfoArray count]:200); j++) { 
    NSString *lattitudeValue = [[delarsInfoArray objectAtIndex:i]objectForKey:@"LATITUDE"]; 
      NSString *longitudeValue = [[delarsInfoArray objectAtIndex:i]objectForKey:@"LONGITUDE" ]; 

    CLLocationCoordinate2D pinLocation; 
    if(([lattitudeValue floatValue] != 0) && ([longitudeValue floatValue] != 0)) { 
     pinLocation.latitude = [lattitudeValue floatValue]; 
     pinLocation.longitude = [longitudeValue floatValue]; 
     if(pinLocation.latitude !=0 && pinLocation.longitude !=0) { 
      myAnnotation1 = [[MyAnnotation alloc] init]; 
      myAnnotation1.coordinate = location; 
      myAnnotation1.title = [[delarsInfoArray objectAtIndex:i] objectForKey: @"STORE"]; 
      [dealerMapView addAnnotation:myAnnotation1]; 
     } 
    } 
} 

내가 당신 도움이되기를 바랍니다를! 최고의 행운. 건배!!

+0

: 감사합니다. 내 코드가 도움이되고 있습니다. – Pavne

+0

당신은 환영합니다! 루프의 반복마다 맵 영역을 설정했습니다. 이것은 내게 당신이 가진 이슈로 인도하는 것입니다 !! 그것이 당신을 도왔다 니 기뻐. –

관련 문제