如何在百度地图上画线,如何在地图上画直线
答案:1 悬赏:80 手机版
解决时间 2021-05-06 02:06
- 提问者网友:活着好累
- 2021-05-05 20:55
如何在百度地图上画线,如何在地图上画直线
最佳答案
- 五星知识达人网友:由着我着迷
- 2021-05-05 22:17
public Graphic drawLine(){
int lat = (int) (m.getLatitudeE6());
int lon = (int) (m.getLongitudeE6());
GeoPoint pt1 = new GeoPoint(lat, lon); //取得第一点坐标lat = (int) (n.getLatitudeE6());
lon = (int) (n.getLongitudeE6());
GeoPoint pt2 = new GeoPoint(lat, lon); //取得第二点坐标
//构建线
Geometry lineGeometry = new Geometry();
GeoPoint[] linePoints = new GeoPoint[2]; //定义一个坐标数组
linePoints[0] = pt1;
linePoints[1] = pt2;
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; //设置颜色的alpha值
lineSymbol.setLineSymbol(lineColor, 5);
//生成Graphic对象
Graphic lineGraphic = new Graphic(lineGeometry, lineSymbol);
return lineGraphic;
}
你好,m和n分别是点击的第一点和第二点 m = mMapView1.getProjection().fromPixels(((int)e.getX()), ((int)e.getY()));
n = mMapView1.getProjection().fromPixels(((int)e.getX()), ((int)e.getY())); 请问这样写有问题吗?谢谢!
int lat = (int) (m.getLatitudeE6());
int lon = (int) (m.getLongitudeE6());
GeoPoint pt1 = new GeoPoint(lat, lon); //取得第一点坐标lat = (int) (n.getLatitudeE6());
lon = (int) (n.getLongitudeE6());
GeoPoint pt2 = new GeoPoint(lat, lon); //取得第二点坐标
//构建线
Geometry lineGeometry = new Geometry();
GeoPoint[] linePoints = new GeoPoint[2]; //定义一个坐标数组
linePoints[0] = pt1;
linePoints[1] = pt2;
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; //设置颜色的alpha值
lineSymbol.setLineSymbol(lineColor, 5);
//生成Graphic对象
Graphic lineGraphic = new Graphic(lineGeometry, lineSymbol);
return lineGraphic;
}
你好,m和n分别是点击的第一点和第二点 m = mMapView1.getProjection().fromPixels(((int)e.getX()), ((int)e.getY()));
n = mMapView1.getProjection().fromPixels(((int)e.getX()), ((int)e.getY())); 请问这样写有问题吗?谢谢!
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