假如沒有什麼角度來看,你有四個角的座標,它只是縮放位置描述如下事項:
Point upperRightGPS; // upper right GPS coordinates
Point upperLeftGPS; // upper left GPS coordinates
Point lowerRightGPS; // lower left GPS corrdinates
Point upperRight; // upper right screen pixel value (100, 0)?
Point upperLeft; // upper left screen pixel value (0,0)?
Point lowerRight; // lower right screen pixel value (0, 200)?
public Point positionOnMap(Point gps){
double dx = (upperRight.x - upperLeft.x)/(upperRightGPS.x - upperLeftGPS.x);
double dy = (upperRight.y - lowerRight.y)/(upperRightGPS.y - lowerRightGPS.y);
return new Point((int) dx * gps.x, (int) dy * gps.y);
}
這是假設的起源是在你的屏幕upperleft。
您可能需要調整上述代碼才能在您的情況下工作,但這是我最好的猜測,而不會看到您的代碼。
這聽起來像你沒有使用MapActivity,是否正確? – 2012-02-05 22:52:34
約翰,我更新了這篇文章。不,我不使用mapactivity。 – Yash 2012-02-05 22:56:46
由於您使用的是梯形,這是否包含某種3D視角?如果是這樣,你是否使用opengles功能將你的地圖(最好是矩形)轉換成梯形? – 2012-02-05 23:01:01