iOS如何在每个区域(任何位置和任何缩放)计算尺寸宽度到米 [英] iOS how to calculate size width to meters in every region(any location and any zoom)

查看:152
本文介绍了iOS如何在每个区域(任何位置和任何缩放)计算尺寸宽度到米的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

像标题一样,是否有人知道如何在每个区域计算尺寸宽度到米,意味着在每个地方和任何缩放。



我找到了如何获得zoomScale。

  CLLocationDegrees longitudeDelta = myMapView.region.span.longitudeDelta; 
CGFloat mapWidthInPixels = myMapView.bounds.size.width;
double zoomScale = longitudeDelta * MERCATOR_RADIUS * M_PI /(180.0 * mapWidthInPixels);

但我不知道结果意味着什么,如果我想得到尺寸宽度的米或者是20f行,我将 mapWidthInPixels 更改为20是否正确?

解决方案

你可以在这里找到一个详细的公式解释:将经度纬度转换为米



示例代码:

  CLLocationDegrees deltaLatitude = self.mapView.region.span。 latitudeDelta; 
CLLocationDegrees deltaLongitude = self.mapView.region.span.longitudeDelta;
CGFloat latitudeCircumference = 40075160 * cos(self.mapView.region.center.latitude * M_PI / 180);
NSLog(@x:%f; y:%f,deltaLongitude * latitudeCircumference / 360,deltaLatitude * 40008000/360);

马克赎金


like the title, does any one know how to calculate size width to meters in every region, means in every where and any zoom.

I found how to get the zoomScale.

CLLocationDegrees longitudeDelta = myMapView.region.span.longitudeDelta;
CGFloat mapWidthInPixels = myMapView.bounds.size.width;
double zoomScale = longitudeDelta * MERCATOR_RADIUS * M_PI / (180.0 * mapWidthInPixels);

But I don't know what does result mean, if I want to get the meters for size width or maybe a line 20f, I change the mapWidthInPixels to 20 does it right?

解决方案

You can find an elaborate explanation of the formula here: transform longitude latitude into meters.

Sample code:

CLLocationDegrees deltaLatitude = self.mapView.region.span.latitudeDelta;
CLLocationDegrees deltaLongitude = self.mapView.region.span.longitudeDelta;
CGFloat latitudeCircumference = 40075160 * cos(self.mapView.region.center.latitude * M_PI / 180);
NSLog(@"x: %f; y: %f", deltaLongitude * latitudeCircumference / 360, deltaLatitude * 40008000 / 360);

Credits to Mark Ransom

这篇关于iOS如何在每个区域(任何位置和任何缩放)计算尺寸宽度到米的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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