import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.Path;
import android.graphics.Point;
import android.os.Bundle;
import com.baidu.mapapi.BMapManager;
import com.baidu.mapapi.GeoPoint;
import com.baidu.mapapi.MapActivity;
import com.baidu.mapapi.MapController;
import com.baidu.mapapi.MapView;
import com.baidu.mapapi.Overlay;
import com.baidu.mapapi.Projection;
public class BaiduMapActivity extends MapActivity {
private Context mContext;
private MapView mapView;
@Override
protected boolean isRouteDisplayed() {
// TODO Auto-generated method stub
return false;
}
@Override
protected void onCreate(Bundle arg0) {
super.onCreate(arg0);
setContentView(R.layout.baidumap_layout);
BaseApplication baseApp = (BaseApplication) this.getApplication();
if (baseApp.mBMapManage == null) {
baseApp.mBMapManage = new BMapManager(mContext);
baseApp.mBMapManage.init(baseApp.mStrKey,
new BaseApplication.MyGeneralListener());
}
baseApp.mBMapManage.start();
super.initMapActivity(baseApp.mBMapManage);// 初始化map sdk
mapView = (MapView) findViewById(R.id.bmapView);
mapView.setBuiltInZoomControls(true);
// 设置在缩放动画过程中也显示overlay,默认为不绘制
mapView.setDrawOverlayWhenZooming(true);
// RouteLine routeLine =
// (RouteLine)getIntent().getSerializableExtra("routeLine");
//这里画点和连接线
MyOverlay myOverlay = new MyOverlay();
mapView.getOverlays().add(myOverlay);
MapController mapController = mapView.getController();
mapController.zoomIn();
mapController.animateTo(new GeoPoint((int) (2259316 * 10),
(int) (11396279 * 10)));//设置一个起点
}
class MyOverlay extends Overlay {
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
super.draw(canvas, mapView, shadow);
Paint paint = new Paint();
paint.setColor(Color.BLUE);
paint.setDither(true);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeCap(Paint.Cap.ROUND);
paint.setStrokeJoin(Paint.Join.ROUND);
paint.setStrokeWidth(5);
Projection projection = mapView.getProjection();
Point p1 = new Point();
projection.toPixels(gpoint1 = new GeoPoint((int) (2259316 * 10), (int) (11396279 * 10)), p1);
canvas.drawCircle(p1.x, p1.y, projection.metersToEquatorPixels(500), paint);
}
}
}
android百度地图半径画圆
原创mb63e0703549da8 博主文章分类:android基础知识 ©著作权
©著作权归作者所有:来自51CTO博客作者mb63e0703549da8的原创作品,请联系作者获取转载授权,否则将追究法律责任
上一篇:动画片儿:鞋子
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
百度云AI
在人工智能的浪潮中,人脸识别技术如同一颗璀璨的明珠,吸引着无数科技爱好者的目光。
百度云 java 人脸识别 -
Android中应用百度地图API开发地图APP实例-显示百度地图
场景效果在使用百度地图API之前需要先在百度地图开放平台中申请API_K
Android android xml -
百度地图的环境搭建(基于百度地图1.3.3)
ml在AndroidManifest.xml中加上以下代码: <sup
android ide 百度地图