當前位置: 首頁>>代碼示例>>Java>>正文


Java MapView.getProjection方法代碼示例

本文整理匯總了Java中org.osmdroid.views.MapView.getProjection方法的典型用法代碼示例。如果您正苦於以下問題:Java MapView.getProjection方法的具體用法?Java MapView.getProjection怎麽用?Java MapView.getProjection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.osmdroid.views.MapView的用法示例。


在下文中一共展示了MapView.getProjection方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: draw

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    if(!shadow) {
        if(this.mIcon != null) {
            Projection pj = mapView.getProjection();
            pj.toPixels(this.mPosition, this.mPositionPixels);
            int width = this.mIcon.getIntrinsicWidth();
            int height = this.mIcon.getIntrinsicHeight();
            Rect rect = new Rect(0, 0, width, height);
            rect.offset(-((int)(this.mAnchorU * (float)width)), -((int)(this.mAnchorV * (float)height)));
            this.mIcon.setBounds(rect);
            this.mIcon.setAlpha((int)(this.mAlpha * 255.0F));
            float rotationOnScreen = this.mFlat?-this.mBearing:mapView.getMapOrientation() - this.mBearing;
            drawAt(canvas, this.mIcon, this.mPositionPixels.x, this.mPositionPixels.y, false, rotationOnScreen);
        }
    }
}
 
開發者ID:Arman92,項目名稱:Mapsforge-OsmDroid-GraphHopper,代碼行數:17,代碼來源:MyMarker.java

示例2: draw

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
@Override public void draw(Canvas canvas, MapView mapView, boolean shadow) {
	if (shadow)
		return;
	if (mIcon == null)
		return;
	
	final Projection pj = mapView.getProjection();
	
	pj.toPixels(mPosition, mPositionPixels);
	int width = mIcon.getIntrinsicWidth();
	int height = mIcon.getIntrinsicHeight();
	Rect rect = new Rect(0, 0, width, height);
	rect.offset(-(int)(mAnchorU*width), -(int)(mAnchorV*height));
	mIcon.setBounds(rect);
	
	mIcon.setAlpha((int)(mAlpha*255));
	
	float rotationOnScreen = (mFlat ? -mBearing : mapView.getMapOrientation()-mBearing);
	drawAt(canvas, mIcon, mPositionPixels.x, mPositionPixels.y, false, rotationOnScreen);
}
 
開發者ID:jeffallen,項目名稱:MarshrutMe,代碼行數:21,代碼來源:Marker.java

示例3: draw

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
@Override protected void draw(Canvas canvas, MapView mapView, boolean shadow) {

		if (shadow) {
			return;
		}

		final Projection pj = mapView.getProjection();
		mPath.rewind();
		
		mOutline.buildPathPortion(pj);
		
		for (LinearRing hole:mHoles){
			hole.buildPathPortion(pj);
		}
		
		canvas.drawPath(mPath, mFillPaint);
		canvas.drawPath(mPath, mOutlinePaint);
	}
 
開發者ID:jeffallen,項目名稱:MarshrutMe,代碼行數:19,代碼來源:Polygon.java

示例4: isCloseTo

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
/** Detection is done is screen coordinates. 
 * @param point
 * @param tolerance in pixels
 * @return true if the Polyline is close enough to the point. 
 */
public boolean isCloseTo(GeoPoint point, double tolerance, MapView mapView) {
	final Projection pj = mapView.getProjection();
	precomputePoints(pj);
	Point p = pj.toPixels(point, null);
	int i = 0;
	boolean found = false;
	while (i < mPointsPrecomputed - 1 && !found) {
		Point projectedPoint1 = mPoints.get(i);
		if (i == 0){
			pj.toPixelsFromProjected(projectedPoint1, mTempPoint1);
		} else {
			//reuse last b:
			mTempPoint1.set(mTempPoint2.x, mTempPoint2.y);
		}
		Point projectedPoint2 = mPoints.get(i+1);
		pj.toPixelsFromProjected(projectedPoint2, mTempPoint2);
		found = (linePointDist(mTempPoint1, mTempPoint2, p, true) <= tolerance);
		//TODO: if found, compute and return the point ON the line. 
		i++;
	}
	return found;
}
 
