嘿,我使用下面的公式成功地将经纬度转换为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。我怎样才能得到纬度& &;经度?
谢谢
IF…
x = (spotLong - minLong) * xScale;
然后……
(x / xScale) + minLong = spotLong;
可以重新排列一下方程式吗?
然后为纬度设置y。