我从CoreLocation委托方法获取坐标
CLLocationCoordinate2D coordinate;CLLocationdegrees latitude;CLLocationdegrees longitude;- (voID)locationManager:(CLLocationManager *)manager dIDUpdateLocations:(NSArray *)locations{CLLocation *location = [locations lastObject];latitude = location.coordinate.latitude;longitude = location.coordinate.longitude;}
我正在将当前纬度和经度转换为CGPoint,如下所示
CGPoint startPoint = [mapVIEw convertCoordinate:retrIEvedCoordinate topointToVIEw:self.vIEw];CGPoint endPoint = [mapVIEw convertCoordinate:retrIEvedEndCoordinate topointToVIEw:self.vIEw];
我需要根据集合中的值在我的UIVIEw上绘制线条.如何正确调整/缩放,关于UIVIEw的CGPoints. UIVIEw帧大小为(0,768,1004).
这是我所做的扩展
- (CGPoint)convertLatLongCoord:(CGPoint)latLong {CGSize screenSize = [UIScreen mainScreen].applicationFrame.size;CGfloat SCALE = MIN(screenSize.wIDth,screenSize.height) / (2.0 * EARTH_RADIUS);CGfloat OFFSET = MIN(screenSize.wIDth,screenSize.height) / 2.0;CGfloat x = EARTH_RADIUS * cos(latLong.x) * cos(latLong.y) * SCALE + OFFSET;CGfloat y = EARTH_RADIUS * cos(latLong.x) * sin(latLong.y) * SCALE + OFFSET;return CGPointMake(x,y);}
其中#define EARTH_RADIUS 6371
线条图不正确,因为某处转换为CGPoint可能是错误的.我究竟做错了什么.需要帮助.
解决方法 要将CLLocationCoordinate2D转换为CGPoint,请在此处查看答案 – https://stackoverflow.com/a/37276779/2697425 总结以上是内存溢出为你收集整理的iphone – 将地理坐标转换为CGPoint并在UIView中绘制线条全部内容,希望文章能够帮你解决iphone – 将地理坐标转换为CGPoint并在UIView中绘制线条所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)