開發者ID:jeffallen,項目名稱:MarshrutMe,代碼行數:28,代碼來源:Polyline.java

示例5: draw

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
@Override protected void draw(Canvas canvas, MapView mapView, boolean shadow) {
	if (shadow)
		return;
	if (mImage == null)
		return;
	
	if (mHeight == NO_DIMENSION){
		mHeight = mWidth * mImage.getIntrinsicHeight() / mImage.getIntrinsicWidth();
	}
	
	final Projection pj = mapView.getProjection();
	
	pj.toPixels(mPosition, mPositionPixels);
	GeoPoint pEast = mPosition.destinationPoint(mWidth, 90.0f);
	GeoPoint pSouthEast = pEast.destinationPoint(mHeight, -180.0f);
	pj.toPixels(pSouthEast, mSouthEastPixels);
	int width = mSouthEastPixels.x-mPositionPixels.x;
	int height = mSouthEastPixels.y-mPositionPixels.y;
	mImage.setBounds(-width/2, -height/2, width/2, height/2);
	
	mImage.setAlpha(255-(int)(mTransparency*255));

	drawAt(canvas, mImage, mPositionPixels.x, mPositionPixels.y, false, -mBearing);
}
 
開發者ID:jeffallen,項目名稱:MarshrutMe,代碼行數:25,代碼來源:GroundOverlay.java

示例6: zoom

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
private void zoom(MapView mapView, boolean ddragMode) {
    if (isDebugEnabled())  debug("zoom",this);
    // mapView.setC .zoomToBoundingBox(rect);

    final Projection projection = mapView.getProjection();
    IMapController controller = mapView.getController();
    if (ddragMode) {
        IGeoPoint start = projection.fromPixels(this.mStart.x, this.mStart.y);
        IGeoPoint end = projection.fromPixels(this.mEnd.x, this.mEnd.y);
        ZoomUtil.zoomTo(mapView, ZoomUtil.NO_ZOOM, start, end);
        if (isDebugEnabled()) debug("zoom(ddrag mode)", start, "..", end,
                "=>", mapView.getMapCenter(), "z=", mapView.getZoomLevel());
    } else {
        IGeoPoint center = projection.fromPixels(this.mStart.x, this.mStart.y);
        controller.setCenter(center);
        controller.zoomIn();
        if (isDebugEnabled()) debug("zoom(to center of)", center,
                "=>", mapView.getMapCenter(), "z=", mapView.getZoomLevel());
    }
}
 
開發者ID:k3b,項目名稱:LocationMapViewer,代碼行數:21,代碼來源:GuestureOverlay.java

示例7: hitTest

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
public boolean hitTest(MotionEvent event, MapView mapView) {
    Projection pj = mapView.getProjection();
    pj.toPixels(this.mPosition, this.mPositionPixels);
    Rect screenRect = pj.getIntrinsicScreenRect();
    int x = -this.mPositionPixels.x + screenRect.left + (int)event.getX();
    int y = -this.mPositionPixels.y + screenRect.top + (int)event.getY();
    boolean hit = this.mIcon.getBounds().contains(x, y);
    return hit;
}
 
開發者ID:Arman92,項目名稱:Mapsforge-OsmDroid-GraphHopper,代碼行數:10,代碼來源:MyMarker.java

示例8: draw

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
@Override
protected void draw(Canvas canvas, MapView mapView, boolean shadow) {
    if (this.Icon != null) {
        Projection pj = mapView.getProjection();
        Point PositionPixels = new Point();
        pj.toPixels(this.Position, PositionPixels);
        int width = this.Icon.getIntrinsicWidth();
        int height = this.Icon.getIntrinsicHeight();
        Rect rect = new Rect(0, 0, width, height);
        rect.offset(-((int) (this.AnchorU * (float) width)), -((int) (this.AnchorV * (float) height)));
        this.Icon.setBounds(rect);
        this.Icon.setAlpha((int) (this.Alpha * 255.0F));
        drawAt(canvas, this.Icon, PositionPixels.x, PositionPixels.y, false, 0);
    }
}
 
開發者ID:gabm,項目名稱:FancyPlaces,代碼行數:16,代碼來源:OsmMarker.java

示例9: hitTest

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
public boolean hitTest(final MotionEvent event, final MapView mapView){
        final Projection pj = mapView.getProjection();
        pj.toPixelsFromProjected(mMapCoordsProjected, mPositionPixels);

        final Rect screenRect = pj.getIntrinsicScreenRect();
        int x = -mPositionPixels.x + screenRect.left + (int) event.getX();
        int y = -mPositionPixels.y + screenRect.top + (int) event.getY();
        boolean hit = mIcon.getBounds().contains(x, y);
        return hit;
//        return true;
    }
 
開發者ID:Arman92,項目名稱:Mapsforge-OsmDroid-GraphHopper,代碼行數:12,代碼來源:MyLocationNewOverlay.java

示例10: hitTest

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
public boolean hitTest(final MotionEvent event, final MapView mapView){
	final Projection pj = mapView.getProjection();
	pj.toPixels(mPosition, mPositionPixels);
	final Rect screenRect = pj.getIntrinsicScreenRect();
	int x = -mPositionPixels.x + screenRect.left + (int) event.getX();
	int y = -mPositionPixels.y + screenRect.top + (int) event.getY();
	boolean hit = mIcon.getBounds().contains(x, y);
	return hit;
}
 
開發者ID:jeffallen,項目名稱:MarshrutMe,代碼行數:10,代碼來源:Marker.java

示例11: onSingleTapConfirmed

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
@Override public boolean onSingleTapConfirmed(final MotionEvent event, final MapView mapView){
	if (mInfoWindow == null)
		//no support for tap:
		return false;
	boolean tapped = contains(event);
	if (tapped){
		Projection pj = mapView.getProjection();
		GeoPoint position = (GeoPoint)pj.fromPixels((int)event.getX(), (int)event.getY());
		mInfoWindow.open(this, position, 0, 0);
	}
	return tapped;
}
 
開發者ID:jeffallen,項目名稱:MarshrutMe,代碼行數:13,代碼來源:Polygon.java

示例12: onSingleTapConfirmed

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
@Override public boolean onSingleTapConfirmed(final MotionEvent event, final MapView mapView){
	final Projection pj = mapView.getProjection();
	GeoPoint eventPos = (GeoPoint) pj.fromPixels((int)event.getX(), (int)event.getY());
	double tolerance = mPaint.getStrokeWidth();
	boolean touched = isCloseTo(eventPos, tolerance, mapView);
	if (touched){
		if (mOnClickListener == null){
			return onClickDefault(this, mapView, eventPos);
		} else {
			return mOnClickListener.onClick(this, mapView, eventPos);
		}
	} else
		return touched;
}
 
開發者ID:jeffallen,項目名稱:MarshrutMe,代碼行數:15,代碼來源:Polyline.java

