以dialog的形式弹出定位地图

dialog = new Dialog(context, R.style.dialog);// 自定义dialog宽和高// setDialog();View viewMap = LayoutInflater.from(context).inflate(R.layout.dialog_baidumap, null);iv_close = (ImageView) viewMap.findViewById(R.id.iv_close);mMapView = (MapView) viewMap.findViewById(R.id.mapView);iv_close.setOnClickListener(this);mBaiduMap = mMapView.getMap();dialog.setContentView(viewMap, new LayoutParams(650, 1000));dialog.show();initMap(); // 地图初始化/** * 地图初始化 */private void initMap() {mCurrentMode = LocationMode.NORMAL;// 开启定位图层mBaiduMap.setMyLocationEnabled(true);mMapView.showScaleControl(false);int count = mMapView.getChildCount();for (int i = 0; i < count; i++) {View child = mMapView.getChildAt(i);if (child instanceof ImageView) {// 隐藏百度logochild.setVisibility(View.INVISIBLE);}// 隐藏ZoomControlif (child instanceof ZoomControls) {child.setVisibility(View.INVISIBLE);}}// 定位初始化mLocClient = new LocationClient(this);mLocClient.registerLocationListener(myListener);LocationClientOption option = new LocationClientOption();option.setOpenGps(true);// 打开gpsoption.setCoorType("bd09ll"); // 设置坐标类型option.setScanSpan(1000);mLocClient.setLocOption(option);mLocClient.start();}/** * 定位SDK监听函数 */public class MyLocationListenner implements BDLocationListener {@Overridepublic void onReceiveLocation(BDLocation location) {// map view 销毁后不在处理新接收的位置if (location == null || mMapView == null)return;MyLocationData locData = new MyLocationData.Builder().accuracy(location.getRadius())// 此处设置开发者获取到的方向信息,,顺时针0-360.direction(100).latitude(location.getLatitude()).longitude(location.getLongitude()).build();mBaiduMap.setMyLocationData(locData);if (isFirstLoc) {isFirstLoc = false;LatLng ll = new LatLng(location.getLatitude(),location.getLongitude());MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);mBaiduMap.animateMapStatus(u);}}public void onReceivePoi(BDLocation poiLocation) {}}@Overrideprotected void onDestroy() {super.onDestroy();// 关闭定位if (mMapView != null) {mMapView.onDestroy();mMapView = null;}}

与一个赏心悦目的人错肩,真真实实的活着,也就够了。

以dialog的形式弹出定位地图

相关文章:

你感兴趣的文章:

标签云: