百度地图移动到指定点
求解,在oncreate的时候,设置地图中心在北京天安门,之后再调用mapController.setCenter来移动到别的地方,为什么地图没反应,但是当触摸手机的时候突然的就跳到了指定的点,如何去设置???
求高手解答!!
public class MyOverLay extends Overlay {
private GeoPoint geoPoint = null;
public MyOverLay(int x, int y) {
// TODO Auto-generated constructor stub
geoPoint = new GeoPoint(x, y);
}
//coonstruct the point on the map
//define a paint tool
private Paint paint = new Paint();
@Override
public void draw(Canvas arg0, MapView arg1, boolean arg2) {
// TODO Auto-generated method stub
super.draw(arg0, arg1, arg2);
Point point = mapView.getProjection().toPixels(geoPoint, null);
arg0.drawText("*ME*", point.x, point.y, paint);
// mapController = mapView.getController();
// mapView.invalidate();
// mapController.setCenter(this.geoPoint);
// mapController.animateTo(this.geoPoint);
}
}
private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Log.d(TAG, "onReceive");
String action = intent.getAction();
Log.d(TAG, "recv action: " + action);
if(action.equals(MIRROR_SERVER)) {
//...
int x = intent.getIntExtra("POINTX", 0);
int y = intent.getIntExtra("POINTY", 0);
Log.d(TAG, "x: " + x + ", y: " + y);
mapView.getOverlays().add(new MyOverLay(x, y));
GeoPoint geoPoint = new GeoPoint(x, y);
geoPoint = new GeoPoint(x, y);
mapController.setCenter(geoPoint);
// mapController.animateTo(geoPoint);
}
}
};
当我得到broadcast发来的点信息的时候我要在该点画上一个符号,然后地图移动到这个点,但是调用了setCentre地图不动
求高手解答!!
public class MyOverLay extends Overlay {
private GeoPoint geoPoint = null;
public MyOverLay(int x, int y) {
// TODO Auto-generated constructor stub
geoPoint = new GeoPoint(x, y);
}
//coonstruct the point on the map
//define a paint tool
private Paint paint = new Paint();
@Override
public void draw(Canvas arg0, MapView arg1, boolean arg2) {
// TODO Auto-generated method stub
super.draw(arg0, arg1, arg2);
Point point = mapView.getProjection().toPixels(geoPoint, null);
arg0.drawText("*ME*", point.x, point.y, paint);
// mapController = mapView.getController();
// mapView.invalidate();
// mapController.setCenter(this.geoPoint);
// mapController.animateTo(this.geoPoint);
}
}
private BroadcastReceiver mBroadcastReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
Log.d(TAG, "onReceive");
String action = intent.getAction();
Log.d(TAG, "recv action: " + action);
if(action.equals(MIRROR_SERVER)) {
//...
int x = intent.getIntExtra("POINTX", 0);
int y = intent.getIntExtra("POINTY", 0);
Log.d(TAG, "x: " + x + ", y: " + y);
mapView.getOverlays().add(new MyOverLay(x, y));
GeoPoint geoPoint = new GeoPoint(x, y);
geoPoint = new GeoPoint(x, y);
mapController.setCenter(geoPoint);
// mapController.animateTo(geoPoint);
}
}
};
当我得到broadcast发来的点信息的时候我要在该点画上一个符号,然后地图移动到这个点,但是调用了setCentre地图不动
...全文
相关推荐
类似滴滴打车,多辆小车在地图上平滑移动的实现,基于百度地图实现(轨迹已画好和无轨迹)
类似滴滴打车,多辆小车在地图上平滑移动的实现,基于百度地图实现(轨迹已画好和无轨迹) [注:本内容来自网络,在此分享仅为帮助有需要的网友,如果侵犯了您的权利,麻烦联系我,我会第一时间删除,谢谢您。]
百度地图选点定位demo
百度地图选点定位
百度地图点聚合
是官方demo中扣出来的
百度地图的安卓移动端demo-InfoWindow
百度InfoWindow实现的demo有详细注释,看不懂代码可以下载这个demo自己调试
百度地图区域例子
自己改写整合百度地图实例分为跳跃点,静态点,自定义图标点,多点增加标注 点开文件夹内html即可使用


