android 百度地图上怎么画线,画圆

android 百度地图上怎么画线,画圆,第1张

//代码如下
import androidcontentContext;
import androidgraphicsCanvas;
import androidgraphicsColor;
import androidgraphicsPaint;
import androidgraphicsPaintStyle;
import androidgraphicsPath;
import androidgraphicsPoint;
import androidosBundle;
import combaidumapapiBMapManager;
import combaidumapapiGeoPoint;
import combaidumapapiMapActivity;
import combaidumapapiMapController;
import combaidumapapiMapView;
import combaidumapapiOverlay;
import combaidumapapiProjection;
 
public class BaiduMapActivity extends MapActivity {
        private Context mContext;
        private MapView mapView;
        @Override
        protected boolean isRouteDisplayed() {
                // TODO Auto-generated method stub
                return false;
        }
        private GeoPoint gpoint1, gpoint2, gpoint3;// 连线的点
        @Override
        protected void onCreate(Bundle arg0) {
                superonCreate(arg0);
                setContentView(Rlayoutbaidumap_layout);
 
                BaseApplication baseApp = (BaseApplication) thisgetApplication();
                if (baseAppmBMapManage == null) {
                        baseAppmBMapManage = new BMapManager(mContext);
                        baseAppmBMapManageinit(baseAppmStrKey,
                                        new BaseApplicationMyGeneralListener());
                }
                baseAppmBMapManagestart();
                superinitMapActivity(baseAppmBMapManage);// 初始化map sdk
                mapView = (MapView) findViewById(RidbmapView);
                mapViewsetBuiltInZoomControls(true);
                // 设置在缩放动画过程中也显示overlay,默认为不绘制
                mapViewsetDrawOverlayWhenZooming(true);
 
                // RouteLine routeLine =
                // (RouteLine)getIntent()getSerializableExtra("routeLine");
 
                //这里画点和连接线
                MyOverlay myOverlay = new MyOverlay();
                mapViewgetOverlays()add(myOverlay);
                 
                MapController mapController = mapViewgetController();
                mapControllerzoomIn();
                 
                gpoint1 = new GeoPoint((int) (2259316  10),
                                (int) (11396279  10));
                gpoint2 = new GeoPoint((int) (2259245  10),
                                (int) (11396226  10));
                gpoint3 = new GeoPoint((int) (2259121  10),
                                (int) (11396066  10));                
                mapControlleranimateTo(gpoint1);//设置一个起点
        }
 
        class MyOverlay extends Overlay {
 
                @Override
                public void draw(Canvas canvas, MapView mapView, boolean shadow) {
                        superdraw(canvas, mapView, shadow);
                         
                        Projection projection = mapViewgetProjection();
                        Point p1 = new Point();
                        Point p2 = new Point();
                        Point p3 = new Point();
                        // 经度转像素
                        projectiontoPixels(gpoint1, p1);
                        projectiontoPixels(gpoint2, p2);
                        projectiontoPixels(gpoint3, p3);
                 
                        //第一个画笔 画圆
                        Paint fillPaint = new Paint();
                        fillPaintsetColor(ColorBLUE);
                        fillPaintsetAntiAlias(true);
                        fillPaintsetStyle(StyleFILL);
                         
                        // 将图画到上层
                        canvasdrawCircle(p1x, p1y, 50f, fillPaint);
                        canvasdrawCircle(p2x, p2y, 50f, fillPaint);
                        canvasdrawCircle(p3x, p3y, 50f, fillPaint);
 
                        //第二个画笔 画线
                        Paint paint = new Paint();
                        paintsetColor(ColorBLUE);
                        paintsetDither(true);
                        paintsetStyle(PaintStyleSTROKE);
                        paintsetStrokeJoin(PaintJoinROUND);
                        paintsetStrokeCap(PaintCapROUND);
                        paintsetStrokeWidth(4);
 
                        //连接
                        Path path = new Path();
                        pathmoveTo(p1x, p1y);
                        pathlineTo(p2x, p2y);
                        pathlineTo(p3x, p3y);
                        //画出路径
                        canvasdrawPath(path, paint);
                }
        }
 
}

如果自己手机支持截屏功能的话,直接点击截屏按钮来获取截图,得到截图可在相册中对进行编辑和涂鸦。

使用QQ的摇动手机截屏来获取截图,打开手机QQ,点击设置,进入设置后找到辅助功能,进去以后打开摇动手机截屏即可。(此方法只能在QQ界面截图,其他界面截图需要获取root权限)

在手机软件商城中,下载第三方截图软件来获取截图,然后在截图上画圈。


欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/yw/13337947.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-07-17
下一篇 2023-07-17

发表评论

登录后才能评论

评论列表(0条)

保存