我有一个地图应用程序,当用户移动到某些位置时插入地图针,我的问题是我如何计算用户经过或在同一个地方的次数。
在以下示例中有:
用户已在(纬度,经度)地点 A 上五次。
这是我到目前为止的代码:
[outletMapView setMapType:MKMapTypeStandard]; [outletMapView setZoomEnabled:YES]; [outletMapView setScrollEnabled:YES]; MKCoordinateRegion region = { {0.0, 0.0 }, { 0.0, 0.0 } }; region.center.latitude = [[eachObject objectForKey:@"latitudeFrom"] floatValue]; //NSLog(@"latitudeFrom=%f",[[eachObject objectForKey:@"latitudeFrom"] floatValue]); region.center.longitude = [[eachObject objectForKey:@"longitudeFrom"] floatValue]; //NSLog(@"longitudeFrom=%f",[[eachObject objectForKey:@"longitudeFrom"] floatValue]); region.span.longitudeDelta = 6; region.span.latitudeDelta = 7; [outletMapView setRegion:region animated:YES]; ///// float longitude = [[eachObject objectForKey:@"latitudeFrom"] floatValue]; float latitude = [[eachObject objectForKey:@"longitudeFrom"] floatValue]; CLLocationCoordinate2D locationco = {latitude,longitude}; ann = [[DisplayMap alloc] init]; ann.coordinate = locationco; ann.title = [eachObject objectForKey:@"setDepartureAirportOrCode"]; int count=0; for(int j = aux; j < [objects count]; j++){ for(int k = j+1;k < [objects count]-j;k++){ NSMutableDictionary *item1 = [objects objectAtIndex:j]; NSMutableDictionary *item2 = [objects objectAtIndex:k]; NSString *str1 = [item1 valueForKey:@"setDepartureAirportOrCode"]; NSString *str2 = [item2 valueForKey:@"setDepartureAirportOrCode"]; // NSLog(@"%@==%@ ???",str1,str2); if([str1 isEqualToString:str2]) NSLog(@"%@==%@ MATCH!!!",str1,str2); count++; } } /* Contagem */ ann.subtitle = [NSString stringWithFormat:@"%d",count]; ann.coordinate = region.center; [outletMapView addAnnotation:ann];
对不起,我的英语很差,请不要降价,任何问题或疑问都会问我,我总是在线。