Googlemap 请求路径拼接

    NSString *origin = [NSString stringWithFormat:@"origin=%.6f,%.6f",_startLocationCoord.latitude,_startLocationCoord.longitude];

    NSString *destinagtion = [NSString stringWithFormat:@"destination=%.6f,%.6f",_endLocationCoord.latitude, _endLocationCoord.longitude];


    NSMutableString *mutableStr = [NSMutableString new];

    [mutableStrappendString:@"https://maps.googleapis.com/maps/api/directions/json?"];

    [mutableStrappendString:origin];

    [mutableStrappendString:@"&"];

    [mutableStrappendString:destinagtion];

    [mutableStrappendString:@"&"];

    [mutableStrappendString:@"mode=driving"];

    [mutableStrappendString:@"&"];

    [mutableStrappendString:[NSString stringWithFormat:@"key=%@",LAGOOGLEMAPSERVICEKEY]];


    if(locationArry && locationArry.count>0)

    {

        [mutableStrappendString:@"&"];

        [mutableStrappendString:@"waypoints="];

        for(inti=0; i

        {

            LAMapCoordinateLocation*location = [locationArryobjectAtIndex:i];

//            NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:3];

//            [dict setValue:@"true" forKey:@"stopover"];

            NSString*lvalue = [NSStringstringWithFormat:@"via:%.6f,%6f",[locationcoordinate].latitude,[locationcoordinate].longitude];

            [mutableStrappendString:lvalue];


            if((i+1)

            {

                [mutableStrappendString:@"|"];

            }

        }

        __weakLAMapService*weakself =self;

        [directionServicerequestDirections:mutableStrcomplete:^(NSDictionary*_Nonnulldirections,NSError*_Nonnullerror) {

            if(!error)

            {

                [weakselfdarwDirectionRoute:directions];

            }

            else

            {

#todo 粘贴图片

            }

        }];

    }

你可能感兴趣的:(Googlemap 请求路径拼接)