本文整理汇总了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);
}
}
示例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();
}
示例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);
}
}
}
}