怎么查android定位吗,Android 实时定位与查询的显示问题

问题:1:仅定位后显示当前位置的图标如

5c9b9b8e122746a9048b75436206305a.png,在此基础上添加动态图层以开发查询功能,结果是实时定位能实现,查询功能正常,仅上图位置图标不显示。

2:在单独实现定位功能时,手机转动上图标“圆”随之转动,三角形不动,如何改成三角形转动,而圆圈不动?

本人代码:

mMapControl.getMap().refresh();

mDynView = new DynamicView(context, mMapControl.getMap());

mView = new CompassView(this);

mapView.addDynamicView(mDynView);

mapView.addView(mView);

mGesture = new Gesture(mapView,mDynView);

mPopup = new QueryResultPopup(mapView,mDynView);

mMapControl.getMap().refresh();

mGesture.setSearchAroundListener(new SearchAroundListener() {

public void searchGeometry(Geometry geoRegion) {

query(geoRegion, DatasetType.POINT);

}

});

CompassView.java:

package com.example.supermarket;

import java.io.InputStream;

import com.supermap.data.Point;

import android.content.Context;

import android.graphics.Bitmap;

import android.graphics.BitmapFactory;

import android.graphics.Canvas;

import android.graphics.Paint;

import android.graphics.BitmapFactory.Options;

import android.util.AttributeSet;

import android.view.View;

public class CompassView extends View {

private Bitmap[] mBitmapArray = new Bitmap[4];

InputStream is;

private float[] mValues;

int[] mBitmapWidth = new int[4];

int[] mBitmapHeight = new int[4];

public Point point;

public Point getPoint() {

return point;

}

public void setPoint(Point point) {

this.point = point;

}

public CompassView(Context context) {

this(context, null);

// TODO Auto-generated constructor stub

}

public CompassView(Context context, AttributeSet attrs) {

super(context, attrs);

BitmapFactory.Options opts = new Options();

opts.inJustDecodeBounds = false;

setBitMapArray(context, 0, opts, R.drawable.panel);

setBitMapArray(context, 1, opts, R.drawable.daohang);

}

/**

* 设置bitmap数组个下标的值

*

* @param index

* @param opts

* @param resid

*/

private void setBitMapArray(Context context, int index,

BitmapFactory.Options opts, int resid) {

is = context.getResources().openRawResource(resid);

mBitmapArray[index] = BitmapFactory.decodeStream(is);

mBitmapWidth[index] = mBitmapArray[index].getWidth();

mBitmapHeight[index] = mBitmapArray[index].getHeight();

mBitmapArray[index + 2] = BitmapFactory.decodeStream(is, null, opts);

mBitmapHeight[index + 2] = mBitmapArray[index + 2].getHeight();

mBitmapWidth[index + 2] = mBitmapArray[index + 2].getWidth();

}

@Override

protected void onDraw(Canvas canvas) {

// TODO Auto-generated method stub

super.onDraw(canvas);

Paint paint = new Paint();

paint.setAntiAlias(true);

int w = canvas.getWidth();

int h = canvas.getHeight();

int cx;

int cy;

if(point !=null){

cx = point.getX();

cy = point.getY();

}else

{

cx=w/2;

cy=h/2;

}

canvas.translate(cx, cy);

drawPictures(canvas, 0);

}

private void drawPictures(Canvas canvas, int idDelta) {

if (mValues != null) {

// Log.d(TAG, "mValues[0] = "+ mValues[0]);

canvas.rotate(-mValues[0]);

canvas.drawBitmap(mBitmapArray[0 + idDelta],

-mBitmapWidth[0 + idDelta] / 2,

-mBitmapHeight[0 + idDelta] / 2, null);

canvas.rotate(360 + mValues[0]);

canvas.drawBitmap(mBitmapArray[1 + idDelta],

-mBitmapWidth[1 + idDelta] / 2,

-mBitmapHeight[1 + idDelta] / 2, null);

} else {

canvas.drawBitmap(mBitmapArray[0 + idDelta],

-mBitmapWidth[0 + idDelta] / 2,

-mBitmapHeight[0 + idDelta] / 2, null);

canvas.drawBitmap(mBitmapArray[1 + idDelta],

-mBitmapWidth[1 + idDelta] / 2,

-mBitmapHeight[1 + idDelta] / 2, null);

}

}

public void setValue(float[] value) {

this.mValues = value;

}

望大神指导一二!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值