使用百度地图SDK 这是之前版本 现在的sdk v2-1-2使用方法完全改变
2024-10-22 04:48:34
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;
}
}
最新文章
- 麦软社区Mindmanager现金抵用券使用流程
- log4net详解(转载)
- 【AT91SAM3S】ADC中断方式采集数据
- CentOS 7下源码安装MySQL 5.7
- php中英文截取无乱码 包括全角下的字符
- Spring JdbcTemplate的queryForList(String sql , Class<;T>; elementType)易错使用--转载
- JavaScript之简易计算器
- 《Programming WPF》翻译 第9章 5.默认可视化
- EclipseEE导入项目出现的那些问题
- MySQL查询1
- Python学习之路基础篇--05Python基础+列表和元组
- WPF设置软件界面背景为MediaElement并播放视频
- 收藏一个带动画效果的ScrollViewer以及ScrollBar的模板
- NoSQL还是SQL?这一篇讲清楚
- logback身份证脱敏
- yyyy-MM-dd&#39;T&#39;HH:mm:ss.SSS&#39;Z&#39;即UTC时间,与String日期转换
- hdu-1394(线段树&;逆序数的性质和求法)
- Code Igniter数据库操作函数大全
- servlet类
- Eclipse 安装更多版本SDK