简体   繁体   English

iPhone应用程序:计算Google地图中路径的距离

[英]iPhone App: Calculate Distance of path in Google maps

I am developing an iPhone app. 我正在开发一个iPhone应用程序。 here in my App I have included Google maps.I am showing the highlighted path in map. 在我的应用中,我已经包含了Google地图。我在地图中显示了突出显示的路径。

Now my Question is how to calculate distance between two point as per path as Apple"s native map App is showing routes with distance. 现在我的问题是,如苹果的本机地图应用程序显示带距离的路线,如何按路径计算两点之间的距离。

Thanks in Advance. 提前致谢。

    CLLocation *loc1 = [[CLLocation alloc] initWithLatitude:oldLocation.coordinate.latitude longitude:oldLocation.coordinate.longitude];
    CLLocation *loc2 = [[CLLocation alloc] initWithLatitude:newLocation.coordinate.latitude longitude:newLocation.coordinate.latitude];

    CLLocationDistance distance = ([loc2 distanceFromLocation:loc1]) * 0.000621371192;

This may help you. 这可能对您有帮助。

When running in the simulator, Core Location assigns a fixed set of coordinate values to this property. 在模拟器中运行时,“核心位置”会为此属性分配一组固定的坐标值。 You must run your application on an iOS-based device to get real location values. 您必须在基于iOS的设备上运行应用程序才能获取真实位置值。

CLLocation *loc2 = [[CLLocation alloc] initWithLatitude:newLocation.coordinate.latitude longitude:newLocation.coordinate.latitude];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM