Java Code Examples for com.baidu.mapapi.map.MapView#getMap()

The following examples show how to use com.baidu.mapapi.map.MapView#getMap() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From Study_Android_Demo with Apache License 2.0 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    //初始化地图控件
    mapView = (MapView) findViewById(R.id.mapview);

    mBaiduMap = mapView.getMap();
    //初始化定位
    mLocationClient = new LocationClient(getApplicationContext());
    //初始化定位
    initLocation();
    //注册监听函数
    mLocationClient.registerLocationListener(this);
    //开始定位,定位完成后,不管是否成功,都会调用上面的监听函数中的方法
    mLocationClient.start();

    //设置地图的点击事件
    setMapListenter();


}
 
Example 2
Source File: MainActivity.java    From BaiDuMapSelectDemo with Apache License 2.0 5 votes vote down vote up
private void initMap() {
    mMapView = (MapView) findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();
    mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
    // 开启定位图层
    mBaiduMap.setMyLocationEnabled(true);
}
 
Example 3
Source File: MapPickerActivity.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
private void initMap() {
    //ricky init baidumap begin
    mMapView = (MapView) findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();
    mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
    mMapView.showZoomControls(false);
    MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(17.0f);
    mBaiduMap.setMapStatus(msu);
    mBaiduMap.setOnMapTouchListener(touchListener);
    // 初始化POI信息列表
    mInfoList = new ArrayList<PoiInfo>();
    // 初始化当前MapView中心屏幕坐标,初始化当前地理坐标
    mCenterPoint = mBaiduMap.getMapStatus().targetScreen;
    mLoactionLatLng = mBaiduMap.getMapStatus().target;
    // 定位
    mBaiduMap.setMyLocationEnabled(true);
    // 隐藏百度logo ZoomControl
    int count = mMapView.getChildCount();
    for (int i = 0; i < count; i++) {
        View child = mMapView.getChildAt(i);
        if (child instanceof ImageView || child instanceof ZoomControls) {
            child.setVisibility(View.INVISIBLE);
        }
    }
    // 隐藏比例尺
    //mMapView.showScaleControl(false);
    // 地理编码

    mGeoCoder = GeoCoder.newInstance();
    mGeoCoder.setOnGetGeoCodeResultListener(GeoListener);
    list = (ListView) findViewById(R.id.list);
    list.setOnItemClickListener(this);
    list.setChoiceMode(AbsListView.CHOICE_MODE_SINGLE);
    loading = (ProgressBar) findViewById(R.id.loading);
    status = (TextView) findViewById(R.id.status);
    mAdapter = new MapPickerAdapter(MapPickerActivity.this, mInfoList);
    list.setAdapter(mAdapter);
}
 
Example 4
Source File: MainActivity.java    From VirtualLocation with Apache License 2.0 5 votes vote down vote up
@Override
protected void IniView() {
    bt_Ok = (Button) findViewById(R.id.bt_Ok);
    tv_location = (TextView) findViewById(R.id.tv_location);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.dl_left);
    mTopbanner = (TopBanner) findViewById(R.id.topbanner);
    mAboutAuthor = (TextView) findViewById(R.id.tv_about_me);
    mCurrentLocation = (ImageView)findViewById(R.id.iv_location);
    mStopMock = (ImageView)findViewById(R.id.iv_stop_location);
    mPreciseLocation = (TextView)findViewById(R.id.tv_precise);
    mAddProcess = (TextView) findViewById(R.id.tv_add_app);
    //加载旋转动画
    mOperatingAnim = AnimationUtils.loadAnimation(this, R.anim.spinloaing);
    LinearInterpolator lin = new LinearInterpolator();

    mOperatingAnim.setInterpolator(lin);
    // 地图初始化
    mMapView = (MapView) findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();
    // 开启定位图层
    mBaiduMap.setMyLocationEnabled(true);
    //隐藏地图比例尺
    mMapView.showScaleControl(false);
    //关闭缩放放大控件
    mMapView.showZoomControls(false);
    mMapView.removeViewAt(1);
    // 定位初始化
    mLocClient = new LocationClient(this);
}
 
