如何將緯度和經度值從CLLocation Manager傳遞到我的CustomView。我有一個視圖控制器隨着CLLocationManger其中IAM獲得位置,我有另一個UIView類用的drawRect在那裏我有分爲觀與座標如何從CLLocationManager傳遞位置
#define EARTH_RADIUS 6371
- (void)drawRect:(CGRect)rect
{
CGPoint latLong = {41.998035, -116.012215};
CGPoint newCoord = [self convertLatLongCoord:latLong];
NSLog(@"Cartesian Coordinate: (%f, %f)",newCoord.x, newCoord.y);
//Draw dot at coordinate
CGColorRef darkColor = [[UIColor colorWithRed:21.0/255.0
green:92.0/255.0
blue:136.0/255.0
alpha:1.0] CGColor];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, darkColor);
CGContextFillRect(context, CGRectMake(newCoord.x, newCoord.y, 100, 100));
}
-(CGPoint)convertLatLongCoord:(CGPoint)latLong
{
CGFloat x = EARTH_RADIUS * cos(latLong.x) * cos(latLong.y);
CGFloat y = EARTH_RADIUS * cos(latLong.x) * sin(latLong.y);
return CGPointMake(x, y);
}
我已經拿了CGPoint經緯度= {41.998035,-116.012215}靜。
你能說我如何傳遞一個視圖控制器值到UIView類
我想更新設備移動的位置。它沒有地圖。 – 2013-05-12 14:40:46
@ rajesh.k - 我明白了,但我不認爲'convertLatLongCoord'會達到您認爲的任何效果。玩弄它,你會明白我的意思。 – Rob 2013-05-12 14:43:54
選中此項,我想找到沒有地圖的船。 https://play.google.com/store/apps/details?id=com.terboel.myanchorwatch – 2013-05-12 14:55:48