我已经倾倒了文档并且无法解决这个问题.它甚至可能吗?
Please see this
解决方法:
看起来正确的机制是扩展MyLocationOverlay然后覆盖drawMyLocation()受保护的方法.
以下使用箭头显示“你”的位置以及“你”指向的方式:
package com.example;import androID.content.Context;import androID.graphics.Bitmap;import androID.graphics.BitmapFactory;import androID.graphics.Canvas;import androID.graphics.Matrix;import androID.graphics.Point;import androID.location.Location;import com.Google.androID.maps.GeoPoint;import com.Google.androID.maps.MapVIEw;import com.Google.androID.maps.MyLocationOverlay;public class MyCustomLocationOverlay extends MyLocationOverlay { private Context mContext; private float mOrIEntation; public MyCustomLocationOverlay(Context context, MapVIEw mapVIEw) { super(context, mapVIEw); mContext = context; } @OverrIDe protected voID drawMyLocation(Canvas canvas, MapVIEw mapVIEw, Location lastFix, GeoPoint myLocation, long when) { // translate the GeoPoint to screen pixels Point screenPts = mapVIEw.getProjection().topixels(myLocation, null); // create a rotated copy of the marker Bitmap arrowBitmap = BitmapFactory.decodeResource( mContext.getResources(), R.drawable.arrow_green); Matrix matrix = new Matrix(); matrix.postRotate(mOrIEntation); Bitmap rotatedBmp = Bitmap.createBitmap( arrowBitmap, 0, 0, arrowBitmap.getWIDth(), arrowBitmap.getHeight(), matrix, true ); // add the rotated marker to the canvas canvas.drawBitmap( rotatedBmp, screenPts.x - (rotatedBmp.getWIDth() / 2), screenPts.y - (rotatedBmp.getHeight() / 2), null ); } public voID setorIEntation(float newOrIEntation) { mOrIEntation = newOrIEntation; }}
总结 以上是内存溢出为你收集整理的java – 如何在MyLocationOverlay中为“你在这里”点使用自定义位图?全部内容,希望文章能够帮你解决java – 如何在MyLocationOverlay中为“你在这里”点使用自定义位图?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)