0

ズームレベルとピクセル単位の地図のサイズを考慮して、Googleの静的地図画像の寸法(度またはキロメートル)を取得する方法があるかどうか疑問に思いました。

経度を度で取得する式を見てきました。

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

そして、これはかなり正確です。ただし、kmと度の比率は、極または赤道にどれだけ近いかによって変わるため、この式は機能しません(180の代わりに360を使用しても)

誰かがこれのための公式または何かヒントを持っていますか?

4

1 に答える 1

1

You can use MKMetersBetweenMapPoints to find dimensions in km.

//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 に答える