// 添加定位图层
mLocationOverlay = new MyLocationOverlay(this, mMapView);
mMapView.getOverlays().add(mLocationOverlay);
public void onLocationChanged(Location location) {
if (location != null) {
pt = new GeoPoint((int) (location.getLatitude() * 1e6),
(int) (location.getLongitude() * 1e6));
// mMapView.getController().animateTo(pt);// = 0;// 本地标记
mSearch.reverseGeocode(pt);// ni地址解析
Toast.makeText(paisong2.this, "本地移动onlocation",
Toast.LENGTH_LONG).show();
upload(pt);
}
}
mMapView.getController().animateTo(pt);这一句加在onLocationChanged里面的话,以后每次一移动地图就跑到当前位置了,可是我只想第一次显示并移动到当前位置?
mMapView.getController().animateTo(pt);加在oncreate方法里面又会发生错误,请问要怎么解决??
// 初始化Location模块
mLocationManager = mBMapMan.getLocationManager();
// 通过enableProvider和disableProvider方法,选择定位的Provider
// mLocationManager.enableProvider(MKLocationManager.MK_NETWORK_PROVIDER);
// mLocationManager.disableProvider(MKLocationManager.MK_GPS_PROVIDER);
// 添加定位图层
MyLocationOverlay mylocTest = new MyLocationOverlay(this, mMapView);
mylocTest.enableMyLocation(); // 启用定位
mylocTest.enableCompass(); // 启用指南针
mMapView.getOverlays().add(mylocTest);