android中使用百度地图绘制弹出框的覆盖物
这几天在项目中引入了百度地图,实现的功能就是类似美团的地图查看周边团购那样的功能,实现的弹出框布局要比美团复杂一些。
下面直接上代码:
通过这个方法在指定的坐标创建一个覆盖物
mBaiduMap.setOnMarkerClickListener(new BaiduMap.OnMarkerClickListener() {@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)@Override public boolean onMarkerClick(Marker marker) {LatLng latLng = marker.getPosition();showWindow(latLng.latitude,latLng.longitude);return true;} });
然后通过showWindow方法实现弹出框
private void showWindow(double latitude,double longitude){try {for (int i = 0, n = list_data.size(); i < n; i++) {if (Double.parseDouble(list_data.get(i).get("lat").toString()) == latitude &&Double.parseDouble(list_data.get(i).get("lng").toString()) == longitude) {NearListBean nearListBean=null;if(convertView ==null) {convertView = LayoutInflater.from(getApplicationContext()).inflate(R.layout.near_map_item, null);nearListBean = new NearListBean();nearListBean.pic = (RoundRectImageView) convertView.findViewById(R.id.near_list_item_pic);nearListBean.title = (TextView) convertView.findViewById(R.id.near_list_item_title);nearListBean.time = (TextView) convertView.findViewById(R.id.near_list_item_time);nearListBean.priceSymbol = (TextView) convertView.findViewById(R.id.near_list_item_price_symbol);nearListBean.price = (TextView) convertView.findViewById(R.id.near_list_item_price);nearListBean.endtime = (TextView) convertView.findViewById(R.id.near_list_item_endtime);nearListBean.age = (TextView) convertView.findViewById(R.id.near_list_item_age);nearListBean.distance = (TextView) convertView.findViewById(R.id.near_list_item_distance);convertView.setTag(nearListBean);}else{nearListBean= (NearListBean) convertView.getTag();}//homeListBean.img.setImageResource((Integer)mData.get(position).get("img")); AsynImageLoader asynImageLoader = new AsynImageLoader();asynImageLoader.showImageAsyn(nearListBean.pic, list_data.get(i).get("pic").toString(), R.drawable.message);//imageLoader.DisplayImage(list_data.get(i).get("pic").toString(), nearListBean.pic); nearListBean.title.setText(list_data.get(i).get("title").toString());nearListBean.time.setText(list_data.get(i).get("startTime").toString());String price= list_data.get(i).get("price").toString();if(price.indexOf("免费") ==-1) {nearListBean.priceSymbol.setText("¥");nearListBean.price.setText(price.substring(1, price.length()));}else{nearListBean.priceSymbol.setText("");nearListBean.price.setText(price);}nearListBean.distance.setText("<"+list_data.get(i).get("distance").toString());nearListBean.age.setText(list_data.get(i).get("age").toString());SimpleDateFormat format=new SimpleDateFormat("yyyy-MM-dd HH:mm");nearListBean.endtime.setText(DateUtil.dateDiff(format.format(new Date()),list_data.get(i).get("applyend").toString(),"yyyy-MM-dd HH:mm"));//定义用于显示该InfoWindow的坐标点 LatLng pt = new LatLng(latitude, longitude);//创建InfoWindow , 传入 view, 地理坐标, y 轴偏移量 InfoWindow mInfoWindow = new InfoWindow(convertView, pt, -78);//显示InfoWindow mBaiduMap.showInfoWindow(mInfoWindow);index=i;convertView.setOnClickListener(new View.OnClickListener() {@Override public void onClick(View v) {Intent intent = new Intent(NearMapActivity.this, ActivityDetailActivity.class);intent.putExtra("activityId",(int)Float.parseFloat(list_data.get(index).get("activityId").toString()));startActivity(intent);}});break;}}}catch (Exception e){e.printStackTrace();} }
这里其实跟listview添加item基本一样的,这里的的布局文件的长宽写死了,不然会被压缩。
android中使用百度地图绘制弹出框的覆盖物相关推荐
- 百度地图自定义吹出框
2019独角兽企业重金招聘Python工程师标准>>> 百度地图自定义吹出框 直入正题吧! 这些都是知道的了,看文档添加就行了! 实现三个代理方法: 这个方法类似tableview添 ...
- html百度地图中心点不正确,百度地图嵌入弹出层,无法准确正确显示marker标记到中心位置的问题...
最近同事遇到了一个问题,找我帮忙,先说下情况: 1,页面中有一个弹出框,也就是弹出层,弹出层里面的html是实用table, 其中一个tr中使用div作为百度地图的容器 如图: 2,打开弹出层后,根据 ...
- android 微信点赞功能,Android 仿微信点赞和评论弹出框
wjntekaqskfhwktpgpvzhp 1. 微信弹出框 微信朋友圈的点赞和评论功能,有2个组成部分: 左下角的"更多"按钮: 点击该按钮后弹出的对话框: 微信朋友圈点赞和评 ...
- Android 仿微信点赞和评论弹出框
下载源码:http://download.csdn.net/detail/zhaizu/9790030 本文简单模仿微信朋友圈的点赞和评论弹出框,布局等细节请忽略,着重实现弹出框.发评论,及弹出位置的 ...
- Android仿IOS封装通用的弹出框Dialog和底部弹出列表选择框 仿美团顶部条件筛选框 附自定义ViewGroup
弹出框 背景 提示与询问弹出框 实现 使用 列表选择框 实现 使用 顶部条件筛选框 实现 自定义ViewGroup 使用 总结 背景 鉴于Android提供的默认弹出框很一般,IOS的弹出框样式还不错 ...
- 【Popover 弹出框】在vue中,ElmentUI下Popover 弹出框组件 “ 自定义样式修改不了 ” 的解决方法
通过 /deep/ 深层查找并不能找到相关的元素,查找原因发现此组件的样式是全局样式,如果你style中加了scoped,如<style lang="scss" scoped ...
- android 气球菜单,jQuery实现气球弹出框式的侧边导航菜单效果
本文实例讲述了jQuery实现气球弹出框式的侧边导航菜单效果.分享给大家供大家参考.具体如下: 这是一款基于jQuery实现的气球弹出框式的侧边导航菜单,预览效果时左下角会提示错误,而且看不到效果,刷 ...
- android 百度地图覆盖物popupwindow自动弹出,android实现百度地图自定义弹出窗口功能...
public class MyPopupOverlay extends ItemizedOverlay { private Context context = null; // 这是弹出窗口, 包括内 ...
- Android中应用百度地图API开发地图APP实例-显示百度地图
场景 效果 在使用百度地图API之前需要先在百度地图开放平台中申请API_KEY http://lbsyun.baidu.com/index.php 申请API_KEY 登录百度开放平台后找到控制台下 ...
最新文章
- OO实现ALV TABLE 八:ALV的布局功能
- VTK:图片之ImageMask
- 论文浅尝 - 计算机工程 | 知识图谱可视化查询技术综述
- 计算机常用工具软件教案,常用工具软件教案.doc
- plsql developer连接oracle--本地不安装oracle
- 2015年《大数据》高被引论文Top10文章No.2——大数据时代的数据挖掘 —— 从应用的角度看大数据挖掘(上)...
- 数据库索引优化原理,索引的工作机制
- 2018年小米竟发布了16款手机,然而最值得入手的是它!
- Tornado之异步authenticated
- visual studio 设计器不显示_嫦娥上升器为什么不设计成月球勘测器?
- c/c++常见关键字
- NB50/60 TJ1/TK1 模具 黑苹果保姆级教程整理
- 5G+智慧矿山系统如何降低开发成本
- php 取字符串任意两个的中间部分,掐头去尾
- fulltext全文索引的使用
- 抖音SEO,抖音SEO搜索排名详细介绍
- CSS图片阴影+鼠标移上图片放大、变形
- 【C++】1048:有一门课不及格的学生(信息学奥赛)
- 解决安装VC6.0后出现MSDEV.EXE错误,无法用打开工程解决方法
- LORA模块初始化失败
热门文章
- Android开发——蓝牙配对自动设置PIN
- openlayer4中,地图通过extent缩放至范围。
- Extent Reports (cdn.rawgit.com墙)样式加载不到解法
- English Learning - L1-6 从此口语变得简约(下)2022.12.22 周四
- Oracle网络TNS协议介绍(revised)
- mysql8 servertime_MySql的时区(serverTimezone)引发的血案
- 深度学习:基于TensorFlow的双层BiDirection_Attention_LSTM的北京PM2.5数据集预测
- 谁还不是在职场中寻寻觅觅
- 2022 RoboCom 世界机器人开发者大赛-本科组(省赛)RC-u4 攻略分队 (已完结)
- javaweb JAVA JSP记账管理系统财务管理系统(个人理财系统个人财务管理系统