0

我想知道在给定缩放级别和地图大小(以像素为单位)的情况下,是否有任何方法可以获取谷歌静态地图图像的尺寸(以度或公里为单位)。

我已经看到了一个以度数计算经度的公式:

(widthInPixels/256)*(360/pow(2,zoomLevel));

这是非常准确的。但是,公里和度数之间的比率会根据您与两极或赤道的距离而变化,因此这个公式不起作用(即使我用 360 代替 180)

有没有人有这个公式或任何提示?

4

1 回答 1

1

您可以使用 MKMetersBetweenMapPoints 以公里为单位查找尺寸。

//Let's say region is represents the piece of map
    MKMapPoint pWest = MKMapPointForCoordinate( CLLocationCoordinate2DMake(region.center.latitude, region.center.longitude-region.span.longitudeDelta/2.0));
    MKMapPoint pEast = MKMapPointForCoordinate( CLLocationCoordinate2DMake(region.center.latitude, region.center.longitude+region.span.longitudeDelta/2.0));
    CLLocationDistance distW = MKMetersBetweenMapPoints(pWest, pEast)/1000.0;//map width in km
    MKMapPoint pNorth = MKMapPointForCoordinate( CLLocationCoordinate2DMake(region.center.latitude+region.span.latitudeDelta/2.0, region.center.longitude));
    MKMapPoint pSouth = MKMapPointForCoordinate( CLLocationCoordinate2DMake(region.center.latitude-region.span.latitudeDelta/2.0, region.center.longitude));
    CLLocationDistance distH = MKMetersBetweenMapPoints(pNorth, pSouth)/1000.0;;//map height in km
于 2013-05-18T00:45:42.497 回答