相关疑难解决方法(0)

GoogleMap API为两点之间的方向提供了错误的坐标

我正在使用GoogleMap API在GoogleMap上显示两点之间的绘制方向.

我想在iOS 6.1上给予支持,所以我使用谷歌地图我知道iOS7恢复这个.

使用下面的代码进行解析并获取坐标的步骤以在地图上绘制折线:

NSString *str=@"http://maps.googleapis.com/maps/api/directions/json?origin=bharuch,gujarat&destination=vadodara,gujarat&sensor=false";

NSURL *url=[[NSURL alloc]initWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

NSURLRequest *request = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];

NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
     NSError* error;

NSDictionary* json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];

NSArray* latestRoutes = [json objectForKey:@"routes"];

NSMutableDictionary *legs=[[[latestRoutes objectAtIndex:0] objectForKey:@"legs"] objectAtIndex:0];

NSArray *steps=[legs objectForKey:@"steps"];

NSString *startLocation,*endLocation,*totalDistance,*totalDuration;
     CLLocationCoordinate2D startLoc,endLoc;
     startLocation = [legs  objectForKey:@"start_address"];
     endLocation = [legs objectForKey:@"end_address"];
     totalDistance = [[legs objectForKey:@"distance"] objectForKey:@"text"];
     totalDuration = [[legs objectForKey:@"duration"] objectForKey:@"text"];
     startLoc=CLLocationCoordinate2DMake([[[legs objectForKey:@"start_location"] objectForKey:@"lat"] doubleValue], [[[legs objectForKey:@"start_location"] objectForKey:@"lng"] doubleValue]);
     endLoc=CLLocationCoordinate2DMake([[[legs objectForKey:@"end_location"] objectForKey:@"lat"] …
Run Code Online (Sandbox Code Playgroud)

google-maps ios ios6-maps google-maps-sdk-ios ios6.1

2
推荐指数
1
解决办法
2292
查看次数

SWIFT:谷歌地图绘制航点折线

您好,我想知道是否有一种方法可以在谷歌地图 iOS 中的两个或多个标记之间绘制航路点。我不想画直线...而是只使用公共道路。这是我的一些绘制直线的代码,但这不是我想要的。

    @objc private func makeGpsPath(){
    for i in 0 ..< trailArr.count {
        path.add(trailArr[i])
    }
    let polyline = GMSPolyline(path: path)
    polyline.strokeWidth = 5.0
    polyline.strokeColor = UIColor.black
    polyline.map = mapViewContainer
}
Run Code Online (Sandbox Code Playgroud)

google-maps swift

1
推荐指数
1
解决办法
1万
查看次数