当前位置: 首页>>代码示例>>Java>>正文


Java MapView.getMeasuredWidth方法代码示例

本文整理汇总了Java中com.mapbox.mapboxsdk.views.MapView.getMeasuredWidth方法的典型用法代码示例。如果您正苦于以下问题:Java MapView.getMeasuredWidth方法的具体用法?Java MapView.getMeasuredWidth怎么用?Java MapView.getMeasuredWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.mapbox.mapboxsdk.views.MapView的用法示例。


在下文中一共展示了MapView.getMeasuredWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: drawSafe

import com.mapbox.mapboxsdk.views.MapView; //导入方法依赖的package包/类
/**
 * Draw a marker on each of our items. populate() must have been called first.<br/>
 * <br/>
 * The marker will be drawn twice for each Item in the Overlay--once in the shadow phase,
 * skewed
 * and darkened, then again in the non-shadow phase. The bottom-center of the marker will be
 * aligned with the geographical coordinates of the Item.<br/>
 * <br/>
 * The order of drawing may be changed by overriding the getIndexToDraw(int) method. An item
 * may
 * provide an alternate marker via its Marker.getMarker(int) method. If that method returns
 * null, the default marker is used.<br/>
 * <br/>
 * The focused item is always drawn last, which puts it visually on top of the other
 * items.<br/>
 *
 * @param canvas the Canvas upon which to draw. Note that this may already have a
 * transformation
 * applied, so be sure to leave it the way you found it
 * @param mapView the MapView that requested the draw. Use MapView.getProjection() to convert
 * between on-screen pixels and latitude/longitude pairs
 * @param shadow if true, draw the shadow layer. If false, draw the overlay contents.
 */
@Override
protected void drawSafe(ISafeCanvas canvas, MapView mapView, boolean shadow) {

    if (shadow) {
        return;
    }

    if (mPendingFocusChangedEvent && mOnFocusChangeListener != null) {
        mOnFocusChangeListener.onFocusChanged(this, mFocusedItem);
    }
    mPendingFocusChangedEvent = false;

    final Projection pj = mapView.getProjection();
    final int size = this.mInternalItemList.size() - 1;

    final RectF bounds =
            new RectF(0, 0, mapView.getMeasuredWidth(), mapView.getMeasuredHeight());
    pj.rotateRect(bounds);
    final float mapScale = 1 / mapView.getScale();

/* Draw in backward cycle, so the items with the least index are on the front. */
    for (int i = size; i >= 0; i--) {
        final Marker item = getItem(i);
        if (item == mFocusedItem) {
            continue;
        }
        onDrawItem(canvas, item, pj, mapView.getMapOrientation(), bounds, mapScale);
    }
    if (mFocusedItem != null) {
        onDrawItem(canvas, mFocusedItem, pj, mapView.getMapOrientation(), bounds, mapScale);
    }
}
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:56,代码来源:ItemizedOverlay.java

示例2: drawMyLocation

import com.mapbox.mapboxsdk.views.MapView; //导入方法依赖的package包/类
protected void drawMyLocation(final ISafeCanvas canvas, final MapView mapView, final Location lastFix) {

        final Rect mapBounds = new Rect(0, 0, mapView.getMeasuredWidth(), mapView.getMeasuredHeight());
        final Projection projection = mapView.getProjection();
        Rect rect = new Rect();
        getDrawingBounds(projection, lastFix, null).round(rect);
        if (!Rect.intersects(mapBounds, rect)) {
            //dont draw item if offscreen
            return;
        }
        projection.toMapPixels(mLatLng, mMapCoords);
        final float mapScale = 1 / mapView.getScale();

        canvas.save();

        canvas.scale(mapScale, mapScale, mMapCoords.x, mMapCoords.y);

        if (mDrawAccuracyEnabled) {
            final float radius = lastFix.getAccuracy() / (float) Projection.groundResolution(
                    lastFix.getLatitude(), mapView.getZoomLevel()) * mapView.getScale();
            canvas.save();
            // Rotate the icon
            canvas.rotate(lastFix.getBearing(), mMapCoords.x, mMapCoords.y);
            // Counteract any scaling that may be happening so the icon stays the same size

            mCirclePaint.setAlpha(50);
            mCirclePaint.setStyle(Style.FILL);
            canvas.drawCircle(mMapCoords.x, mMapCoords.y, radius, mCirclePaint);

            mCirclePaint.setAlpha(150);
            mCirclePaint.setStyle(Style.STROKE);
            canvas.drawCircle(mMapCoords.x, mMapCoords.y, radius, mCirclePaint);
            canvas.restore();
        }

        if (UtilConstants.DEBUGMODE) {
            final float tx = (mMapCoords.x + 50);
            final float ty = (mMapCoords.y - 20);
            canvas.drawText("Lat: " + lastFix.getLatitude(), tx, ty + 5, mPaint);
            canvas.drawText("Lon: " + lastFix.getLongitude(), tx, ty + 20, mPaint);
            canvas.drawText("Alt: " + lastFix.getAltitude(), tx, ty + 35, mPaint);
            canvas.drawText("Acc: " + lastFix.getAccuracy(), tx, ty + 50, mPaint);
        }

        if (lastFix.hasBearing()) {
            canvas.save();
            // Rotate the icon
            canvas.rotate(lastFix.getBearing(), mMapCoords.x, mMapCoords.y);
            // Draw the bitmap
            canvas.translate(-mDirectionArrowBitmap.getWidth() * mDirectionHotspot.x,
                    -mDirectionArrowBitmap.getHeight() * mDirectionHotspot.y);

            canvas.drawBitmap(mDirectionArrowBitmap, mMapCoords.x, mMapCoords.y, mPaint);
            canvas.restore();
        } else {
            canvas.save();
            // Unrotate the icon if the maps are rotated so the little man stays upright
            canvas.rotate(-mMapView.getMapOrientation(), mMapCoords.x, mMapCoords.y);
            // Counteract any scaling that may be happening so the icon stays the same size
            canvas.translate(-mPersonBitmap.getWidth() * mPersonHotspot.x,
                    -mPersonBitmap.getHeight() * mPersonHotspot.y);
            // Draw the bitmap
            canvas.drawBitmap(mPersonBitmap, mMapCoords.x, mMapCoords.y, mPaint);
            canvas.restore();
        }
        canvas.restore();
    }
 
