com.baidu.mapapi.map.MapView Java Examples

The following examples show how to use com.baidu.mapapi.map.MapView. 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: BaiduMapFragment.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onDestroyView() {
    // 关闭定位图层
    if (null != mBaiduMap) {
        mBaiduMap.hideInfoWindow();
        mBaiduMap.setMyLocationEnabled(false);
    }

    if (null != mMapView) {
        MapView.setMapCustomEnable(false);
        mMapView.onDestroy();
        mMapView = null;
    }

    if (null != mSearchInteracter) {
        mSearchInteracter.destroy();
    }
    if (null != mFavoriteInteracter) {
        mFavoriteInteracter.destroy();
    }

    super.onDestroyView();
}
 
Example #2
Source File: BaiduMapViewManager.java    From BaiduMapKit with MIT License 6 votes vote down vote up
/**
 * 显示地理标记
 *
 * @param mapView
 * @param array
 */
@ReactProp(name="marker")
public void setMarker(MapView mapView, ReadableArray array) {
    Log.d(TAG, "marker:" + array);
    if (array != null) {
        for (int i = 0; i < array.size(); i++) {
            ReadableArray sub = array.getArray(i);
            //定义Maker坐标点
            LatLng point = new LatLng(sub.getDouble(0), sub.getDouble(1));
            //构建Marker图标
            BitmapDescriptor bitmap = BitmapDescriptorFactory.fromResource(R.drawable.icon_gcoding);
            //构建MarkerOption,用于在地图上添加Marker
            OverlayOptions option = new MarkerOptions()
                    .position(point)
                    .icon(bitmap)
                    .draggable(true);
            //在地图上添加Marker,并显示
            mapView.getMap().addOverlay(option);
        }
    }
}
 
Example #3
Source File: BaiduMapRouteFragment.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
private void configMap() {
    ConfigInteracter configInteracter = new ConfigInteracter(getActivity());
    mBaiduMap.getUiSettings().setZoomGesturesEnabled(configInteracter.isZoomGesturesEnabled());
    mBaiduMap.getUiSettings().setOverlookingGesturesEnabled(configInteracter.isOverlookEnable());
    mBaiduMap.getUiSettings().setRotateGesturesEnabled(configInteracter.isRotateEnable());
    mMapView.showScaleControl(configInteracter.isShowScaleControl());
    mBaiduMap.showMapPoi(configInteracter.isMapPoiEnable());
    mBaiduMap.setTrafficEnabled(configInteracter.isTrafficEnable());
    if (configInteracter.getNightMode() == 2){
        MapView.setMapCustomEnable(true);
    }else {
        MapView.setMapCustomEnable(false);
    }
    mMapView.showZoomControls(false);
    mBaiduMap.setMaxAndMinZoomLevel(20f, 3f);
    CoordinatorLayout.LayoutParams params = new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    if (configInteracter.getZoomControlsPosition()) {
        params.rightMargin = AppUtils.dip2Px(getActivity(), 10);
        params.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;
    } else {
        params.leftMargin = AppUtils.dip2Px(getActivity(), 10);
        params.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
    }
    mCardZoom.setLayoutParams(params);

}
 
Example #4
Source File: BaiduMapFragment.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
@Override
public void onDestroyView() {
    // 关闭定位图层
    if (null != mBaiduMap) {
        mBaiduMap.hideInfoWindow();
        mBaiduMap.setMyLocationEnabled(false);
    }

    if (null != mMapView) {
        MapView.setMapCustomEnable(false);
        mMapView.onDestroy();
        mMapView = null;
    }

    if (null != mSearchInteracter) {
        mSearchInteracter.destroy();
    }
    if (null != mFavoriteInteracter) {
        mFavoriteInteracter.destroy();
    }

    super.onDestroyView();
}
 
Example #5
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 #6
Source File: FreightTrackGoogleMapFragment.java    From ESeal with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_freight_track_google_map, container, false);

    mFreightId = getArguments().getString(ARGUMENT_FREIGHT_ID);
    mFreightName = getArguments().getString(ARGUMENT_FREIGHT_NAME);

    FloatingActionButton fab = (FloatingActionButton) getActivity().findViewById(R.id.fab);
    fab.setOnClickListener(mOnFabClickListener);

    bmapView = (MapView) view.findViewById(R.id.bmapView);
    googleMapView = (com.google.android.gms.maps.MapView) view.findViewById(R.id.googleMapView);

    mHandler = new Handler();
    return view;
}
 
Example #7
Source File: FreightTrackMapFragment.java    From ESeal with Apache License 2.0 6 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View view = inflater.inflate(R.layout.fragment_freight_track_map, container, false);

    mFreightId = getArguments().getString(ARGUMENT_FREIGHT_ID);
    mFreightName = getArguments().getString(ARGUMENT_FREIGHT_NAME);

    FloatingActionButton fab = (FloatingActionButton) getActivity().findViewById(R.id.fab);
    fab.setOnClickListener(mOnFabClickListener);

    bmapView = (MapView) view.findViewById(R.id.bmapView);

    mHandler = new Handler();
    return view;
}
 
Example #8
Source File: ShareLocationActivity.java    From imsdk-android with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SDKInitializer.initialize(getApplicationContext());
    shareId = getIntent().getStringExtra(SHARE_ID);
    fromId = getIntent().getStringExtra(FROM_ID);
    myId = QtalkStringUtils.userId2Jid(CurrentPreference.getInstance().getUserid());
    presenter.setShareLocationView(this);
    setContentView(R.layout.atom_ui_activity_share_location);
    mapView = (MapView) findViewById(R.id.mapView);
    img_reset_location = (ImageView) findViewById(R.id.img_reset_location);
    hint = (TextView) findViewById(R.id.hint);
    topContainer = (LinearLayout) findViewById(R.id.location_top_container);
    actionBar = (QtNewActionBar) findViewById(R.id.my_action_bar);
    setNewActionBar(actionBar);
    initBaiduMap();
    img_reset_location.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            zoomMap();
        }
    });
    addMember(myId);
}
 
Example #9
Source File: FreightTrackMapWithWebViewFragment.java    From ESeal with Apache License 2.0 6 votes vote down vote up
@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_freight_track_map_with_webview, container, false);

        mFreightId = getArguments().getString(ARGUMENT_FREIGHT_ID);
        mFreightName = getArguments().getString(ARGUMENT_FREIGHT_NAME);

        FloatingActionButton fab = (FloatingActionButton) getActivity().findViewById(R.id.fab);
        fab.setOnClickListener(__ -> mPresenter.loadFreightDataListDetail(mIsFreightTrackMode));

        bmapView = (MapView) view.findViewById(R.id.bmapView);
        webView = (WebView) view.findViewById(R.id.webView);

        //根据当前系统语言设置加载不同的Map Ui
        mUsingWebView = "zh-CN".equals(LanguageUtil.getLanguage()) ? false : true;
//        mUsingWebView = true; //for test webviewMap
        setupMapUi(mUsingWebView);
        if (mUsingWebView) {
            setupWebView();
        }

        mHandler = new Handler();
        return view;
    }
 
Example #10
Source File: MapFragment.java    From apollo-DuerOS with Apache License 2.0 6 votes vote down vote up
private void initView(View view) {
    bearinglist = getActivity().getResources().getStringArray(R.array.bearing_list_text);

    mapRecover = view.findViewById(R.id.map_view_recover);
    mapRecover.setOnClickListener(this);

    framelayout = (FrameLayout) view.findViewById(R.id.bmap_frame);
    mProgressRl = (RelativeLayout) view.findViewById(R.id.progress_rl);
    compassView = (ImageView) view.findViewById(R.id.im_compass);
    tvDushu = (TextView) view.findViewById(R.id.tv_degree);
    directionView = (TextView) view.findViewById(R.id.tv_direction);
    tvLa = (TextView) view.findViewById(R.id.tv_weidu);
    tvLn = (TextView) view.findViewById(R.id.tv_longitude);
    updateCompassView(compassView, bearing);
    // Get sensor management services
    mSensorManager = (SensorManager) LauncherApp.getInstance().getSystemService(SENSOR_SERVICE);

    // We need to make personalized configuration before MapView initialization
    if (FileUtil.isFileExists(FILE_PATH_NAME)) {
        MapView.setCustomMapStylePath(FILE_PATH_NAME);
    }
    mMapView = new MapView(getActivity());
    framelayout.addView(mMapView);
}
 
Example #11
Source File: MapFragment.java    From apollo-DuerOS with Apache License 2.0 6 votes vote down vote up
private void initView(View view) {
    mapRecover = view.findViewById(R.id.map_view_recover);
    mapRecover.setOnClickListener(this);

    framelayout = (FrameLayout) view.findViewById(R.id.map_frame);
    mProgressRl = (RelativeLayout) view.findViewById(R.id.map_rl_progress);

    mSensorManager = (SensorManager) LauncherApp.getInstance().getSystemService(SENSOR_SERVICE);

    // set some custom config ,before mapview init
    if (FileUtil.isFileExists(FILE_PATH_NAME)) {
        MapView.setCustomMapStylePath(FILE_PATH_NAME);
    }
    mMapView = new MapView(getActivity());
    framelayout.addView(mMapView);
}
 
Example #12
Source File: BaiduMapRouteFragment.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
private void configMap() {
    ConfigInteracter configInteracter = new ConfigInteracter(getActivity());
    mBaiduMap.getUiSettings().setZoomGesturesEnabled(configInteracter.isZoomGesturesEnabled());
    mBaiduMap.getUiSettings().setOverlookingGesturesEnabled(configInteracter.isOverlookEnable());
    mBaiduMap.getUiSettings().setRotateGesturesEnabled(configInteracter.isRotateEnable());
    mMapView.showScaleControl(configInteracter.isShowScaleControl());
    mBaiduMap.showMapPoi(configInteracter.isMapPoiEnable());
    mBaiduMap.setTrafficEnabled(configInteracter.isTrafficEnable());
    if (configInteracter.getNightMode() == 2){
        MapView.setMapCustomEnable(true);
    }else {
        MapView.setMapCustomEnable(false);
    }
    mMapView.showZoomControls(false);
    mBaiduMap.setMaxAndMinZoomLevel(20f, 3f);
    CoordinatorLayout.LayoutParams params = new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    if (configInteracter.getZoomControlsPosition()) {
        params.rightMargin = AppUtils.dip2Px(getActivity(), 10);
        params.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;
    } else {
        params.leftMargin = AppUtils.dip2Px(getActivity(), 10);
        params.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
    }
    mCardZoom.setLayoutParams(params);

}
 
Example #13
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 #14
Source File: MainActivity.java    From Android-Plugin-Framework with MIT License 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    //appkey是使用插件的packageName注册的
    //sdk的配置信息也在插件中
    SDKInitializer.initialize(getApplication());

    setContentView(R.layout.activity_main);

    mMapView = (MapView) findViewById(R.id.bmapView);
}
 
Example #15
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 #16
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 #17
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 #18
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 #19
Source File: BaiduMapFragment.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
private void configMap() {
        ConfigInteracter configInteracter = new ConfigInteracter(getActivity());
        mBaiduMap.getUiSettings().setZoomGesturesEnabled(configInteracter.isZoomGesturesEnabled());
        mBaiduMap.getUiSettings().setOverlookingGesturesEnabled(configInteracter.isOverlookEnable());
        mBaiduMap.getUiSettings().setRotateGesturesEnabled(configInteracter.isRotateEnable());
        mMapView.showScaleControl(configInteracter.isShowScaleControl());
        mBaiduMap.showMapPoi(configInteracter.isMapPoiEnable());
        mBaiduMap.setTrafficEnabled(configInteracter.isTrafficEnable());
        if (configInteracter.getNightMode() == 2) {
            MapView.setMapCustomEnable(true);
        } else {
            MapView.setMapCustomEnable(false);
        }

        mMapView.showZoomControls(false);
//        mBaiduMap.setMaxAndMinZoomLevel(20f, 3f);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        FrameLayout.LayoutParams params2 = new FrameLayout.LayoutParams(AppUtils.dip2Px(getActivity(), 36), ViewGroup.LayoutParams.WRAP_CONTENT);
        if (configInteracter.getZoomControlsPosition()) {
            params.rightMargin = AppUtils.dip2Px(getActivity(), 10);
            params.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;
            params2.leftMargin = AppUtils.dip2Px(getActivity(), 10);
            params2.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
        } else {
            params.leftMargin = AppUtils.dip2Px(getActivity(), 10);
            params.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
            params2.rightMargin = AppUtils.dip2Px(getActivity(), 10);
            params2.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;
        }
        mCardZoom.setLayoutParams(params);
        mCardFloor.setLayoutParams(params2);

    }
 
Example #20
Source File: Activity_Location.java    From FoodOrdering with Apache License 2.0 5 votes vote down vote up
private void findViewById() {
    back_lay = (LinearLayout) findViewById(R.id.back_lay);
    title= (TextView) findViewById(R.id.title);
    custom_made= (TextView) findViewById(R.id.custom_made);
    title.setText("定位");
    custom_made.setText("确定");
    mMapView = (MapView) findViewById(R.id.bmapView);
    tv_longitude = (TextView) findViewById(R.id.tv_longitude);
    tv_latitude = (TextView) findViewById(R.id.tv_latitude);
    tv_address = (TextView) findViewById(R.id.tv_address);
    back_lay.setOnClickListener(this);
    custom_made.setOnClickListener(this);

}
 
Example #21
Source File: RouteBaiduBusActivity.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
private void configMap() {
        ConfigInteracter configInteracter = new ConfigInteracter(this);
        mBaiduMap.getUiSettings().setZoomGesturesEnabled(configInteracter.isZoomGesturesEnabled());
        mBaiduMap.getUiSettings().setOverlookingGesturesEnabled(configInteracter.isOverlookEnable());
        mBaiduMap.getUiSettings().setRotateGesturesEnabled(configInteracter.isRotateEnable());
        mMapView.showScaleControl(configInteracter.isShowScaleControl());
        mBaiduMap.showMapPoi(configInteracter.isMapPoiEnable());
        mBaiduMap.setTrafficEnabled(configInteracter.isTrafficEnable());
        if (configInteracter.getNightMode() == 2) {
            MapView.setMapCustomEnable(true);
        } else {
            MapView.setMapCustomEnable(false);
        }

        mMapView.showZoomControls(false);
        mBaiduMap.setMaxAndMinZoomLevel(20f, 3f);
        CoordinatorLayout.LayoutParams params = new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        if (configInteracter.getZoomControlsPosition()) {
            params.rightMargin = AppUtils.dip2Px(this, 10);
            params.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;
        } else {
            params.leftMargin = AppUtils.dip2Px(this, 10);
            params.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
        }
        mCardZoom.setLayoutParams(params);

//        if (configInteracter.getZoomControlsPosition()) {
//            mMapView.setZoomControlsPosition(new Point(mMapView.getWidth() - 150, mMapView.getHeight() / 2));
//        } else {
//            mMapView.setZoomControlsPosition(new Point(20, mMapView.getHeight() / 2));
//        }
    }
 
Example #22
Source File: BaiduMapSelectPoiFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
private void configMap() {
    ConfigInteracter configInteracter = new ConfigInteracter(getActivity());
    mBaiduMap.getUiSettings().setZoomGesturesEnabled(configInteracter.isZoomGesturesEnabled());
    mBaiduMap.getUiSettings().setOverlookingGesturesEnabled(configInteracter.isOverlookEnable());
    mBaiduMap.getUiSettings().setRotateGesturesEnabled(configInteracter.isRotateEnable());
    mMapView.showScaleControl(configInteracter.isShowScaleControl());
    mBaiduMap.showMapPoi(configInteracter.isMapPoiEnable());
    mBaiduMap.setTrafficEnabled(configInteracter.isTrafficEnable());
    if (configInteracter.getNightMode() == 2){
        MapView.setMapCustomEnable(true);
    }else {
        MapView.setMapCustomEnable(false);
    }

    mMapView.showZoomControls(false);
    mBaiduMap.setMaxAndMinZoomLevel(20f, 3f);
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    if (configInteracter.getZoomControlsPosition()) {
        params.rightMargin = AppUtils.dip2Px(getActivity(), 10);
        params.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;
    } else {
        params.leftMargin = AppUtils.dip2Px(getActivity(), 10);
        params.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
    }
    mCardZoom.setLayoutParams(params);

}
 
Example #23
Source File: BaiduMapFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
private void configMap() {
        ConfigInteracter configInteracter = new ConfigInteracter(getActivity());
        mBaiduMap.getUiSettings().setZoomGesturesEnabled(configInteracter.isZoomGesturesEnabled());
        mBaiduMap.getUiSettings().setOverlookingGesturesEnabled(configInteracter.isOverlookEnable());
        mBaiduMap.getUiSettings().setRotateGesturesEnabled(configInteracter.isRotateEnable());
        mMapView.showScaleControl(configInteracter.isShowScaleControl());
        mBaiduMap.showMapPoi(configInteracter.isMapPoiEnable());
        mBaiduMap.setTrafficEnabled(configInteracter.isTrafficEnable());
        if (configInteracter.getNightMode() == 2) {
            MapView.setMapCustomEnable(true);
        } else {
            MapView.setMapCustomEnable(false);
        }

        mMapView.showZoomControls(false);
//        mBaiduMap.setMaxAndMinZoomLevel(20f, 3f);
        FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        FrameLayout.LayoutParams params2 = new FrameLayout.LayoutParams(AppUtils.dip2Px(getActivity(), 36), ViewGroup.LayoutParams.WRAP_CONTENT);
        if (configInteracter.getZoomControlsPosition()) {
            params.rightMargin = AppUtils.dip2Px(getActivity(), 10);
            params.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;
            params2.leftMargin = AppUtils.dip2Px(getActivity(), 10);
            params2.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
        } else {
            params.leftMargin = AppUtils.dip2Px(getActivity(), 10);
            params.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
            params2.rightMargin = AppUtils.dip2Px(getActivity(), 10);
            params2.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;
        }
        mCardZoom.setLayoutParams(params);
        mCardFloor.setLayoutParams(params2);

    }
 
Example #24
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 #25
Source File: RouteBaiduBusActivity.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
private void configMap() {
        ConfigInteracter configInteracter = new ConfigInteracter(this);
        mBaiduMap.getUiSettings().setZoomGesturesEnabled(configInteracter.isZoomGesturesEnabled());
        mBaiduMap.getUiSettings().setOverlookingGesturesEnabled(configInteracter.isOverlookEnable());
        mBaiduMap.getUiSettings().setRotateGesturesEnabled(configInteracter.isRotateEnable());
        mMapView.showScaleControl(configInteracter.isShowScaleControl());
        mBaiduMap.showMapPoi(configInteracter.isMapPoiEnable());
        mBaiduMap.setTrafficEnabled(configInteracter.isTrafficEnable());
        if (configInteracter.getNightMode() == 2) {
            MapView.setMapCustomEnable(true);
        } else {
            MapView.setMapCustomEnable(false);
        }

        mMapView.showZoomControls(false);
        mBaiduMap.setMaxAndMinZoomLevel(20f, 3f);
        CoordinatorLayout.LayoutParams params = new CoordinatorLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        if (configInteracter.getZoomControlsPosition()) {
            params.rightMargin = AppUtils.dip2Px(this, 10);
            params.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;
        } else {
            params.leftMargin = AppUtils.dip2Px(this, 10);
            params.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
        }
        mCardZoom.setLayoutParams(params);

//        if (configInteracter.getZoomControlsPosition()) {
//            mMapView.setZoomControlsPosition(new Point(mMapView.getWidth() - 150, mMapView.getHeight() / 2));
//        } else {
//            mMapView.setZoomControlsPosition(new Point(20, mMapView.getHeight() / 2));
//        }
    }
 
Example #26
Source File: BaiduMapSelectPoiFragment.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
private void configMap() {
    ConfigInteracter configInteracter = new ConfigInteracter(getActivity());
    mBaiduMap.getUiSettings().setZoomGesturesEnabled(configInteracter.isZoomGesturesEnabled());
    mBaiduMap.getUiSettings().setOverlookingGesturesEnabled(configInteracter.isOverlookEnable());
    mBaiduMap.getUiSettings().setRotateGesturesEnabled(configInteracter.isRotateEnable());
    mMapView.showScaleControl(configInteracter.isShowScaleControl());
    mBaiduMap.showMapPoi(configInteracter.isMapPoiEnable());
    mBaiduMap.setTrafficEnabled(configInteracter.isTrafficEnable());
    if (configInteracter.getNightMode() == 2){
        MapView.setMapCustomEnable(true);
    }else {
        MapView.setMapCustomEnable(false);
    }

    mMapView.showZoomControls(false);
    mBaiduMap.setMaxAndMinZoomLevel(20f, 3f);
    FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    if (configInteracter.getZoomControlsPosition()) {
        params.rightMargin = AppUtils.dip2Px(getActivity(), 10);
        params.gravity = Gravity.CENTER_VERTICAL | Gravity.RIGHT;
    } else {
        params.leftMargin = AppUtils.dip2Px(getActivity(), 10);
        params.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT;
    }
    mCardZoom.setLayoutParams(params);

}
 
Example #27
Source File: BaiduMapViewManager.java    From BaiduMapKit with MIT License 4 votes vote down vote up
@Override
protected MapView createViewInstance(ThemedReactContext reactContext) {
    return new MapView(mActivity);
}
 
Example #28
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();

}
 
Example #29
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 #30
Source File: TrafficShowPresenter.java    From AssistantBySDK with Apache License 2.0 4 votes vote down vote up
public TrafficShowPresenter(ITrafficShow.INaviSetPointView view, MapView mapView) {
    this.mTrafficShowView = view;
    this.mapView = mapView;
    mContext = (Activity) view;
    mAppConfig = (AppConfig) mContext.getApplication();
}