Example 5
Source File: NearbyGroupWithRedPocketMapViewActivity.java    From Social with Apache License 2.0 5 votes vote down vote up
private void initView(){
    infos = new ArrayList<RedPocketGroup>();

    fab_home = (FloatingActionButton)this.findViewById(R.id.id_nearby_group_with_redpocket_mapview_activity_fab_home);
    fab_home.setOnClickListener(this);

    if (is_first_page==1){
        fab_home.setVisibility(View.GONE);
    }else{
        fab_home.setVisibility(View.VISIBLE);
    }

    mapView = (MapView)this.findViewById(R.id.id_nearby_group_with_redpocket_mapview_activity_mapview);
    mBaiduMap  = mapView.getMap();

    rl_mark_info_container = (RelativeLayout)this.findViewById(R.id.id_nearby_group_with_redpocket_mapview_activity_mark_info_windows);
    rl_mark_info_container.setVisibility(View.INVISIBLE);

    mBaiduMap.setOnMapClickListener(new BaiduMap.OnMapClickListener() {
        @Override
        public void onMapClick(LatLng latLng) {
            rl_mark_info_container.setVisibility(View.INVISIBLE);
        }

        @Override
        public boolean onMapPoiClick(MapPoi mapPoi) {
            return false;
        }
    });
}
 
Example 6
Source File: MapActivity.java    From BaiduMap-TrafficAssistant with MIT License 5 votes vote down vote up
private void initView() {
	// 获取地图控件引用
	mMapView = (MapView) findViewById(R.id.bmapView);
	// 改变显示的比例尺
	mBaiduMap = mMapView.getMap();
	MapStatusUpdate after = MapStatusUpdateFactory.zoomTo(15.0f);
	mBaiduMap.setMapStatus(after);

}
 
Example 7
Source File: LocationActivity.java    From Conquer with Apache License 2.0 5 votes vote down vote up
private void initBaiduMap() {
	// 地图初始化
	mMapView = (MapView) findViewById(R.id.bmapView);
	mBaiduMap = mMapView.getMap();
	// 设置缩放级别
	mBaiduMap.setMaxAndMinZoomLevel(18, 13);
	// 注册 SDK 广播监听者
	IntentFilter iFilter = new IntentFilter();
	iFilter.addAction(SDKInitializer.SDK_BROADTCAST_ACTION_STRING_PERMISSION_CHECK_ERROR);
	iFilter.addAction(SDKInitializer.SDK_BROADCAST_ACTION_STRING_NETWORK_ERROR);
	mReceiver = new BaiduReceiver();
	registerReceiver(mReceiver, iFilter);

	Intent intent = getIntent();
	String type = intent.getStringExtra("type");
	if (type.equals("select")) {// 选择发送位置
		// initTopBarForBoth("位置", R.drawable.btn_login_selector, "发送", new
		// onRightImageButtonClickListener() {
		// @Override
		// public void onClick() {
		// // TODO Auto-generated method stub
		// gotoChatPage();
		// }
		// });
		// mHeaderLayout.getRightImageButton().setEnabled(false);
		initLocClient();
	} else {// 查看当前位置
		// initTopBarForLeft("位置");
		Bundle b = intent.getExtras();
		LatLng latlng = new LatLng(b.getDouble("latitude"), b.getDouble("longtitude"));// 维度在前,经度在后
		mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLng(latlng));
		// 显示当前位置图标
		OverlayOptions ooA = new MarkerOptions().position(latlng).icon(bdgeo).zIndex(9);
		mBaiduMap.addOverlay(ooA);
	}

	mSearch = GeoCoder.newInstance();
	mSearch.setOnGetGeoCodeResultListener(this);

}
 
