Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/95.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
iOS检查注释';s坐标为{0,0}_Ios_For Loop_Annotations_Mkmapview_Coordinates - Fatal编程技术网

iOS检查注释';s坐标为{0,0}

iOS检查注释';s坐标为{0,0},ios,for-loop,annotations,mkmapview,coordinates,Ios,For Loop,Annotations,Mkmapview,Coordinates,我有一个循环语句,它从数组在mapView上显示注释。如何检查数组中的坐标是否为0,0,如果是,请删除/不打印它们 谢谢 代码: CLLocationCoordinate2D maxCoord = {45.60250f,-122.39181f}; CLLocationCoordinate2D minCoord = {45.35697f,-123.12789f}; NSArray *callsArray = [xmlParser calls];

我有一个循环语句,它从数组在mapView上显示注释。如何检查数组中的坐标是否为0,0,如果是,请删除/不打印它们

谢谢

代码:

        CLLocationCoordinate2D maxCoord = {45.60250f,-122.39181f};
        CLLocationCoordinate2D minCoord = {45.35697f,-123.12789f};

        NSArray *callsArray = [xmlParser calls];

        for (JointCAD *call in callsArray) {
            NSString *callnumber = [call.callnumber stringByAppendingFormat:@". "];
            NSString *callandnumber = [callnumber stringByAppendingString:call.currentCallType];
            CLLocationCoordinate2D newCoord = { [call.latitude doubleValue], [call.longitude doubleValue]};

            if ([call.longitude doubleValue] > maxCoord.longitude)
            {
                maxCoord.longitude = [call.longitude doubleValue];
            }
            if ([call.latitude doubleValue] > maxCoord.latitude)
            {
                maxCoord.latitude = [call.latitude doubleValue];
            }
            if ([call.longitude doubleValue] < minCoord.longitude)
            {
                minCoord.longitude = [call.longitude doubleValue];
            }
            if ([call.latitude doubleValue] < minCoord.latitude)
            {
                minCoord.latitude = [call.latitude doubleValue];
            }

            Annotation *ann = [[Annotation alloc] init];
            ann.title = callandnumber;
            ann.subtitle = [call location];
            ann.coordinate = newCoord;
            [mapView addAnnotation:ann];
        }

        MKCoordinateRegion region = {{0.0f, 0.0f}, {0.0f, 0.0f}};

        region.center.longitude = (minCoord.longitude + maxCoord.longitude) / 2.0;
        region.center.latitude = (minCoord.latitude + maxCoord.latitude) / 2.0;

        region.span.longitudeDelta = (maxCoord.longitude - minCoord.longitude) * 1.1;
        region.span.latitudeDelta = (maxCoord.latitude - minCoord.latitude) * 1.1;

        [mapView regionThatFits:region];
        [self.mapView setRegion:region animated:YES];

        [self setRefreshState:@"Finished"];
cllocationcoordinate2dmaxcoord={45.60250f,-122.39181f};
CLLocationCoordinate2D minCoord={45.35697f,-123.12789f};
NSArray*callsArray=[xmlParser调用];
for(JointCAD*调用callsArray){
NSString*callnumber=[call.callnumber stringByAppendingFormat:@.”;
NSString*callandnumber=[callnumber stringByAppendingString:call.currentCallType];
CLLocationCoordinate2D newCoord={[call.latitude doubleValue],[call.latitude doubleValue]};
if([call.longitude doubleValue]>maxCoord.longitude)
{
maxCoord.longitude=[call.longitude doubleValue];
}
if([call.latitude doubleValue]>maxCoord.latitude)
{
maxCoord.latitude=[call.latitude doubleValue];
}
if([call.longitude doubleValue]
Hm当坐标等于0时,为什么不在
for
循环中添加一个
continue

在创建
注释
对象之前,只需添加一个简单的

if(newCoord.latitude == 0 && newCoord.longitude == 0) continue;
continue
只需跳到循环的下一个迭代