package com.epapnavigation.activity;
import java.util.ArrayList;
import java.util.List;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.baidu.mapapi.BMapManager;
import com.baidu.mapapi.map.Geometry;
import com.baidu.mapapi.map.Graphic;
import com.baidu.mapapi.map.GraphicsOverlay;
import com.baidu.mapapi.map.LocationData;
import com.baidu.mapapi.map.MapController;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.MyLocationOverlay;
import com.baidu.mapapi.map.RouteOverlay;
import com.baidu.mapapi.map.Symbol;
import com.baidu.mapapi.search.MKRoute;
import com.baidu.platform.comapi.basestruct.GeoPoint;
import com.epapnavigation.R;
import com.epapnavigation.common.DateUtil;
import com.epapnavigation.common.Declare;
import com.epapnavigation.db.MapLongLatService;
import com.epapnavigation.db.MapPointsService;
import com.epapnavigation.db.MapRouteService;
import com.epapnavigation.domain.MapLongLat;
import com.epapnavigation.domain.MapPoints;
import com.epapnavigation.domain.MapRoute;
import com.epapnavigation.domain.SP_Dict;
import com.epapnavigation.ui.EndPointSpinner;
public class MapNaviActivity extends BaseActivity {
//MapView 是地图主控件
private MapView mMapView = null;
//用MapController完成地图控制
private MapController mMapController = null;
// 定位相关
private LocationClient mLocationClient = null;
private MyLocationListener myListener = new MyLocationListener();
private LocationData locData = null;
// 定位图层
locationOverlay myLocationOverlay = null;
private EditText et_startpoint;
private EndPointSpinner sp_endPoint;
private Button btnNavigator,btnRoutePlan ,btn_startcollect,btn_stopcollect;
private List<MapLongLat> mapLongLatList ;
private static int POINTTYPEEND = 1;
//服务类
private MapLongLatService mapLongLatService;
private MapPointsService mapPointsService;
private MapRouteService mapRouteService;
Declare appDeclare; //控制采集流程
private Boolean collectStartGps = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
appDeclare = (Declare) this.getApplication();
if (appDeclare.mBMapManager == null) {
appDeclare.mBMapManager = new BMapManager(getApplicationContext());
//如果BMapManager没有初始化则初始化BMapManager
appDeclare.mBMapManager.init(new Declare.MyGeneralListener());
}
setContentView(R.layout.activity_mapnavi);
initView();
initMap();
}
//初期化视图
private void initView(){
et_startpoint = (EditText) findViewById(R.id.et_startpoint);
sp_endPoint = (EndPointSpinner) findViewById(R.id.sp_endPoint);
sp_endPoint.setSelection(0);
//实例化服务类
mapLongLatService = new MapLongLatService(mContext);
mapPointsService = new MapPointsService(mContext);
mapRouteService = new MapRouteService(mContext);
//绑定目的地列表
endpointsBind();
//启动导航
btnNavigator = (Button) findViewById(R.id.btnNavigator);
btnNavigator.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
}
});
//路径规划
btnRoutePlan = (Button) findViewById(R.id.btnRoutePlan);
btnRoutePlan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//加载地图经纬度数据源
initData();
if(null != mapLongLatList){
getRoute(mapLongLatList);
}
}
});
//开始采集
btn_startcollect = (Button) findViewById(R.id.btn_startcollect);
btn_startcollect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
collectStartGps = true;
if(dbLatitude.equals(0.0) || dbLongitude.equals(0.0)){
Toast.makeText(mContext, "操作失误", Toast.LENGTH_LONG).show();
}else{
MapPoints mapPoint = new MapPoints();
mapPoint.setCreateDate(DateUtil.getStringDate());
mapPoint.setPointLat(dbLatitude);
mapPoint.setPointLong(dbLongitude);
mapPoint.setPointName(startpointName);
try {
mapPointsService.UpdateMapPoint(mapPoint);
} catch (Exception e) {
Toast.makeText(mContext, "操作失误", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
Toast.makeText(mContext, "开始采集!", Toast.LENGTH_LONG).show();
}
}
});
//采集结束
btn_stopcollect = (Button) findViewById(R.id.btn_stopcollect);
btn_stopcollect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
collectStartGps = false;
if(dbLatitude.equals(0.0) || dbLongitude.equals(0.0)){
Toast.makeText(mContext, "操作失误", Toast.LENGTH_LONG).show();
}else{
MapPoints mapPoint = new MapPoints();
mapPoint.setCreateDate(DateUtil.getStringDate());
mapPoint.setPointLat(dbLatitude);
mapPoint.setPointLong(dbLongitude);
mapPoint.setPointName(endpointName);
try {
mapPointsService.UpdateMapPoint(mapPoint);
} catch (Exception e) {
Toast.makeText(mContext, "操作失误", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
Toast.makeText(mContext, "结束采集!", Toast.LENGTH_LONG).show();}
}
});
}
//加载地图经纬度数据源
private void initData(){
//导航点ID
if(sp_endPoint.getCount() > 0){
int mappointID = ((SP_Dict) sp_endPoint.getSelectedItem()).getId();
//路线ID
try {
int maproutID = mapRouteService.SeeMapRoute(mappointID).getMapRouteID();
mapLongLatList = mapLongLatService.getMapLongLats(maproutID);
} catch (Exception e) {
e.printStackTrace();
}
}
}
//Bind 目的地列表
private void endpointsBind(){
try {
List<SP_Dict> mapPoints = mapPointsService.SeeMapPointList(POINTTYPEEND);
sp_endPoint.setList((ArrayList<SP_Dict>)mapPoints);
ArrayAdapter<SP_Dict> mapPointAdapter = new ArrayAdapter<SP_Dict>(this,android.R.layout.simple_spinner_item, mapPoints);
sp_endPoint.setAdapter(mapPointAdapter);
} catch (Exception e) {
Toast.makeText(mContext, "系统错误", Toast.LENGTH_SHORT).show();
}
}
/**
* 绘制折线,该折线状态随地图状态变化
* @return 折线对象
*/
private Graphic drawLine(List<MapLongLat> mapLongLats){
//构建线
Geometry lineGeometry = new Geometry();
int counts = mapLongLats.size();
//设定折线点坐标
GeoPoint[] linePoints = new GeoPoint[counts];
for(int i =0 ;i<counts;i++){
linePoints[i] = mapLongLats.get(i).getGeopoint();
}
lineGeometry.setPolyLine(linePoints);
//设定样式
Symbol lineSymbol = new Symbol();
Symbol.Color lineColor = lineSymbol.new Color();
lineColor.red = 255;
lineColor.green = 0;
lineColor.blue = 0;
lineColor.alpha = 255;
lineSymbol.setLineSymbol(lineColor, 10);
//生成Graphic对象
Graphic lineGraphic = new Graphic(lineGeometry, lineSymbol);
return lineGraphic;
}
/**
* 绘制路线
*
* @param List
* <PillarGeo>
* */
private void getRoute(List<MapLongLat> mapLongLatList) {
// 用站点数据构建一个MKRoute
MKRoute route = new MKRoute();
// 起点坐标
GeoPoint start = mapLongLatList.get(0).getGeopoint();
// 终点坐标
GeoPoint stop = mapLongLatList.get((mapLongLatList.size() - 1)).getGeopoint();
int size = mapLongLatList.size();
GeoPoint[][] routeData = new GeoPoint[1][];
GeoPoint[] step = new GeoPoint[size];
for (int i = 0; i < mapLongLatList.size(); i++) {
step[i] = mapLongLatList.get(i).getGeopoint();
}
routeData[0] = step;
route.customizeRoute(start, stop, routeData);
RouteOverlay routeOverlay = new RouteOverlay(MapNaviActivity.this, mMapView);
routeOverlay.setData(route);
//向地图添加构造好的RouteOverlay
mMapView.getOverlays().add(routeOverlay);
//执行刷新使生效
mMapView.refresh();
}
/**
* 将自定义线条和关键点图标加载到地图上
*
* */
private void initOverlay(){
GraphicsOverlay graphicsOverlay = new GraphicsOverlay(mMapView);
mMapView.getOverlays().add(graphicsOverlay);
}
private void initMap(){
// 地图初始化
mMapView = (MapView) findViewById(R.id.bmapView);
// 实例化地图控制器
mMapController = mMapView.getController();
mMapController.setZoom(14);
mMapController.enableClick(true);
mMapView.setBuiltInZoomControls(true);
// 定位初始化
locData = new LocationData();
mLocationClient = new LocationClient(getApplicationContext());
LocationClientOption option = new LocationClientOption();
option.setOpenGps(true);// 打开gps
option.setCoorType("bd09ll"); // 设置坐标类型
option.setScanSpan(1000);
option.setAddrType("false");//返回的定位结果包含地址信息
option.setPriority(LocationClientOption.GpsFirst);//GPS优先
mLocationClient.setLocOption(option);
mLocationClient.registerLocationListener(myListener);
mLocationClient.start();
// 定位图层初始化
myLocationOverlay = new locationOverlay(mMapView);
// 设置定位数据
myLocationOverlay.setData(locData);
// 添加定位图层
mMapView.getOverlays().add(myLocationOverlay);
myLocationOverlay.enableCompass();
//修改定位数据后刷新图层生效
mMapView.refresh();
}
/**
* BDLocationListener接口有2个方法需要实现: 1.接收异步返回的定位结果,参数是BDLocation类型参数。
* 2.接收异步返回的POI查询结果,参数是BDLocation类型参数。
*
*/
public class MyLocationListener implements BDLocationListener {
@Override
public void onReceiveLocation(BDLocation location) {
if (location == null)
return;
locData.latitude = location.getLatitude();
locData.longitude = location.getLongitude();
dbLatitude = location.getLatitude();
dbLongitude = location.getLongitude();
if(collectStartGps){
try {
MapRoute mapRoute = mapRouteService.SeeMapRoute(endpointID);
int maprouteID = mapRoute.getMapRouteID();
MapLongLat mapLongLat = new MapLongLat();
mapLongLat.setLatitude(dbLatitude);
mapLongLat.setLongitude(dbLongitude);
mapLongLat.setMapRouteID(maprouteID);
mapLongLatService.AddMapLongLat(mapLongLat);
} catch (Exception e) {
Toast.makeText(mContext, "经纬度采集失败", Toast.LENGTH_LONG).show();
}
}
// 如果不显示定位精度圈,将accuracy赋值为0即可
locData.accuracy = location.getRadius();
// 此处可以设置 locData的方向信息, 如果定位 SDK 未返回方向信息,用户可以自己实现罗盘功能添加方向信息。
locData.direction = location.getDerect();
if (myLocationOverlay == null) {
myLocationOverlay = new locationOverlay(mMapView);
// 添加定位图层
mMapView.getOverlays().add(myLocationOverlay);
myLocationOverlay.enableCompass();
}
// 更新定位数据
myLocationOverlay.setData(locData);
mMapController.setCenter(new GeoPoint(
(int) (locData.latitude * 1e6),
(int) (locData.longitude * 1e6)));
// 更新图层数据执行刷新后生效
mMapView.refresh();
// 移动到定位点
mMapController.animateTo(new GeoPoint(
(int) (locData.latitude * 1e6),
(int) (locData.longitude * 1e6)));
}
@Override
public void onReceivePoi(BDLocation arg0) {
}
}
@Override
protected void onDestroy() {
// 退出时销毁定位
if (mLocationClient != null)
mLocationClient.stop();
mMapView.destroy();
super.onDestroy();
}
@Override
protected void onPause() {
mMapView.onPause();
super.onPause();
}
@Override
protected void onResume() {
mMapView.onResume();
super.onResume();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mMapView.onSaveInstanceState(outState);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
mMapView.onRestoreInstanceState(savedInstanceState);
}
public class locationOverlay extends MyLocationOverlay{
public locationOverlay(MapView mapView) {
super(mapView);
}
@Override
protected boolean dispatchTap() {
return true;
}
}
}
import java.util.ArrayList;
import java.util.List;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.baidu.mapapi.BMapManager;
import com.baidu.mapapi.map.Geometry;
import com.baidu.mapapi.map.Graphic;
import com.baidu.mapapi.map.GraphicsOverlay;
import com.baidu.mapapi.map.LocationData;
import com.baidu.mapapi.map.MapController;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.MyLocationOverlay;
import com.baidu.mapapi.map.RouteOverlay;
import com.baidu.mapapi.map.Symbol;
import com.baidu.mapapi.search.MKRoute;
import com.baidu.platform.comapi.basestruct.GeoPoint;
import com.epapnavigation.R;
import com.epapnavigation.common.DateUtil;
import com.epapnavigation.common.Declare;
import com.epapnavigation.db.MapLongLatService;
import com.epapnavigation.db.MapPointsService;
import com.epapnavigation.db.MapRouteService;
import com.epapnavigation.domain.MapLongLat;
import com.epapnavigation.domain.MapPoints;
import com.epapnavigation.domain.MapRoute;
import com.epapnavigation.domain.SP_Dict;
import com.epapnavigation.ui.EndPointSpinner;
public class MapNaviActivity extends BaseActivity {
//MapView 是地图主控件
private MapView mMapView = null;
//用MapController完成地图控制
private MapController mMapController = null;
// 定位相关
private LocationClient mLocationClient = null;
private MyLocationListener myListener = new MyLocationListener();
private LocationData locData = null;
// 定位图层
locationOverlay myLocationOverlay = null;
private EditText et_startpoint;
private EndPointSpinner sp_endPoint;
private Button btnNavigator,btnRoutePlan ,btn_startcollect,btn_stopcollect;
private List<MapLongLat> mapLongLatList ;
private static int POINTTYPEEND = 1;
//服务类
private MapLongLatService mapLongLatService;
private MapPointsService mapPointsService;
private MapRouteService mapRouteService;
Declare appDeclare; //控制采集流程
private Boolean collectStartGps = false;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
appDeclare = (Declare) this.getApplication();
if (appDeclare.mBMapManager == null) {
appDeclare.mBMapManager = new BMapManager(getApplicationContext());
//如果BMapManager没有初始化则初始化BMapManager
appDeclare.mBMapManager.init(new Declare.MyGeneralListener());
}
setContentView(R.layout.activity_mapnavi);
initView();
initMap();
}
//初期化视图
private void initView(){
et_startpoint = (EditText) findViewById(R.id.et_startpoint);
sp_endPoint = (EndPointSpinner) findViewById(R.id.sp_endPoint);
sp_endPoint.setSelection(0);
//实例化服务类
mapLongLatService = new MapLongLatService(mContext);
mapPointsService = new MapPointsService(mContext);
mapRouteService = new MapRouteService(mContext);
//绑定目的地列表
endpointsBind();
//启动导航
btnNavigator = (Button) findViewById(R.id.btnNavigator);
btnNavigator.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
}
});
//路径规划
btnRoutePlan = (Button) findViewById(R.id.btnRoutePlan);
btnRoutePlan.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//加载地图经纬度数据源
initData();
if(null != mapLongLatList){
getRoute(mapLongLatList);
}
}
});
//开始采集
btn_startcollect = (Button) findViewById(R.id.btn_startcollect);
btn_startcollect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
collectStartGps = true;
if(dbLatitude.equals(0.0) || dbLongitude.equals(0.0)){
Toast.makeText(mContext, "操作失误", Toast.LENGTH_LONG).show();
}else{
MapPoints mapPoint = new MapPoints();
mapPoint.setCreateDate(DateUtil.getStringDate());
mapPoint.setPointLat(dbLatitude);
mapPoint.setPointLong(dbLongitude);
mapPoint.setPointName(startpointName);
try {
mapPointsService.UpdateMapPoint(mapPoint);
} catch (Exception e) {
Toast.makeText(mContext, "操作失误", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
Toast.makeText(mContext, "开始采集!", Toast.LENGTH_LONG).show();
}
}
});
//采集结束
btn_stopcollect = (Button) findViewById(R.id.btn_stopcollect);
btn_stopcollect.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
collectStartGps = false;
if(dbLatitude.equals(0.0) || dbLongitude.equals(0.0)){
Toast.makeText(mContext, "操作失误", Toast.LENGTH_LONG).show();
}else{
MapPoints mapPoint = new MapPoints();
mapPoint.setCreateDate(DateUtil.getStringDate());
mapPoint.setPointLat(dbLatitude);
mapPoint.setPointLong(dbLongitude);
mapPoint.setPointName(endpointName);
try {
mapPointsService.UpdateMapPoint(mapPoint);
} catch (Exception e) {
Toast.makeText(mContext, "操作失误", Toast.LENGTH_LONG).show();
e.printStackTrace();
}
Toast.makeText(mContext, "结束采集!", Toast.LENGTH_LONG).show();}
}
});
}
//加载地图经纬度数据源
private void initData(){
//导航点ID
if(sp_endPoint.getCount() > 0){
int mappointID = ((SP_Dict) sp_endPoint.getSelectedItem()).getId();
//路线ID
try {
int maproutID = mapRouteService.SeeMapRoute(mappointID).getMapRouteID();
mapLongLatList = mapLongLatService.getMapLongLats(maproutID);
} catch (Exception e) {
e.printStackTrace();
}
}
}
//Bind 目的地列表
private void endpointsBind(){
try {
List<SP_Dict> mapPoints = mapPointsService.SeeMapPointList(POINTTYPEEND);
sp_endPoint.setList((ArrayList<SP_Dict>)mapPoints);
ArrayAdapter<SP_Dict> mapPointAdapter = new ArrayAdapter<SP_Dict>(this,android.R.layout.simple_spinner_item, mapPoints);
sp_endPoint.setAdapter(mapPointAdapter);
} catch (Exception e) {
Toast.makeText(mContext, "系统错误", Toast.LENGTH_SHORT).show();
}
}
/**
* 绘制折线,该折线状态随地图状态变化
* @return 折线对象
*/
private Graphic drawLine(List<MapLongLat> mapLongLats){
//构建线
Geometry lineGeometry = new Geometry();
int counts = mapLongLats.size();
//设定折线点坐标
GeoPoint[] linePoints = new GeoPoint[counts];
for(int i =0 ;i<counts;i++){
linePoints[i] = mapLongLats.get(i).getGeopoint();
}
lineGeometry.setPolyLine(linePoints);
//设定样式
Symbol lineSymbol = new Symbol();
Symbol.Color lineColor = lineSymbol.new Color();
lineColor.red = 255;
lineColor.green = 0;
lineColor.blue = 0;
lineColor.alpha = 255;
lineSymbol.setLineSymbol(lineColor, 10);
//生成Graphic对象
Graphic lineGraphic = new Graphic(lineGeometry, lineSymbol);
return lineGraphic;
}
/**
* 绘制路线
*
* @param List
* <PillarGeo>
* */
private void getRoute(List<MapLongLat> mapLongLatList) {
// 用站点数据构建一个MKRoute
MKRoute route = new MKRoute();
// 起点坐标
GeoPoint start = mapLongLatList.get(0).getGeopoint();
// 终点坐标
GeoPoint stop = mapLongLatList.get((mapLongLatList.size() - 1)).getGeopoint();
int size = mapLongLatList.size();
GeoPoint[][] routeData = new GeoPoint[1][];
GeoPoint[] step = new GeoPoint[size];
for (int i = 0; i < mapLongLatList.size(); i++) {
step[i] = mapLongLatList.get(i).getGeopoint();
}
routeData[0] = step;
route.customizeRoute(start, stop, routeData);
RouteOverlay routeOverlay = new RouteOverlay(MapNaviActivity.this, mMapView);
routeOverlay.setData(route);
//向地图添加构造好的RouteOverlay
mMapView.getOverlays().add(routeOverlay);
//执行刷新使生效
mMapView.refresh();
}
/**
* 将自定义线条和关键点图标加载到地图上
*
* */
private void initOverlay(){
GraphicsOverlay graphicsOverlay = new GraphicsOverlay(mMapView);
mMapView.getOverlays().add(graphicsOverlay);
}
private void initMap(){
// 地图初始化
mMapView = (MapView) findViewById(R.id.bmapView);
// 实例化地图控制器
mMapController = mMapView.getController();
mMapController.setZoom(14);
mMapController.enableClick(true);
mMapView.setBuiltInZoomControls(true);
// 定位初始化
locData = new LocationData();
mLocationClient = new LocationClient(getApplicationContext());
LocationClientOption option = new LocationClientOption();
option.setOpenGps(true);// 打开gps
option.setCoorType("bd09ll"); // 设置坐标类型
option.setScanSpan(1000);
option.setAddrType("false");//返回的定位结果包含地址信息
option.setPriority(LocationClientOption.GpsFirst);//GPS优先
mLocationClient.setLocOption(option);
mLocationClient.registerLocationListener(myListener);
mLocationClient.start();
// 定位图层初始化
myLocationOverlay = new locationOverlay(mMapView);
// 设置定位数据
myLocationOverlay.setData(locData);
// 添加定位图层
mMapView.getOverlays().add(myLocationOverlay);
myLocationOverlay.enableCompass();
//修改定位数据后刷新图层生效
mMapView.refresh();
}
/**
* BDLocationListener接口有2个方法需要实现: 1.接收异步返回的定位结果,参数是BDLocation类型参数。
* 2.接收异步返回的POI查询结果,参数是BDLocation类型参数。
*
*/
public class MyLocationListener implements BDLocationListener {
@Override
public void onReceiveLocation(BDLocation location) {
if (location == null)
return;
locData.latitude = location.getLatitude();
locData.longitude = location.getLongitude();
dbLatitude = location.getLatitude();
dbLongitude = location.getLongitude();
if(collectStartGps){
try {
MapRoute mapRoute = mapRouteService.SeeMapRoute(endpointID);
int maprouteID = mapRoute.getMapRouteID();
MapLongLat mapLongLat = new MapLongLat();
mapLongLat.setLatitude(dbLatitude);
mapLongLat.setLongitude(dbLongitude);
mapLongLat.setMapRouteID(maprouteID);
mapLongLatService.AddMapLongLat(mapLongLat);
} catch (Exception e) {
Toast.makeText(mContext, "经纬度采集失败", Toast.LENGTH_LONG).show();
}
}
// 如果不显示定位精度圈,将accuracy赋值为0即可
locData.accuracy = location.getRadius();
// 此处可以设置 locData的方向信息, 如果定位 SDK 未返回方向信息,用户可以自己实现罗盘功能添加方向信息。
locData.direction = location.getDerect();
if (myLocationOverlay == null) {
myLocationOverlay = new locationOverlay(mMapView);
// 添加定位图层
mMapView.getOverlays().add(myLocationOverlay);
myLocationOverlay.enableCompass();
}
// 更新定位数据
myLocationOverlay.setData(locData);
mMapController.setCenter(new GeoPoint(
(int) (locData.latitude * 1e6),
(int) (locData.longitude * 1e6)));
// 更新图层数据执行刷新后生效
mMapView.refresh();
// 移动到定位点
mMapController.animateTo(new GeoPoint(
(int) (locData.latitude * 1e6),
(int) (locData.longitude * 1e6)));
}
@Override
public void onReceivePoi(BDLocation arg0) {
}
}
@Override
protected void onDestroy() {
// 退出时销毁定位
if (mLocationClient != null)
mLocationClient.stop();
mMapView.destroy();
super.onDestroy();
}
@Override
protected void onPause() {
mMapView.onPause();
super.onPause();
}
@Override
protected void onResume() {
mMapView.onResume();
super.onResume();
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
mMapView.onSaveInstanceState(outState);
}
@Override
protected void onRestoreInstanceState(Bundle savedInstanceState) {
super.onRestoreInstanceState(savedInstanceState);
mMapView.onRestoreInstanceState(savedInstanceState);
}
public class locationOverlay extends MyLocationOverlay{
public locationOverlay(MapView mapView) {
super(mapView);
}
@Override
protected boolean dispatchTap() {
return true;
}
}
}