android百度地图自定义覆盖物
2015-06-03 12:23
330 查看
android百度地图自定义覆盖物
参考资料
BitmapDescriptorFactory.fromView(view) 报错View, Bitmap, layout与系统底层调用的关系
百度地图中可以使用BitmapDescriptor将view转化为view类View, Bitmap, layout属系统显示高层类,都需要转换为系统底层进行显示。这三者可以使用SDK中的方法进行互相转换,转换时需要注意系统资源占用问题。
注意的问题
使用LinearLayout进行转换,具体可能是百度SDK的bug注意不要把经纬度传反了!!!!
代码
public void setOverlays(ArrayList<Place> places) { int placeNumber = places.size(); for (int i = 0; i < placeNumber; i++) { Place place = places.get(i); LatLng llA = new LatLng(place.getLatitude(), place.getLongitude()); // 初始化覆盖物 View inflatedView = mInflater .inflate(R.layout.map_item_place, null); TextView tvPlaceName = (TextView) inflatedView .findViewById(R.id.tv_place_name); TextView tvMessagesNumber = (TextView) inflatedView .findViewById(R.id.tv_message_number); tvPlaceName.setText(place.getPlaceName()); tvMessagesNumber.setText(place.getCommentsNumber() + "条吐槽"); BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory .fromView(inflatedView); OverlayOptions ooA = new MarkerOptions().position(llA) .icon(bitmapDescriptor).zIndex(9).draggable(true); Marker marker = (Marker) (mBaiduMap.addOverlay(ooA)); Bundle bundle = new Bundle(); bundle.putInt(Constant.PLACE_ITEM_INT, i); marker.setExtraInfo(bundle); mMarkers.add(marker); } }
相关文章推荐
- Android-IntentService
- Android-BoundService
- Android常用自定义控件
- android的m、mm、mmm编译命令的使用
- Android ADB 端口占用问题解决方案
- Android中的Environment.getExternalStorageState使用
- Android Service详解
- 最新Android & iOS设计尺寸规范
- HTML5 web应用打包成android应用
- 注意Android里TextView控件的一个小坑,用android:theme来设置样式时动态载入的layout会丢失该样式
- Android如何区别真机和模拟器
- Android 对Layout_weight属性完全解析以及使用ListView来实现表格(自定义适配器)
- Android Studio常用快捷键
- Android 调用系统的分享[完美实现同时分享图片和文字]
- 【Android笔记】Androd手机拍照或从相册选取图片作为头像
- Android整机源码如何轻松下载?清华大学Android源码镜像
- 【Android】 R.layout.main报错问题
- Android设计模式(三)--装饰模式
- 如何使Android应用程序获得root权限
- Android自定义控件(状态提示图表)