定位已经正确了,但是轨迹打点的时候确实在非洲,下面贴了部分代码,使用的是track的地图数据
private void initTrack(){
if (m_Track != null){
// 设置用户传入GPS数据
m_Track.setCustomLocation(true);
// 设置距离间隔为3米
m_Track.setDistanceInterval(3);
// 设置时间间隔为1s
m_Track.setTimeInterval(20);
// 设置匹配道路所在的数据集
m_Track.setMatchDatasets( m_Map.getWorkspace().getDatasources().get("road").getDatasets());
m_Track.setCustomLocation(false);
}
}
/**
* 设置用于轨迹记录的GPS数据
* @param gpsData
*/
public static void setGpsData(LocationManagePlugin.GPSData gpsData){
if(m_Track != null){
//创建point2d
Point2D mPoint = mNavigation.encryptGPS ( gpsData.dLongitude,gpsData.dLatitude );
gpsData.dLongitude = mPoint.getX ();
gpsData.dLatitude = mPoint.getY ();
System.out.println ( gpsData.dLongitude +"?????????????????????????????X");
System.out.println ( gpsData.dLatitude + "????????????????????????????Y");
//地理坐标与投影坐标的转换
PrjCoordSys Prj = m_Map.getPrjCoordSys ();
if (Prj.getType () != PrjCoordSysType.PCS_EARTH_LONGITUDE_LATITUDE) {
Point2Ds points = new Point2Ds ();
points.add ( point2d );
PrjCoordSys desPrjCoorSys = new PrjCoordSys ();
desPrjCoorSys.setType ( PrjCoordSysType.PCS_EARTH_LONGITUDE_LATITUDE );
CoordSysTranslator.convert ( points, desPrjCoorSys, Prj, new CoordSysTransParameter (), CoordSysTransMethod.MTH_GEOCENTRIC_TRANSLATION );
point2d = points.getItem ( 0 );
}
m_Track.setCustomLocation ( false );
m_Track.setGPSData ( gpsData );
count ++;
System.out.println ( "++++++++++++++++++" + count );
}
if(50 == count){
m_Map.refresh ();
count = 0;
}
}
private void track() {
System.out.println("================================6");
Datasource m_Datasource = m_Map.getWorkspace().getDatasources().get("track");
System.out.println("================================7");
m_Layers = m_Map.getLayers();
System.out.println("================================8");
// 创建数据集
DatasetVector dataset = m_Track.createDataset(m_Datasource, "qwe");
System.out.println("================================9");
//设置数据集的投影信息
PrjCoordSys Prj = m_Map.getPrjCoordSys();
if (Prj.getType() != PrjCoordSysType.PCS_EARTH_LONGITUDE_LATITUDE) {
PrjCoordSys desPrjCoorSys = new PrjCoordSys();
desPrjCoorSys.setType(PrjCoordSysType.PCS_EARTH_LONGITUDE_LATITUDE);
dataset.setPrjCoordSys(desPrjCoorSys);
}
//设置轨迹记录的数据集为datas
m_Track.setDataset(dataset);
System.out.println("================================10");
//开始轨迹记录
m_Track.startTrack();
System.out.println("================================11");
clearLayers();
System.out.println("================================12");
//添加在图层轨迹记录的点数据
m_Layers.add(dataset, true);
System.out.println("================================13");
System.out.println(dataset + "****************************dataset");
m_EnableLocationService = false;
System.out.println("================================14");
//刷新地图
m_Map.refresh();
System.out.println("================================15");
//开启定位
mylocation ();
}