本文整理汇总了Java中com.mapbox.mapboxsdk.views.MapView.getProjection方法的典型用法代码示例。如果您正苦于以下问题:Java MapView.getProjection方法的具体用法?Java MapView.getProjection怎么用?Java MapView.getProjection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.mapbox.mapboxsdk.views.MapView
的用法示例。
在下文中一共展示了MapView.getProjection方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSingleTapConfirmed
import com.mapbox.mapboxsdk.views.MapView; //导入方法依赖的package包/类
@Override
public boolean onSingleTapConfirmed(MotionEvent e, MapView mapView) {
final int size = this.size();
final Projection projection = mapView.getProjection();
final float x = e.getX();
final float y = e.getY();
for (int i = 0; i < size; i++) {
final Marker item = getItem(i);
if (markerHitTest(item, projection, x, y)) {
// We have a hit, do we get a response from onTap?
if (onTap(i)) {
// We got a response so consume the event
return true;
}
}
}
return super.onSingleTapConfirmed(e, mapView);
}
示例2: activateSelectedItems
import com.mapbox.mapboxsdk.views.MapView; //导入方法依赖的package包/类
/**
* When a content sensitive action is performed the content item needs to be identified. This
* method does that and then performs the assigned task on that item.
*
* @return true if event is handled false otherwise
*/
private boolean activateSelectedItems(final MotionEvent event,
final MapView mapView,
final ActiveItem task) {
final Projection projection = mapView.getProjection();
final float x = event.getX();
final float y = event.getY();
for (int i = 0; i < this.mItemList.size(); ++i) {
final Marker item = getItem(i);
if (markerHitTest(item, projection, x, y)) {
if (task.run(i)) {
this.setFocus(item);
return true;
}
}
}
return false;
}
示例3: activateSelectedItems
import com.mapbox.mapboxsdk.views.MapView; //导入方法依赖的package包/类
/**
* When a content sensitive action is performed the content item needs to be identified. This
* method does that and then performs the assigned task on that item.
*
* @return true if event is handled false otherwise
*/
private boolean activateSelectedItems(final MotionEvent event,
final MapView mapView,
final ActiveItem task) {
final Projection projection = mapView.getProjection();
final float x = event.getX();
final float y = event.getY();
for (int i = 0; i < size(); ++i) {
final Marker item = getItem(i);
if (markerHitTest(item, projection, x, y)) {
if (task.run(i)) {
this.setFocus(item);
return true;
}
}
}
return false;
}
示例4: onTouchEvent
import com.mapbox.mapboxsdk.views.MapView; //导入方法依赖的package包/类
public boolean onTouchEvent(MotionEvent paramMotionEvent, MapView paramMapView) {
Projection localProjection = paramMapView.getProjection();
float x = paramMotionEvent.getX();
float y = paramMotionEvent.getY();
int i = 0;
while (i < this.mItemList.size()) {
if ((markerHitTest(getItem(i), localProjection, x, y)) && (this.mOnItemGestureListener.onItemDown(i, this.mItemList.get(i)))) {
return true;
}
i += 1;
}
return super.onTouchEvent(paramMotionEvent, paramMapView);
}
示例5: 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);
}
}
示例6: onLongPress
import com.mapbox.mapboxsdk.views.MapView; //导入方法依赖的package包/类
@Override
public boolean onLongPress(MotionEvent e, MapView mapView) {
Projection proj = mapView.getProjection();
ILatLng p = proj.fromPixels(e.getX(), e.getY());
//throw event to the receiver:
return mReceiver.longPressHelper(p);
}
示例7: drawSafe
import com.mapbox.mapboxsdk.views.MapView; //导入方法依赖的package包/类
@Override
protected void drawSafe(final ISafeCanvas c, final MapView mapView, final boolean shadow) {
if (shadow) {
return;
}
//Commented for now. It needs heavy testing to see if we actually need it
isAnimating = mapView.isAnimating();
// Calculate the half-world size
final Projection pj = mapView.getProjection();
c.getClipBounds(mClipRect);
float zoomDelta = (float) (Math.log(mapView.getScale()) / Math.log(2d));
final float zoomLevel = pj.getZoomLevel();
mWorldSize_2 = pj.getHalfWorldSize();
GeometryMath.viewPortRectForTileDrawing(pj, mViewPort);
int tileSize = Projection.getTileSize();
// Draw the tiles!
if (tileSize > 0) {
if (mDrawLoadingTile) {
drawLoadingTile(c.getSafeCanvas(), mapView, zoomLevel, mClipRect);
}
drawTiles(c.getSafeCanvas(), zoomLevel, tileSize, mViewPort, mClipRect);
}
if (UtilConstants.DEBUGMODE && mapView.getScrollableAreaLimit() != null) {
SafePaint paint = new SafePaint();
paint.setColor(Color.BLUE);
paint.setStyle(Paint.Style.STROKE);
Rect rect = new Rect();
mapView.getScrollableAreaLimit().round(rect);
if (mapView.getScrollableAreaLimit() != null) {
c.drawRect(rect, paint);
}
}
}
示例8: drawSafe
import com.mapbox.mapboxsdk.views.MapView; //导入方法依赖的package包/类
@Override
protected void drawSafe(final ISafeCanvas c, final MapView mapView, final boolean shadow) {
// Log.d(TAG, "drawSafe() called with shadow = '" + shadow + "'");
if (shadow) {
return;
}
//Commented for now. It needs heavy testing to see if we actually need it
isAnimating = mapView.isAnimating();
// Calculate the half-world size
final Projection pj = mapView.getProjection();
c.getClipBounds(mClipRect);
float zoomDelta = (float) (Math.log(mapView.getScale()) / Math.log(2d));
final float zoomLevel = pj.getZoomLevel();
mWorldSize_2 = pj.getHalfWorldSize();
GeometryMath.viewPortRectForTileDrawing(pj, mViewPort);
int tileSize = Projection.getTileSize();
// Draw the tiles!
if (tileSize > 0) {
// Log.d(TAG, "drawSafe(), start drawing tiles!");
drawLoadingTile(c.getSafeCanvas(), mapView, zoomLevel, mClipRect);
drawTiles(c.getSafeCanvas(), zoomLevel, tileSize, mViewPort, mClipRect);
// Log.d(TAG, "drawSafe(), done drawing tiles!");
} else {
Log.d(TAG, "tileSize is not > 0, so not drawing tiles.");
}
if (UtilConstants.DEBUGMODE && mapView.getScrollableAreaLimit() != null) {
SafePaint paint = new SafePaint();
paint.setColor(Color.BLUE);
paint.setStyle(Paint.Style.STROKE);
Rect rect = new Rect();
mapView.getScrollableAreaLimit().round(rect);
if (mapView.getScrollableAreaLimit() != null) {
c.drawRect(rect, paint);
}
}
}
示例9: onSingleTapConfirmed
import com.mapbox.mapboxsdk.views.MapView; //导入方法依赖的package包/类
@Override
public boolean onSingleTapConfirmed(final MotionEvent e, final MapView mapView) {
Projection proj = mapView.getProjection();
ILatLng p = proj.fromPixels(e.getX(), e.getY());
return mReceiver.singleTapUpHelper(p);
}
示例10: 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();
}
示例11: 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);
}
}
}
}