百度地图之自我定位---弹窗

当到了自我定位界面时,会自动弹出一个窗体,百度称它为pupopOverlay,效果图如下:


1、先定义一个窗体

/**
	 * 定位后自动弹出popOverlay窗体
	 * @return void
	 */
		private void initPopupOverLay() {
		    Bitmap[] bmps = new Bitmap[3];
	        try {
	            bmps[0] = BitmapFactory.decodeStream(getResources().getAssets().open("locate_near.png"));
	            bmps[1] = BitmapFactory.decodeStream(getResources().getAssets().open("locate_mylocation.png"));
	            bmps[2] = BitmapFactory.decodeStream(getResources().getAssets().open("locate_route.png"));
	            
	            popup.showPopup(bmps,Geo, 12);//窗体显示在定位中心点上面
	            popupisshow=true;
	            dialog.dismiss();
	            Log.i("initPopupOverLay","popupwindow show");
	        } catch (IOException e) {
	        	Log.i("initPopupOverLay","IOException");
	            e.printStackTrace();
	        }catch(Exception e){
	        	Log.i("initPopupOverLay","Exception");
	            e.printStackTrace();
	        }
		}
2、弹窗中每一个组件单击事件,点击中间“我的位置”显示我的位置,右边是路线规划,左边是周边搜索

 //定义弹出popOverlay窗体及其单击事件
		popup = new PopupOverlay(MyLocation.mMapView,new PopupClickListener() {
			@Override
			public void onClickedPopup(int index) {
				switch(index){
				case 0://单击周边搜索图标
					 Intent intent = new Intent(MyLocation.this, PoiSearch.class);
					 intent.putExtra("MyLocation", true);
					 startActivity(intent);
					 break;
				case 1://单击我的位置图标
					 if(address_msg==null){
						 Toast.makeText(MyLocation.this, "定位服务进行中...", Toast.LENGTH_SHORT).show();
					 }else{
						 Toast.makeText(MyLocation.this, "我的位置:"+address_msg, Toast.LENGTH_SHORT).show();
					 }
					 break;
				case 2://单击线路查询图标
					 intent = new Intent(MyLocation.this, RoutePlan.class);
					 intent.putExtra("MyLocation", ""+address_msg);//将地址信息发给线路查询界面
					 startActivity(intent);
					// popup.hidePop();
					break;
				}
			}
		});


这里顺便提一下,图中底部定位按钮,它响应的事件如下:

 //单击定位按钮事件
		locate=(ImageButton)super.findViewById(R.id.icon_locate);
		locate.setOnClickListener(new OnClickListener(){
			@Override
			public void onClick(View v) {
				Toast.makeText(MyLocation.this,"正在定位中,请稍侯...", Toast.LENGTH_SHORT).show();
				mLocClient.requestLocation(); 
			}
		});
之后会重新定位

安卓市场:http://apk.hiapk.com/html/2013/05/1468059.html?module=256&info=IWjtVg9cqVJLYg%3D%3D
N多市场:http://www.nduoa.com/apk/detail/553415

360手机助手:http://zhushou.360.cn/search/index/?kw=%E6%A0%A1%E5%9B%AD%E5%B0%8F%E5%8A%A9%E6%89%8B

百度应用:http://as.baidu.com/a/item?docid=3101724&pre=web_am_se

优亿市场(eoe):http://www.eoemarket.com/search/apps/?keyword=%E6%A0%A1%E5%9B%AD%E5%B0%8F%E5%8A%A9%E6%89%8B


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值