示例13: draw

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
@Override public void draw(Canvas canvas, MapView mapView, boolean shadow) {
	if (shadow)
		return;
	if (mImage == null)
		return;
	
	if (mHeight == NO_DIMENSION){
		mHeight = mWidth * mImage.getIntrinsicHeight() / mImage.getIntrinsicWidth();
	}
	
	final Projection pj = mapView.getProjection();
	
	pj.toPixels(mPosition, mPositionPixels);
	/*
	GeoPoint pEast = mPosition.destinationPoint(mWidth, 90.0f);
	GeoPoint pSouthEast = pEast.destinationPoint(mHeight, -180.0f);
	pj.toPixels(pSouthEast, mSouthEastPixels);
	int width = mSouthEastPixels.x-mPositionPixels.x;
	int height = mSouthEastPixels.y-mPositionPixels.y;
	mImage.setBounds(-width/2, -height/2, width/2, height/2);
	*/
	GeoPoint pEast = mPosition.destinationPoint(mWidth/2, 90.0f);
	GeoPoint pSouthEast = pEast.destinationPoint(mHeight/2, -180.0f);
	pj.toPixels(pSouthEast, mSouthEastPixels);
	int hWidth = mSouthEastPixels.x-mPositionPixels.x;
	int hHeight = mSouthEastPixels.y-mPositionPixels.y;
	mImage.setBounds(-hWidth, -hHeight, hWidth, hHeight);

	mImage.setAlpha(255-(int)(mTransparency*255));

	drawAt(canvas, mImage, mPositionPixels.x, mPositionPixels.y, false, -mBearing);
}
 
開發者ID:MKergall,項目名稱:osmbonuspack,代碼行數:33,代碼來源:GroundOverlay.java

示例14: isHit

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
public boolean isHit(MotionEvent event, MapView mapView) {
    Projection pj = mapView.getProjection();

    Point PositionPixels = new Point();
    pj.toPixels(this.Position, PositionPixels);
    Rect screenRect = pj.getIntrinsicScreenRect();
    int x = -PositionPixels.x + screenRect.left + (int) event.getX();
    int y = -PositionPixels.y + screenRect.top + (int) event.getY();
    boolean hit = this.Icon.getBounds().contains(x, y);
    return hit;
}
 
開發者ID:gabm,項目名稱:FancyPlaces,代碼行數:12,代碼來源:OsmMarker.java

示例15: recalculateMatrix

import org.osmdroid.views.MapView; //導入方法依賴的package包/類
protected void recalculateMatrix(@NonNull final MapView mapView) {
    //final int mapSize = TileSystem.MapSize(mapView.getZoomLevel());

    final Projection projection = mapView.getProjection();
    final IGeoPoint geoPoint = mapView.getMapCenter();
    if (lastCenterGeoPoint == null) lastCenterGeoPoint = geoPoint;

    /*
    Log.d("BitmapPolygon", "geoPoint.getLatitude() =" + geoPoint.getLatitude());
    Log.d("BitmapPolygon", "geoPoint.getLongitude() =" + geoPoint.getLongitude());
    Log.d("BitmapPolygon", "lastCenterGeoPoint.getLatitude() =" + lastCenterGeoPoint.getLatitude());
    Log.d("BitmapPolygon", "lastCenterGeoPoint.getLongitude() = " + lastCenterGeoPoint.getLongitude());
    */

    final Point point = projection.toPixels(geoPoint, null);
    final Point lastCenterPoint = projection.toPixels(lastCenterGeoPoint, null);

    /*
    Log.d("BitmapPolygon", "point.x = " + point.x);
    Log.d("BitmapPolygon", "point.y = " + point.y);
    Log.d("BitmapPolygon", "lastCenterPoint.x = " + lastCenterPoint.x);
    Log.d("BitmapPolygon", "lastCenterPoint.y = " + lastCenterPoint.y);
    */

    xOffset += lastCenterPoint.x - point.x;
    yOffset += lastCenterPoint.y - point.y;

    xOffset %= width;
    yOffset %= height;

    final Matrix matrix = new Matrix();
    matrix.reset();
    matrix.setScale(1,1);
    matrix.preTranslate(xOffset, yOffset);
    //matrix.setTranslate(xOffset, yOffset);
    bitmapShader.setLocalMatrix(matrix);

    /*
    Log.d("BitmapPolygon", "xOffset = " + xOffset);
    Log.d("BitmapPolygon", "yOffset = " + yOffset);
    */

    mFillPaint.setShader(bitmapShader);

    lastCenterGeoPoint = geoPoint;
}
 
開發者ID:lassana,項目名稱:osmdroid-shape-extension,代碼行數:47,代碼來源:BitmapPolygon.java


注:本文中的org.osmdroid.views.MapView.getProjection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。