Example 8
Source File: RouteDetailActivity.java    From Mobike with Apache License 2.0 4 votes vote down vote up
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_route_detail);
    route_detail_mapview = (MapView) findViewById(R.id.route_detail_mapview);
    total_time = (TextView) findViewById(R.id.total_time);
    total_distance = (TextView) findViewById(R.id.total_distance);
    total_price = (TextView) findViewById(R.id.total_pricce);
    routeBaiduMap = route_detail_mapview.getMap();
    route_detail_mapview.showZoomControls(false);
    startBmp = BitmapDescriptorFactory.fromResource(R.mipmap.route_start);
    endBmp = BitmapDescriptorFactory.fromResource(R.mipmap.route_end);
    initMap();

    Intent intent = getIntent();
    String time = intent.getStringExtra("totalTime");
    String distance = intent.getStringExtra("totalDistance");
    String price = intent.getStringExtra("totalPrice");
    routePointsStr = intent.getStringExtra("routePoints");
    routePoints = new Gson().fromJson(routePointsStr, new TypeToken<List<RoutePoint>>() {
    }.getType());

    savaDatas(time,distance,price);//yiwen add

    List<LatLng> points = new ArrayList<LatLng>();

    for (int i = 0; i < routePoints.size(); i++) {
        RoutePoint point = routePoints.get(i);
        LatLng latLng = new LatLng(point.getRouteLat(), point.getRouteLng());
        Log.d("gaolei", "point.getRouteLat()----show-----" + point.getRouteLat());
        Log.d("gaolei", "point.getRouteLng()----show-----" + point.getRouteLng());
        points.add(latLng);
    }
    if (points.size() > 2) {
        OverlayOptions ooPolyline = new PolylineOptions().width(10)
                .color(0xFF36D19D).points(points);
        routeBaiduMap.addOverlay(ooPolyline);
        RoutePoint startPoint = routePoints.get(0);
        LatLng startPosition = new LatLng(startPoint.getRouteLat(), startPoint.getRouteLng());

        MapStatus.Builder builder = new MapStatus.Builder();
        builder.target(startPosition).zoom(18.0f);
        routeBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build()));

        RoutePoint endPoint = routePoints.get(routePoints.size() - 1);
        LatLng endPosition = new LatLng(endPoint.getRouteLat(), endPoint.getRouteLng());
        addOverLayout(startPosition, endPosition);
    }

    total_time.setText("骑行时长:" + time + "分钟");
    total_distance.setText("骑行距离:" + distance + "米");
    total_price.setText("余额支付:" + price + "元");


}
 
Example 9
Source File: MainActivity.java    From MoveMapLocation with Apache License 2.0 4 votes vote down vote up
private void initView() {
    mMapView = (MapView) findViewById(R.id.main_bdmap);
    mBaiduMap = mMapView.getMap();

    poisLL = (ListView) findViewById(R.id.main_pois);

    topRL = (RelativeLayout) findViewById(R.id.main_top_RL);

    searchAddress = (EditText) findViewById(R.id.main_search_address);

    searchPois = (ListView) findViewById(R.id.main_search_pois);

    //定义地图状态
    MapStatus mMapStatus = new MapStatus.Builder().zoom(18).build();
    MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory.newMapStatus(mMapStatus);
    //改变地图状态
    mBaiduMap.setMapStatus(mMapStatusUpdate);

    //地图状态改变相关监听
    mBaiduMap.setOnMapStatusChangeListener(this);

    //开启定位图层
    mBaiduMap.setMyLocationEnabled(true);

    //定位图层显示方式
    mCurrentMode = MyLocationConfiguration.LocationMode.NORMAL;

    /**
     * 设置定位图层配置信息,只有先允许定位图层后设置定位图层配置信息才会生效
     * customMarker用户自定义定位图标
     * enableDirection是否允许显示方向信息
     * locationMode定位图层显示方式
     */
    mBaiduMap.setMyLocationConfigeration(new MyLocationConfiguration(mCurrentMode, true, null));

    //初始化定位
    mLocClient = new LocationClient(this);
    //注册定位监听
    mLocClient.registerLocationListener(this);

    //定位选项
    LocationClientOption option = new LocationClientOption();
    /**
     * coorType - 取值有3个:
     * 返回国测局经纬度坐标系:gcj02
     * 返回百度墨卡托坐标系 :bd09
     * 返回百度经纬度坐标系 :bd09ll
     */
    option.setCoorType("bd09ll");
    //设置是否需要地址信息,默认为无地址
    option.setIsNeedAddress(true);
    //设置是否需要返回位置语义化信息,可以在BDLocation.getLocationDescribe()中得到数据,ex:"在天安门附近", 可以用作地址信息的补充
    option.setIsNeedLocationDescribe(true);
    //设置是否需要返回位置POI信息,可以在BDLocation.getPoiList()中得到数据
    option.setIsNeedLocationPoiList(true);
    /**
     * 设置定位模式
     * Battery_Saving
     * 低功耗模式
     * Device_Sensors
     * 仅设备(Gps)模式
     * Hight_Accuracy
     * 高精度模式
     */
    option.setLocationMode(LocationClientOption.LocationMode.Hight_Accuracy);
    //设置是否打开gps进行定位
    option.setOpenGps(true);
    //设置扫描间隔,单位是毫秒 当<1000(1s)时,定时定位无效
    option.setScanSpan(1000);

    //设置 LocationClientOption
    mLocClient.setLocOption(option);

    //开始定位
    mLocClient.start();

}