//轨迹坐标
private int geoPoint[][] = {{118099893, 24444963},
{118099888, 24444757}, {118099830, 24444400},
{118099722, 24443947}, {118099641, 24443437},
{118099502, 24443022}, {118099489, 24443014},
{118099085, 24442393}, {118098797, 24441986},
{118098680, 24441797}, {118099444, 24441320},
{118100989, 24440411}, {118101995, 24439667},
{118104016, 24439222}, {118105453, 24439190},
{118106882, 24439103}, {118108836, 24438758},
{118109837, 24438314}, {118112191, 24437536},
{118112191, 24437536}, {118113992, 24436895},
{118116143, 24435986}, {118117706, 24435620},
{118119512, 24435242}, {118120931, 24434970},
{118120945, 24435044}, {118121044, 24435916},
{118121286, 24437857}, {118121502, 24438680},
{118122023, 24439420}, {118122427, 24439740},
{118123913, 24440649}, {118122705, 24441928},};
/**
* 轨迹回放
*/
private void drawLine() {
mViewBtn.mMapView.getController().setZoom(17);
graphicsOverlay = new GraphicsOverlay(mViewBtn.mMapView);
mViewBtn.mMapView.getOverlays().add(graphicsOverlay);
GeoPoint pt1, pt2, pt3 = null;
for (int i = 0; i < 32; i = i + 2) {
if (i != 0) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
int lon = geoPoint[i][0];
int lat = geoPoint[i][1];
pt1 = new GeoPoint(lat, lon);
if (i == 0) {//标记起点
setMarker(pt1,2);
}
lon = geoPoint[i + 1][0];
lat = geoPoint[i + 1][1];
pt2 = new GeoPoint(lat, lon);
lon = geoPoint[i + 2][0];
lat = geoPoint[i + 2][1];
pt3 = new GeoPoint(lat, lon);
//构建线
Geometry lineGeometry = new Geometry();
//设定折线点坐标
GeoPoint[] linePoints = new GeoPoint[3];
linePoints[0] = pt1;
linePoints[1] = pt2;
linePoints[2] = pt3;
lineGeometry.setPolyLine(linePoints);
//设定样式
Symbol lineSymbol = new Symbol();
Symbol.Color lineColor = lineSymbol.new Color();
lineColor.red = 0;
lineColor.green = 0;
lineColor.blue = 255;
lineColor.alpha = 126;
lineSymbol.setLineSymbol(lineColor, 10);
//生成Graphic对象
Graphic lineGraphic = new Graphic(lineGeometry, lineSymbol);
graphicsOverlay.setData(lineGraphic);
mViewBtn.mMapView.refresh();
mViewBtn.mMapView.getController().animateTo(pt3);
}
setMarker(pt3,3);//标记终点
}