質問
osmdroid(3.05)でfrompixels()関数を使用しています。
public boolean onScroll(ScrollEvent e) {
//get the scroll's destination
GeoPoint g = (GeoPoint) e.getSource().getProjection().fromPixels(e.getX(), e.getY());
Toast.makeText(e.getSource().getContext(), "in e6: " +
g.getLongitudeE6() + " " + g.getLatitudeE6() + " in deg's" +
convertToDecimalDegrees(g.getLongitudeE6())
+ " " + convertToDecimalDegrees(g.getLatitudeE6()), Toast.LENGTH_LONG).show();}
-0.0029109 51.9933734の近くのどこかにマップをスクロールしていますが、トーストでは次のようになります。
-0.9613029999999999776.605549999999
学位は大丈夫です - 私はただ1E -6を掛けるだけです)
この関数を誤って使用していますか?
私が読んだことから、私の使用法は問題ないようです。
その機能ですが、今すぐ修正する必要があります
前もって感謝します!
オムリ
解決
私はこのスレッドが少し古いことを知っていますが、この質問に対する答えはにあります http://code.google.com/p/osmdroid/issues/detail?id=209ポイントすることは、最大範囲のマップを設定し、その範囲でスクロールを制限することです。以下は上記の問題の要約です(以下のコードをmapview.javaに追加します)
protected Rect mScrollableAreaLimit = null;
public void setScrollableAreaLimit(BoundingBoxE6 boundingBox) {
final int worldSize_2 = TileSystem.MapSize(MapViewConstants.MAXIMUM_ZOOMLEVEL) / 2;
// Clear scrollable area limit if null passed.
if (boundingBox == null) {
mScrollableAreaLimit = null;
return;
}
// Get NW/upper-left
final Point upperLeft = TileSystem.LatLongToPixelXY(boundingBox.getLatNorthE6() / 1E6,
boundingBox.getLonWestE6() / 1E6, MapViewConstants.MAXIMUM_ZOOMLEVEL, null);
upperLeft.offset(-worldSize_2, -worldSize_2);
// Get SE/lower-right
final Point lowerRight = TileSystem.LatLongToPixelXY(boundingBox.getLatSouthE6() / 1E6,
boundingBox.getLonEastE6() / 1E6, MapViewConstants.MAXIMUM_ZOOMLEVEL, null);
lowerRight.offset(-worldSize_2, -worldSize_2);
mScrollableAreaLimit = new Rect(upperLeft.x, upperLeft.y, lowerRight.x, lowerRight.y);
}
これで、マップビューが作成されたときにSetScrollableAleAlimitメソッドを呼び出すか、BoundingBoxe6パラメーターを使用してコンストラクターを拡張できます。
お役に立てれば。
これに加えて、ダブルタップバグの修正が必要です http://code.google.com/p/osmdroid/issues/detail?id=209#c23
@Override
public void computeScroll() {
if (mScroller.computeScrollOffset()) {
if (mScroller.isFinished()) {
// This will facilitate snapping-to any Snappable points.
setZoomLevel(mZoomLevel);
} else {
/* correction for double tap */
int targetZoomLevel = getZoomLevel();
if (targetZoomLevel == mZoomLevel)
scrollTo(mScroller.getCurrX(), mScroller.getCurrY());
}
postInvalidate(); // Keep on drawing until the animation has
// finished.
}
}
所属していません StackOverflow