1、添加BMapApiDemoApp.java

2、AndroidManifest文件 application里添加 android:name=".ui.BMapApiDemoApp"

    <application android:icon="@drawable/ic_launcher"            android:label="@string/app_name"            android:name=".ui.BMapApiDemoApp"             android:debuggable="true">

3、xml 布局文件里添加

 <com.baidu.mapapi.MapView             android:id="@+id/MapViewStoreInfo"            android:layout_width="fill_parent"             android:layout_height="100dip"             android:clickable="true"/>

4、java文件 继承MapActivity

override onPause、onResume、isRouteDisplayed等函数

5、初始化地图、添加标记物

 private void initMap() {        app = (BMapApiDemoApp) this.getApplication();        if (app.mBMapMan == null) {            app.mBMapMan = new BMapManager(getApplication());            app.mBMapMan.init(app.mStrKey,                    new BMapApiDemoApp.MyGeneralListener());        }        app.mBMapMan.start();        // 如果使用地图SDK,请初始化地图Activity        super.initMapActivity(app.mBMapMan);            MapViewStoreInfo.getController().setCenter(setMapCenter());        marker = getResources().getDrawable(                R.drawable.map_marker); // 得到需要标在地图上的资源        marker.setBounds(0, 0, marker.getIntrinsicWidth(),                marker.getIntrinsicHeight()); // 为maker定义位置和边界                MapViewStoreInfo.getOverlays().clear();        MapViewStoreInfo.getOverlays().add(                new OverItemT(marker,StoreInfoActivity.this,setMapCenter()));        MapViewStoreInfo.invalidate();    }

6、下方添加标记物类

class OverItemT extends ItemizedOverlay<OverlayItem>{        private List<OverlayItem> mGeoList = new ArrayList<OverlayItem>();        public OverItemT(Drawable marker, Context context, GeoPoint pt) {            super(boundCenterBottom(marker));                        mGeoList.add(new OverlayItem(pt, "", null));            populate();        }        @Override        protected OverlayItem createItem(int i) {            return mGeoList.get(i);        }        @Override        public int size() {            return mGeoList.size();        }        @Override        public boolean onSnapToItem(int i, int j, Point point, MapView mapview) {            Log.e("ItemizedOverlayDemo","enter onSnapToItem()!");            return false;        }    }

更多相关文章

  1. android studio proguard 混淆微信libammsdk.jar报错
  2. Android: 向最强看齐, 反编译 植物大战僵尸.apk
  3. Android如何设置圆角按钮 类似微信的登陆按钮
  4. Android培训班(38)
  5. 深入剖析ndk配置环境VS简易配置jni流程
  6. Android系统启动流程之Init说明
  7. flutter集成推送功能-小米推送集成
  8. Android内存使用研究
  9. 编译Android(安卓)2.3.1 源代码心得

随机推荐

  1. Use logCat in android native
  2. Android资料整理
  3. android中如何执行java命令
  4. android Intent机制详解
  5. Android节拍器
  6. 【开源项目3】Android快速开源框架--afin
  7. Android官方技术文档翻译——开发工具的
  8. 二阶段之八
  9. Android之Handler
  10. Android(安卓)ApiDemos示例解析(34):App->