当我的地理位置改变如何做什么? [英] How to make anything when my geolocation is changed?
本文介绍了当我的地理位置改变如何做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要做出一些动作,即每当我的地理位置将被改变时,文本'我在这里'显示对话框。
I want to make some action, i.e. show dialog with text 'im here' every time when my geolocation will be changed.
我使用MyLocationOverlay动用我对谷歌地图的图形页面的位置点。
I'm using MyLocationOverlay to draw a dot on my location on the Google Maps's mapview.
我怎样才能做到这一点?
How can I achieve that?
推荐答案
下面是位置监听器类 -
Below is the location listener class -
private MyOverLay draw = new MyOverLay();
class MyLocationListener_gps implements LocationListener {
public void onLocationChanged(Location location) {
clat = location.getLatitude();
clon = location.getLongitude();
GeoPoint geoPoint = new GeoPoint((int) (clat * 1E6),
(int) (clon * 1E6));
mapView.getController().animateTo(geoPoint);
draw = new MyOverLay(geoPoint);
mapView.getOverlays().add(draw);
}
}
下面是code类覆盖 -
Here is code overlay class-
class MyOverLay extends Overlay {
private GeoPoint gp1;
private int mRadius = 3;
public MyOverLay() {
}
public MyOverLay(GeoPoint gp1) {
this.gp1 = gp1;
}
@Override
public boolean draw(Canvas canvas, MapView mapView, boolean shadow,
long when) {
Projection projection = mapView.getProjection();
if (shadow == false) {
Paint paint = new Paint();
paint.setAntiAlias(true);
Point point = new Point();
projection.toPixels(gp1, point);
paint.setColor(Color.BLUE);
RectF oval = new RectF(point.x - mRadius, point.y - mRadius,
point.x + mRadius, point.y + mRadius);
canvas.drawOval(oval, paint);
}
return super.draw(canvas, mapView, shadow, when);
}
}
这将绘制一个蓝色圆点为u移动和UR坐标chnage。
It will draw a blue dot as u move and ur co-ordinates chnage.
这篇关于当我的地理位置改变如何做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文