开发者ID:RoProducts,项目名称:rastertheque,代码行数:68,代码来源:UserLocationOverlay.java

示例3: drawSafe

import com.mapbox.mapboxsdk.views.MapView; //导入方法依赖的package包/类
/**
     * Draw a marker on each of our items. populate() must have been called first.<br/>
     * <br/>
     * The marker will be drawn twice for each Item in the Overlay--once in the shadow phase,
     * skewed
     * and darkened, then again in the non-shadow phase. The bottom-center of the marker will be
     * aligned with the geographical coordinates of the Item.<br/>
     * <br/>
     * The order of drawing may be changed by overriding the getIndexToDraw(int) method. An item
     * may
     * provide an alternate marker via its Marker.getMarker(int) method. If that method returns
     * null, the default marker is used.<br/>
     * <br/>
     * The focused item is always drawn last, which puts it visually on top of the other
     * items.<br/>
     *
     * @param canvas  the Canvas upon which to draw. Note that this may already have a
     *                transformation
     *                applied, so be sure to leave it the way you found it
     * @param mapView the MapView that requested the draw. Use MapView.getProjection() to convert
     *                between on-screen pixels and latitude/longitude pairs
     * @param shadow  if true, draw the shadow layer. If false, draw the overlay contents.
     */
    @Override
    protected void drawSafe(ISafeCanvas canvas, MapView mapView, boolean shadow) {
        if (shadow) {
            return;
        }

        if (mPendingFocusChangedEvent && mOnFocusChangeListener != null) {
            mOnFocusChangeListener.onFocusChanged(this, mFocusedItem);
        }
        mPendingFocusChangedEvent = false;

        sortListByLatitude();

        final Projection pj = mapView.getProjection();
        final int size = size() - 1;

        final RectF bounds =
                new RectF(0, 0, mapView.getMeasuredWidth(), mapView.getMeasuredHeight());
        pj.rotateRect(bounds);
        final float mapScale = 1 / mapView.getScale();

        if (!mIsClusteringEnabled || mapView.getZoomLevel() > mMinZoomForClustering) {
            /* Draw in backward cycle, so the items with the least index are on the front. */
            for (int i = size; i >= 0; i--) {
                final Marker item = getItem(i);
                if (item == mFocusedItem) {
                    continue;
                }
                onDrawItem(canvas, item, pj, mapView.getMapOrientation(), bounds, mapScale);
            }

            if (mFocusedItem != null) {
                onDrawItem(canvas, mFocusedItem, pj, mapView.getMapOrientation(), bounds, mapScale);
            }

        } else if (mInternalClusterList != null) {
            for (int i = mInternalClusterList.size() - 1; i >= 0; --i) {
                final ClusterMarker clusterMarker = mInternalClusterList.get(i);
                List<Marker> markerList = clusterMarker.getMarkersReadOnly();

                if (markerList.size() > 1) {
//                    if (mOnDrawClusterListener != null) {
//                        Drawable drawable = mOnDrawClusterListener.drawCluster(clusterMarker);
//                        clusterMarker.setMarker(drawable);
//                    }
                    onDrawItem(canvas, clusterMarker, pj, mapView.getMapOrientation(), bounds, mapScale);
                } else {
                    onDrawItem(canvas, markerList.get(0), pj, mapView.getMapOrientation(), bounds, mapScale);
                }

            }
        }
    }
 
开发者ID:posm,项目名称:OpenMapKitAndroid,代码行数:77,代码来源:ItemizedOverlay.java


注:本文中的com.mapbox.mapboxsdk.views.MapView.getMeasuredWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。