使用百度地图SDK 这是之前版本 现在的sdk v2-1-2使用方法完全改变
2013-06-28 16:17
513 查看
1、添加BMapApiDemoApp.java
2、AndroidManifest文件 application里添加 android:name=".ui.BMapApiDemoApp"
3、xml 布局文件里添加
4、java文件 继承MapActivity
override onPause、onResume、isRouteDisplayed等函数
5、初始化地图、添加标记物
6、下方添加标记物类
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; } }
相关文章推荐
- 谷歌改变其Android版本使用数量计算方法
- 使用的 SQL Server 版本不支持数据类型“date”的解决方法 [转]
- 案例说明stm32官方库函数使用方法 (库版本v3.5, Keil MDK 5)
- Android Studio使用原生反向地址编码方法和使用百度地图SDK的对比以及遇到的问题
- cocoapods的使用,解决pod search出来的仓库版本低于github仓库版本的方法
- idea 使用总结(svn版本控制修改文件颜色改变,自定义字体颜色)
- Qualcomm_Snapdragon_VR_SDK 2.1.1版本简介及使用方法(四)
- vbsedit 安装高版本后不能使用的解决方法
- 在Linux命令行下查询当前所使用的shell版本与种类的方法
- ARX二次开发中使用DAO方式访问数据库,导致AutoCAD2004及以上版本退出时报错的解决方法
- XCode5 使用AutoLayout情况下改变控件的 方法
- 使用JavaScript脚本无法直接改变Asp.net中Checkbox控件的Enable属性的解决方法
- ujsp版本使用方法
- PullScrollView详解(四)——完全使用listview实现下拉回弹(方法一)
- 使用Spring内置拦截器为Struts的Action在每个方法调用之前打印一句话
- 本方法使用于V9.7.06以上版本
- asp.net c#中使用FCKeditor的方法,版本2.66
- phpredis方法在不同版本使用的异常
- VC中使用高版本API的方法——undeclared identifier引发的血案
- xhprof安装和使用方法(linux版本)