【发布时间】:2015-01-01 07:12:34
【问题描述】:
我正在开发一个具有雷达功能的应用程序,就像 LOVOO 应用程序一样。我没有使用 CoreLocation 和其他基于位置的框架的经验。
如果您能建议我如何实现这一点,我们将不胜感激。 我应该使用什么框架以及如何开始。
虽然这里的 SO 上已经存在相同的问题,但我的问题与 Radar View like LOVOO 相同,但它对我没有用,这就是我再次问它的原因。
到目前为止,我自己尝试的是,我有要绘制的点的纬度和经度值,并且我已经计算了中心点(我的位置)和其他点之间的角度和距离
- (float)angletoCoordinate:(CLLocationCoordinate2D)second {
//myCurrentLocation is origin
//second is point
float lat1 = DegreesToRadians(myCurrentLocation.coordinate.latitude);
float lon1 = DegreesToRadians(myCurrentLocation.coordinate.longitude);
float lat2 = DegreesToRadians(second.latitude);
float lon2 = DegreesToRadians(second.longitude);
float dLon = lon2 - lon1;
float y = sin(dLon) * cos(lat2);
float x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(dLon);
float radiansBearing = atan2(y, x);
if(radiansBearing < 0.0)
{
radiansBearing += 2*M_PI;
}
return radiansBearing;
}
-(float)calculateXPointWithLoc:(ARGeoLocation *)loc andDelta:(float)delta{
float angle = radiansToDegrees(delta);
float dpx = (([myCurrentLocation distanceFromLocation:loc.geoLocation])/1000);
if(0<=angle<=90)
return viewRadar.center.x + sin(angle)*dpx ;
else if(90<angle<=180)
return viewRadar.center.x + cos(angle-90)*dpx ;
else if(180<angle<=270)
return viewRadar.center.x - cos(270-angle)*dpx ;
else if(270<angle<360)
return viewRadar.center.x - sin(360-angle)*dpx ;
return 0;
}
-(float)calculateYPointWithLoc:(ARGeoLocation *)loc andDelta:(float)delta{
float angle = radiansToDegrees(delta);
float dpx = (([myCurrentLocation distanceFromLocation:loc.geoLocation])/1000);
if(0<=angle<=90)
return viewRadar.center.y - cos(angle)*dpx ;
else if(90<angle<=180)
return viewRadar.center.y + sin(angle-90)*dpx ;
else if(180<angle<=270)
return viewRadar.center.y + sin(270-angle)*dpx ;
else if(270<angle<360)
return viewRadar.center.y - cos(360-angle)*dpx ;
return 0;
}
然后
int i = 0;
for(ARGeoLocation *loc in coordinates){
deltaAz = [self angletoCoordinate:loc.geoLocation.coordinate];
x = [self calculateXPointWithLoc:loc andDelta:deltaAz];
y = [self calculateYPointWithLoc:loc andDelta:deltaAz];
[[plots objectAtIndex:i] setFrame:CGRectMake(x, y, DIAMETER_PLOT, DIAMETER_PLOT)];
i++;
}
我不确定 x 和 y 是否正确,如果它们正确,那么我如何通过更改滑块值来更改这些值。
【问题讨论】:
-
我已经创建了一个类似的 LOVOO,例如带有滑块的 iOS 雷达视图。它可以在 github 上找到。 github.com/abm-adnan/Radar
-
那真的很棒.. 我一定会看看你是如何做到的,但是是的,我也创建了它,但由于与我的客户签署了 NDA,所以没有公开它。谢谢
-
如果您需要任何帮助,请告诉我如何提供帮助。谢谢
标签: ios iphone core-location augmented-reality