嘿,我使用这个公式成功地将经度和纬度转换为x / y坐标:
// These should roughly box Germany - use the actual values appropriate to your image
double minLat = 54.8;
double minLong = 5.5;
double maxLat = 47.2;
double maxLong = 15.1;
// Map image size (in points)
CGSize mapSize = mapView.frame.size;
// Determine the map scale (points per degree)
double xScale = mapSize.width / (maxLong - minLong);
double yScale = mapSize.height / (maxLat - minLat);
// Latitude and longitude of city
double spotLat = 49.993615;
double spotLong = 8.242493;
// position of map image for point
CGFloat x = (spotLong - minLong) * xScale;
CGFloat y - (spotLat - minLat) * yScale;
但现在我需要以另一种方式转换它。让我说我得到x = 83和y = 294.我怎样才能得到纬度&从那经度?
谢谢
答案 0 :(得分:2)
如果...
x = (spotLong - minLong) * xScale;
则...
(x / xScale) + minLong = spotLong;
肯定会重新安排这个等式吗?
然后对纬度进行同样的操作。