distanceFromLocation - 计算两点之间的距离 [英] distanceFromLocation - Calculate distance between two points

查看:354
本文介绍了distanceFromLocation - 计算两点之间的距离的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关于Core Location的一个简单问题,我正在尝试计算两点之间的距离,代码如下:

Just a quick question on Core Location, I'm trying to calculate the distance between two points, code is below:

    -(void)locationChange:(CLLocation *)newLocation:(CLLocation *)oldLocation
    {   

    // Configure the new event with information from the location.
        CLLocationCoordinate2D newCoordinate = [newLocation coordinate];
        CLLocationCoordinate2D oldCoordinate = [oldLocation coordinate];

        CLLocationDistance kilometers = [newCoordinate distanceFromLocation:oldCoordinate] / 1000; // Error ocurring here.
        CLLocationDistance meters = [newCoordinate distanceFromLocation:oldCoordinate]; // Error ocurring here.
}

我在最后两行收到以下错误:

I'm getting the following error on the last two lines:


错误:无法转换为指针类型

error: cannot convert to a pointer type

我一直在搜索谷歌,但我找不到任何东西。

I've been searching Google, but I cannot find anything.

推荐答案

试试这个:

CLLocationDistance meters = [newLocation distanceFromLocation:oldLocation];

您尝试使用的方法是 CLLocation 对象:)

The method you're trying to use is a method on a CLLocation object :)

这篇关于distanceFromLocation - 计算两点之间的距离的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