现在部分代码贴上 求高人指点 目前该代码只能实现第一条折线的绘制
在线 苦等。。。。
public void addCustomElementsDemo(){
GraphicsOverlay graphicsOverlay = new GraphicsOverlay(mMapView);
mMapView.getOverlays().add(graphicsOverlay);
//添加折线
graphicsOverlay.setData(drawLine());
//执行地图刷新使生效
mMapView.refresh();
}
public Graphic drawLine(){
String file = getSDPath()+"/pn.xls";
InputStream is = null;
try {
is = new FileInputStream(new File(file));
Workbook wb = Workbook.getWorkbook(is);// 打开Excel文件
Sheet sheet = wb.getSheet(0);// 第一张工作表
int row = sheet.getRows();
for (int i = 1; i < row; ++i) {
Cell calllatA = sheet.getCell(11, i); // 自加获取纬度
Cell calllanA = sheet.getCell(12, i); // 自加获取经度
Cell calllatB = sheet.getCell(13, i); // 自加获取纬度
Cell calllanB = sheet.getCell(14, i); // 自加获取经度
// Cell name = sheet.getCell(1, i);
if(calllatA.getContents() == ""||calllatB.getContents() == "") continue; //判断如果遇空值重新循环
double mlat1 = Double.parseDouble(calllatA.getContents());
double mlon1 = Double.parseDouble(calllanA.getContents());
double mlat2 = Double.parseDouble(calllatB.getContents());
double mlon2 = Double.parseDouble(calllanB.getContents());
GeoPoint p1 = new GeoPoint((int) (mlat1*1E6), (int) (mlon1*1E6));
GeoPoint p2 = new GeoPoint((int) (mlat2*1E6), (int) (mlon2*1E6));
//构建线
Geometry lineGeometry = new Geometry();
//设定折线点坐标
GeoPoint[] linePoints = new GeoPoint[2];
linePoints[0] = p1;
linePoints[1] = p2;
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, 2);
//生成Graphic对象
Graphic lineGraphic = new Graphic(lineGeometry, lineSymbol);
return lineGraphic;
}
mMapView.refresh(); //刷新地图
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
更多0
急求 Android 百度地图 绘制多条折线方法
答案:1 悬赏:40 手机版
解决时间 2021-02-20 06:39
- 提问者网友:那叫心脏的地方装的都是你
- 2021-02-19 06:14
最佳答案
- 五星知识达人网友:零点过十分
- 2021-02-19 06:54
加://设定折线点坐标
GeoPoint[] linePoints = new GeoPoint[4];
linePoints[0] = p1;
linePoints[1] = p2;
lineGeometry.setPolyLine(linePoints);
YOHU.(Exception f)]
GeoPoint[] linePoints = new GeoPoint[4];
linePoints[0] = p1;
linePoints[1] = p2;
lineGeometry.setPolyLine(linePoints);
YOHU.(Exception f)]
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