Java 类com.baidu.mapapi.map.MapView 实例源码

项目:DaiGo    文件:SeeLocationActivity.java   
private void initView() {
    mapView = (MapView) findViewById(R.id.see_location_mapview);
    toolBarView = (ToolBarView) findViewById(R.id.see_location_toolbar);

    toolBarView.setBackButtonImage(R.mipmap.icon_back);
    toolBarView.setBackButtonVisible(true);
    toolBarView.setBackButtonOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
    toolBarView.setTitleText("查看接单人位置");

    baiduMap = mapView.getMap();

    MapStatusUpdate update = MapStatusUpdateFactory.zoomTo(19f);
    baiduMap.setMapStatus(update);

    handler = new MyHandler(this);


}
项目:RunHDU    文件:RunningActivity.java   
private void initView() {
    client = new LocationClient(getApplicationContext());
    client.registerLocationListener(new RunningActivity.MyLocationListener());
    rootLayout = (LinearLayout) findViewById(R.id.running_root_layout);
    mapView = (MapView) findViewById(R.id.bmapView);
    startButton = (CircularProgressButton) findViewById(R.id.cpb_button);
    latLngText = (TextView) findViewById(R.id.lat_lng_text);
    speedNumber = (TextView) findViewById(R.id.speed_text);
    distanceNumber = (ImageNumberDisplayView) findViewById(R.id.distance_text);
    stepNumber = (ImageNumberDisplayView) findViewById(R.id.running_step);
    energyNumber = (ImageNumberDisplayView) findViewById(R.id.running_energy);
    setToolbar(R.id.running_toolbar, true);

    timer = (Chronometer) findViewById(R.id.timer);
    baiduMap = mapView.getMap();
    startButton.setClickable(false);
    startButton.setIndeterminateProgressMode(true);
}
项目:GCSApp    文件:LocationDemo.java   
@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_location);

        mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);//获取传感器管理服务
//        mCurrentMode = LocationMode.NORMAL;

        // 地图初始化
        mMapView = (MapView) findViewById(R.id.bmapView);
        mBaiduMap = mMapView.getMap();
        // 开启定位图层
        mBaiduMap.setMyLocationEnabled(true);
        // 定位初始化
        mLocClient = new LocationClient(this);
        mLocClient.registerLocationListener(myListener);
        LocationClientOption option = new LocationClientOption();
        option.setOpenGps(true); // 打开gps
        option.setCoorType("bd09ll"); // 设置坐标类型
        option.setScanSpan(1000);
        mLocClient.setLocOption(option);
        mLocClient.start();
    }
项目:GCSApp    文件:RoutePlanDemo.java   
protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_routeplan);
        mTvtitle = (TextView) findViewById(R.id.tv_topbar_title);
        mTvtitle.setText("财神谷地址");
        ImageView img = (ImageView) findViewById(R.id.img_topbar_back);
        img.setImageResource(R.mipmap.icon_back);
        img.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                RoutePlanDemo.this.finish();
            }
        });
//        mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);//获取传感器管理服务
        // 初始化地图
        mMapView = (MapView) findViewById(R.id.map);
        mBaidumap = mMapView.getMap();
        MapStatus.Builder builder = new MapStatus.Builder();
        builder.zoom(18.0f);
        builder.target(new LatLng(29.184662, 121.305024));
        mMapStatusUpdate = MapStatusUpdateFactory.newMapStatus(builder.build());
        mBaidumap.setMapStatus(mMapStatusUpdate);
        MarkerOptions ooA = new MarkerOptions().position(GEO_NINGBO).icon(bdA)
                .zIndex(9).draggable(true);
        mBaidumap.addOverlay(ooA);
        mBaidumap.setTrafficEnabled(true);
        findViewById(R.id.lin_action_route).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                go2ThirdMap();
            }
        });
    }
项目:AndroidOpen    文件:RoutePlanDemo.java   
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_routeplan);
    CharSequence titleLable = "路线规划功能";
    setTitle(titleLable);
    // 初始化地图
    mMapView = (MapView) findViewById(R.id.map);
    mBaidumap = mMapView.getMap();
    mBtnPre = (Button) findViewById(R.id.pre);
    mBtnNext = (Button) findViewById(R.id.next);
    mBtnPre.setVisibility(View.INVISIBLE);
    mBtnNext.setVisibility(View.INVISIBLE);
    // 地图点击事件处理
    mBaidumap.setOnMapClickListener(this);
    // 初始化搜索模块,注册事件监听
    mSearch = RoutePlanSearch.newInstance();
    mSearch.setOnGetRoutePlanResultListener(this);
}
项目:BikeHelper    文件:MainActivity.java   
private void setMapView() {
    BaiduMapOptions options = new BaiduMapOptions();
    options.compassEnabled(false);
    options.overlookingGesturesEnabled(false);
    options.rotateGesturesEnabled(false);
    options.scaleControlEnabled(true);
    options.zoomControlsEnabled(false);
    MapStatus.Builder status = new MapStatus.Builder();
    if (Config.Zoom > Float.NEGATIVE_INFINITY)
        status.zoom(Config.Zoom);
    if (Config.Latitude > Double.NEGATIVE_INFINITY && Config.Longitude > Double.NEGATIVE_INFINITY)
        status.target(new LatLng(Config.Latitude, Config.Longitude));
    options.mapStatus(status.build());
    mMapView = new MapView(this, options);

    mMapView.getMap().setMyLocationEnabled(true);
    mMapView.getMap().setBuildingsEnabled(false);
    mMapView.getMap().setOnMapStatusChangeListener(this);

    MapViewUtils.initViewPositions(mMapView);
    MapViewUtils.addMapView(this, mMapView);
}
项目:BikeHelper    文件:RouteViewActivity.java   
private void setMapView() {
    BaiduMapOptions options = new BaiduMapOptions();
    options.compassEnabled(false);
    options.overlookingGesturesEnabled(false);
    options.rotateGesturesEnabled(false);
    options.scaleControlEnabled(true);
    options.zoomControlsEnabled(false);
    mMapView = new MapView(this, options);

    mMapView.getMap().setBuildingsEnabled(false);
    mMapView.getMap().setMapType(Config.MapType);

    MapViewUtils.initViewPositions(mMapView, false);
    MapViewUtils.addMapView(this, mMapView);
    MapViewUtils.addLineOverlay(mMapView, mRoutePoints, 0);
    MapViewUtils.addDrawableOverlay(mMapView, R.drawable.ic_route_start, mRouteData.getBeginLatlng(), 2);
    MapViewUtils.addDrawableOverlay(mMapView, R.drawable.ic_route_end, mRouteData.getEndLatlng(), 1);
    MapViewUtils.zoomToMaxLevel(mMapView, false);
    MapViewUtils.moveToLatLng(mMapView, mRouteData.getBeginLatlng(), false);
}
项目:FirstCodeUtil    文件:AtyLocationBaiduMap.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    //在使用SDK各组件之前初始化context信息,传入ApplicationContext
    //注意该方法要再setContentView方法之前实现
    SDKInitializer.initialize(getApplicationContext());
    setContentView(R.layout.activity_location_baidu_map);
    //获取地图控件引用
    mMapView = (MapView) findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();

    //普通地图
    // mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);

    //卫星地图
    mBaiduMap.setMapType(BaiduMap.MAP_TYPE_SATELLITE);

    //空白地图, 基础地图瓦片将不会被渲染。在地图类型中设置为NONE,将不会使用流量下载基础地图瓦片图层。使用场景:与瓦片图层一起使用,节省流量,提升自定义瓦片图下载速度。
    // mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NONE);
}
项目:ESeal    文件:FreightTrackMapWithWebViewFragment.java   
@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;
    }
项目:ESeal    文件:FreightTrackMapFragment.java   
@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;
}
项目:ESeal    文件:FreightTrackGoogleMapFragment.java   
@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;
}
项目:MyStudyHelper    文件:MapActivity.java   
@Override
protected void OnInitUiAndData() {
    super.OnInitUiAndData();

    mMapView = (MapView) findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();
    ll_back_on_mapactivity = (LinearLayout) findViewById(R.id.ll_back_on_mapactivity);
    fl_mapactivity = (FrameLayout) findViewById(R.id.fl_mapactivity);
    btSearch = (Button) findViewById(R.id.btSearch);
    btClear = (Button) findViewById(R.id.btClear);
    btLoca = (Button) findViewById(R.id.btLoca);
    dialog_show = LayoutInflater.from(this).inflate(R.layout.dialog_show, null);
    etFrom = (EditTextWithFrame) dialog_show.findViewById(R.id.etFrom);
    etEnd = (EditTextWithFrame) dialog_show.findViewById(R.id.etEnd);

}
项目:Mooc-map    文件:MainActivity.java   
private void initView() {
    mMapView = (MapView) findViewById(R.id.id_bmapView);
    mBaiduMap = mMapView.getMap();
    MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(17.0f);//缩放等级17=100m
    mBaiduMap.setMapStatus(msu);
    mLocationMode = MyLocationConfiguration.LocationMode.NORMAL;
    //隐藏缩放控件和百度logo
    int childCount = mMapView.getChildCount();
    for (int i = 0; i < childCount; i++) {
        View child = mMapView.getChildAt(i);
        if (child instanceof ZoomControls || child instanceof ImageView) {
            child.setVisibility(View.GONE);
        }
    }
    //改变比例尺的位置
    final int screenheight = this.getWindowManager().getDefaultDisplay().getHeight();
    mBaiduMap.setOnMapLoadedCallback(new BaiduMap.OnMapLoadedCallback() {

        @Override
        public void onMapLoaded() {
            mMapView.setScaleControlPosition(new Point(200, screenheight - 307));
        }
    });
}
项目:BikeHelper    文件:MainActivity.java   
private void setMapView() {
    BaiduMapOptions options = new BaiduMapOptions();
    options.compassEnabled(false);
    options.overlookingGesturesEnabled(false);
    options.rotateGesturesEnabled(false);
    options.scaleControlEnabled(true);
    options.zoomControlsEnabled(false);
    MapStatus.Builder status = new MapStatus.Builder();
    if (Config.Zoom > Float.NEGATIVE_INFINITY)
        status.zoom(Config.Zoom);
    if (Config.Latitude > Double.NEGATIVE_INFINITY && Config.Longitude > Double.NEGATIVE_INFINITY)
        status.target(new LatLng(Config.Latitude, Config.Longitude));
    options.mapStatus(status.build());
    mMapView = new MapView(this, options);

    mMapView.getMap().setMyLocationEnabled(true);
    mMapView.getMap().setBuildingsEnabled(false);
    mMapView.getMap().setOnMapStatusChangeListener(this);

    MapViewUtils.initViewPositions(mMapView);
    MapViewUtils.addMapView(this, mMapView);
}
项目:BikeHelper    文件:RouteViewActivity.java   
private void setMapView() {
    BaiduMapOptions options = new BaiduMapOptions();
    options.compassEnabled(false);
    options.overlookingGesturesEnabled(false);
    options.rotateGesturesEnabled(false);
    options.scaleControlEnabled(true);
    options.zoomControlsEnabled(false);
    mMapView = new MapView(this, options);

    mMapView.getMap().setBuildingsEnabled(false);
    mMapView.getMap().setMapType(Config.MapType);

    MapViewUtils.initViewPositions(mMapView, false);
    MapViewUtils.addMapView(this, mMapView);
    MapViewUtils.addLineOverlay(mMapView, mRoutePoints, 0);
    MapViewUtils.addDrawableOverlay(mMapView, R.drawable.ic_route_start, mRouteData.getBeginLatlng(), 2);
    MapViewUtils.addDrawableOverlay(mMapView, R.drawable.ic_route_end, mRouteData.getEndLatlng(), 1);
    MapViewUtils.zoomToMaxLevel(mMapView, false);
    MapViewUtils.moveToLatLng(mMapView, mRouteData.getBeginLatlng(), false);
}
项目:LEHomeMobile_android    文件:LocationActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_location);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
    }

    mVisible = true;
    mControlsView = findViewById(R.id.fullscreen_content_controls);
    mMapView = (MapView) findViewById(R.id.location_map_view);

    setupMapView(mMapView);

}
项目:zsyy    文件:HospitalPeripheryNavigationActivity.java   
@Override
protected void initViews() {
    SDKInitializer.initialize(getApplicationContext());

    setContentView(R.layout.activity_hospital_periphery_navigation);
    setTitleBack("周边商户");
    rbDrug = (RadioButton) findViewById(R.id.rb_drug);
    rbHotel = (RadioButton) findViewById(R.id.rb_hotel);
    rbBank = (RadioButton) findViewById(R.id.rb_bank);
    rbIce = (RadioButton) findViewById(R.id.rb_ice);
    mMapView = (MapView) findViewById(R.id.mv);
    mBaiduMap = mMapView.getMap();
    //普通地图
    mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
    //设定中心点坐标
    LatLng centerPoint = new LatLng(31.3023280000, 120.5906890000);
    //定义地图状态
    MapStatus mMapStatus = new MapStatus.Builder()
            .target(centerPoint)
            .zoom(18)
            .build();
    //定义MapStatusUpdate对象,以便描述地图状态将要发生的变化
    MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory.newMapStatus(mMapStatus);
    //改变地图状态
    mBaiduMap.setMapStatus(mMapStatusUpdate);
}
项目:zsyy    文件:HospitalMapNavigationActivity.java   
@Override
    protected void initViews() {
        //在使用SDK各组件之前初始化context信息,传入ApplicationContext
        //注意该方法要再setContentView方法之前实现
        SDKInitializer.initialize(getApplicationContext());

        setContentView(R.layout.activity_hospital_map_navigation);
        setTitleBack("地图导航");
        ibBus = (ImageButton) findViewById(R.id.ib_bus);
        ibDriver = (ImageButton) findViewById(R.id.ib_driver);
        ibWalk = (ImageButton) findViewById(R.id.ib_walk);
        mMapView = (MapView) findViewById(R.id.mv);
        mBaiduMap = mMapView.getMap();

        initMapCenterPoint();

//        initMyLocation();
    }
项目:PiBoat    文件:MapActivity.java   
private void initMapAndLoc() {
    // 地图初始化
    mMapView = (MapView) findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();
    // 开启定位图层
    mBaiduMap.setMyLocationEnabled(true);
    // 定位初始化
    mLocClient = new LocationClient(this);
    mLocClient.registerLocationListener(myListener);
    LocationClientOption option = new LocationClientOption();
    option.setOpenGps(true);// 打开gps
    option.setCoorType("bd09ll"); // 设置坐标类型
    option.setScanSpan(1000);
    mLocClient.setLocOption(option);
    mLocClient.start();

    mBaiduMap
            .setMyLocationConfigeration(new MyLocationConfiguration(
                    mCurrentMode, true, mCurrentMarker));

}
项目:CarApp    文件:RouteActivity.java   
private void initView() {
    iv_back = (ImageView) findViewById(R.id.iv_back);
    iv_back.setVisibility(View.VISIBLE);
    iv_back.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            finish();
        }
    });
    mMapView = (MapView) findViewById(R.id.bmapView);
    mMapView.showScaleControl(false);
    mMapView.showZoomControls(false);
    mBaiduMap = mMapView.getMap();

    mSearch = RoutePlanSearch.newInstance();
    mSearch.setOnGetRoutePlanResultListener(this);
    Intent intent = getIntent();
    LatLng locLatLng = new LatLng(intent.getDoubleExtra("locLat", 0), intent.getDoubleExtra("locLon", 0));
    LatLng desLatLng = new LatLng(intent.getDoubleExtra("lat", 0), intent.getDoubleExtra("lon", 0));
    PlanNode st = PlanNode.withLocation(locLatLng);
    PlanNode en = PlanNode.withLocation(desLatLng);
    mSearch.drivingSearch(new DrivingRoutePlanOption().from(st).to(en));
}
项目:BMap    文件:BusLineSearchDemo.java   
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_busline);
    CharSequence titleLable = "公交线路查询功能";
    setTitle(titleLable);
    mBtnPre = (Button) findViewById(R.id.pre);
    mBtnNext = (Button) findViewById(R.id.next);
    mBtnPre.setVisibility(View.INVISIBLE);
    mBtnNext.setVisibility(View.INVISIBLE);
    mMapView = (MapView) findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();
    mBaiduMap.setOnMapClickListener(this);
    mSearch = PoiSearch.newInstance();
    mSearch.setOnGetPoiSearchResultListener(this);
    mBusLineSearch = BusLineSearch.newInstance();
    mBusLineSearch.setOnGetBusLineSearchResultListener(this);
    busLineIDList = new ArrayList<String>();
    bar = (ProgressBar) findViewById(R.id.progressBar);
    bar.setVisibility(View.GONE);
}
项目:eDao    文件:MapActivity.java   
private void init() {
    // TODO 自动生成的方法存根
    textView_curCity = (TextView) findViewById(R.id.map_textView_curcity);
    layout_store = (LinearLayout) findViewById(R.id.map_layout_store);

    mMapView = (MapView) findViewById(R.id.bmapView);
    imageView_mylocation = (ImageView) findViewById(R.id.map_imageView_mylocaiton);

    textView_curCity.setText(curCity);
    mBaiduMap = mMapView.getMap();
    layout_store.setOnClickListener(this);
    imageView_mylocation.setOnClickListener(this);

    list = new ArrayList<StoreData>();

    mCluster = new Cluster(this, mBaiduMap, mGridSize, isAverageCenter, mGridSize, mDistance);
}
项目:BaiduMapKit    文件:BaiduMapViewManager.java   
/**
 * 显示地理标记
 *
 * @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);
        }
    }
}
项目:itmarry    文件:PoiSelectActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    initMap();
    setContentView(R.layout.activity_poiselect);
    map = (MapView) findViewById(R.id.baidumap);
    actionbar = (CustomActionBar) findViewById(R.id.actionbar);
    edit = (EditText) findViewById(R.id.edit);
    probar = findViewById(R.id.probar);
    flag=(ImageView) findViewById(R.id.flag);
    view.findViewById(R.id.view);
    map.getController().setZoom(15f);
    map.regMapViewListener(app.mapMan, new MapViewListener());
    actionbar.setLeftText("����");
    actionbar.setRightText("ȷ��");
    actionbar.getRightView().setEnabled(false);
    actionbar.setTitle("�ص�༭");
}
项目:calltaxi    文件:MapActivity.java   
public void getLoc() {
    myListener = new MyLocationListener(MapActivity.this, 
        (MapView)findViewById(R.id.bmapsView));

    mLocationClient = new LocationClient(getApplicationContext());
    mLocationClient.setAccessKey(mk);
    mLocationClient.registerLocationListener(myListener);
    LocationClientOption option = new LocationClientOption();

    option.setLocationMode(LocationMode.Hight_Accuracy);//设置定位模式
    option.setCoorType("bd09ll");//返回的定位结果是百度经纬度,默认值gcj02
    option.setScanSpan(5000);
    option.setIsNeedAddress(true);//返回的定位结果包含地址信息
    option.setNeedDeviceDirect(true);//返回的定位结果包含手机机头的方向
    mLocationClient.setLocOption(option); 

    if (mLocationClient != null && false == mLocationClient.isStarted()) {
        mLocationClient.requestLocation();
        mLocationClient.start();
    }
    else
        Log.e("LocSDK3", "locClient is null or not started");
}
项目:calltaxi    文件:MapActivity.java   
public void getLoc() {
    myListener = new MyLocationListener(MapActivity.this, 
        (MapView)findViewById(R.id.bmapsView));

    mLocationClient = new LocationClient(getApplicationContext());
    mLocationClient.setAccessKey(mk);
    mLocationClient.registerLocationListener(myListener);
    LocationClientOption option = new LocationClientOption();

    option.setLocationMode(LocationMode.Hight_Accuracy);//设置定位模式
    option.setCoorType("bd09ll");//返回的定位结果是百度经纬度,默认值gcj02
    option.setScanSpan(5000);
    option.setIsNeedAddress(true);//返回的定位结果包含地址信息
    option.setNeedDeviceDirect(true);//返回的定位结果包含手机机头的方向
    mLocationClient.setLocOption(option); 

    if (mLocationClient != null && false == mLocationClient.isStarted()) {
        mLocationClient.requestLocation();
        mLocationClient.start();
    }
    else
        Log.e("LocSDK3", "locClient is null or not started");
}
项目:HaHaMap    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    SDKInitializer.initialize(getApplicationContext());
    setContentView(R.layout.activity_main);

    mMapView = (MapView) findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();

    mBaiduMap.setMyLocationEnabled(true);

    mBaiduMap.setOnMarkerClickListener(mOnMarkerClickListener);

    LatLng centLl = MyUtils.getLlByIntent(getIntent());
    MyUtils.initMapCenter(centLl, mBaiduMap);
    mBdA = BitmapDescriptorFactory.fromResource(R.drawable.icon_marka);
    mMarker = MyUtils.addOverLayToMap(mBdA, centLl, mBaiduMap);
}
项目:HaHaMap    文件:GeoCoderActivity.java   
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_geocoder);
    CharSequence titleLable = "地理编码功能";
    setTitle(titleLable);

    // 地图初始化
    mMapView = (MapView) findViewById(R.id.bmapView);
    mBaiduMap = mMapView.getMap();

    mBaiduMap.setOnMarkerClickListener(mOnMarkerClickListener);

    // 初始化搜索模块,注册事件监听
    mSearch = GeoCoder.newInstance();
    mSearch.setOnGetGeoCodeResultListener(this);

    mCenterLatLng = MyUtils.getLlByIntent(getIntent());
    MyUtils.initMapCenter(mCenterLatLng, mBaiduMap);
    mMarkerA = MyUtils.addOverLayToMap(
            BitmapDescriptorFactory.fromResource(R.drawable.icon_marka),
            mCenterLatLng, mBaiduMap);

}
项目:FunWeibo    文件:BaiduMapActivity.java   
/**
 * 初始化地图
 */
private void initMap() {
    //设置MapView
    mMapView = (MapView)findViewById(R.id.bmapsView);
    mMapView.setBuiltInZoomControls(true);                      //设置启用内置的缩放控件
    mMapView.showScaleControl(true);                            //显示比例尺

    //地图控制器
    mMapController = mMapView.getController();

    //我的位置
    myLocationOverlay = new MyLocationOverlay(mMapView);

    //设置弹出窗
    mPopWindow = new PopupOverlay(mMapView, new MyPopupClickListener());
}
项目:GitHub    文件:MainActivity.java   
private void initMap() {
    // 地图初始化
    mMapView = (MapView) findViewById(R.id.id_bmapView);
    mBaiduMap = mMapView.getMap();
    // 开启定位图层
    mBaiduMap.setMyLocationEnabled(true);
    // 定位初始化
    mlocationClient = new LocationClient(this);
    mlocationClient.registerLocationListener(myListener);
    LocationClientOption option = new LocationClientOption();
    option.setOpenGps(true); // 打开gps
    option.setCoorType("bd09ll"); // 设置坐标类型
    option.setScanSpan(5000);//设置onReceiveLocation()获取位置的频率
    option.setIsNeedAddress(true);//如想获得具体位置就需要设置为true
    mlocationClient.setLocOption(option);
    mlocationClient.start();
    mCurrentMode = MyLocationConfiguration.LocationMode.FOLLOWING;
    mBaiduMap.setMyLocationConfigeration(new MyLocationConfiguration(
            mCurrentMode, true, null));
    myOrientationListener = new MyOrientationListener(this);
    //通过接口回调来实现实时方向的改变
    myOrientationListener.setOnOrientationListener(new MyOrientationListener.OnOrientationListener() {
        @Override
        public void onOrientationChanged(float x) {
            mCurrentX = x;
        }
    });
    myOrientationListener.start();
    mSearch = RoutePlanSearch.newInstance();
    mSearch.setOnGetRoutePlanResultListener(this);
    initMarkerClickEvent();
}
项目:AndroidBookTest    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.d(TAG,"onCreate");
    mLocationClient=new LocationClient(getApplicationContext());
    mLocationClient.registerLocationListener(new MyLocationListener());
    SDKInitializer.initialize(getApplicationContext());
    setContentView(R.layout.activity_main);
    mapView=(MapView)findViewById(R.id.bmapView);
    baiduMap=mapView.getMap();
    baiduMap.setMyLocationEnabled(true);
    positionText=(TextView)findViewById(R.id.position_text_view);

    List<String>permissionList=new ArrayList<>();
    if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION)
            != PackageManager.PERMISSION_GRANTED){
        permissionList.add(Manifest.permission.ACCESS_FINE_LOCATION);
    }
    if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.READ_PHONE_STATE)
            != PackageManager.PERMISSION_GRANTED){
        permissionList.add(Manifest.permission.READ_PHONE_STATE);
    }
    if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)
            != PackageManager.PERMISSION_GRANTED){
        permissionList.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
    }

    if (!permissionList.isEmpty()){
        String[]permissions=permissionList.toArray(new String[permissionList.size()]);
        ActivityCompat.requestPermissions(MainActivity.this,permissions,1);
    }else {
        requestLocation();
    }
}
项目:ywApplication    文件:BdLocationActivity.java   
private void initView() {
    // 获取地图控件引用
    mMapView = (MapView) findViewById(R.id.bmapView);
    mbaiduMap = mMapView.getMap();
    // 设置地图放大缩小参数
    MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(15.0f);
    mbaiduMap.setMapStatus(msu);
}
项目:RunHDU    文件:RunDetailsActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    SDKInitializer.initialize(getApplicationContext());
    setContentView(R.layout.activity_run_details);

    disText = (TextView) findViewById(R.id.dis_text_details);
    stepNumber = (NumberView) findViewById(R.id.step_text_details);
    speedNumber = (NumberView) findViewById(R.id.speed_text_details);
    dateNumber = (NumberView) findViewById(R.id.date_text_details);
    stepNumber = (NumberView) findViewById(R.id.step_text_details);
    durationNumber = (NumberView) findViewById(R.id.duration_details);
    energyNumber = (NumberView) findViewById(R.id.energy_details);
    startTimeNumber = (NumberView) findViewById(R.id.start_time_text_details);
    mapView = (MapView) findViewById(R.id.map_view_details);
    noTrailText = (TextView) findViewById(R.id.no_trail_text);
    floatInfo = (LinearLayout) findViewById(R.id.run_detail_float_info);
    mapView.showZoomControls(false);
    baiduMap = mapView.getMap();
    setToolbar(R.id.details_toolbar, true);

    Intent intent = getIntent();
    Bundle bundle = intent.getExtras();
    if (bundle != null) {
        //是否为好友的跑步信息
        isFriend = bundle.getBoolean("is_friend", false);
        //获得序列化runningInfo
        mRunningInfo = (RunningInfo) intent.getSerializableExtra("running_info");
        setAllData(mRunningInfo);
    } else {
        Toast.makeText(this, "发生异常。", Toast.LENGTH_SHORT).show();
        finish();
    }
}
项目:SmartButler    文件:LocationActivity.java   
private void initView()
{
    mapView= (MapView) findViewById(R.id.mapView);
    baiduMap=mapView.getMap();
    //允许显示我的位置
    baiduMap.setMyLocationEnabled(true);
    //声明LocationClient类
    mLocationClient = new LocationClient(getApplicationContext());
    //注册监听函数
    mLocationClient.registerLocationListener(myListener);
}
项目:VirtualLocation    文件:MainActivity.java   
@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);
}
项目:LifeHelper    文件:LocationActivity.java   
private void initView() {

        mMapView = (MapView) findViewById(R.id.bmapView);
        mBaiduMap = mMapView.getMap();

        //声明LocationClient类
        mLocationClient = new LocationClient(BaseApplication.getContext());
        //注册监听函数
        mLocationClient.registerLocationListener(myListener);

        initLocation();

        List<String> permissionList = new ArrayList<>();
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) !=
                PackageManager.PERMISSION_GRANTED) {
            permissionList.add(Manifest.permission.ACCESS_FINE_LOCATION);
        }
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.READ_PHONE_STATE) !=
                PackageManager.PERMISSION_GRANTED) {
            permissionList.add(Manifest.permission.READ_PHONE_STATE);
        }
        if (ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE) !=
                PackageManager.PERMISSION_GRANTED) {
            permissionList.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
        }
        if (!permissionList.isEmpty()) {
            String[] permissions = permissionList.toArray(new String[permissionList.size()]);
            ActivityCompat.requestPermissions(this, permissions, LOC_PER_CODE);
        } else {
            requestLocation();
        }



    }
项目:MapDemo    文件:MainActivity.java   
private void initView() {
    // 获取地图控件引用
    mMapView = (MapView) findViewById(R.id.bmapView);
    mbaiduMap = mMapView.getMap();
    MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(15.0f);
    mbaiduMap.setMapStatus(msu);
    list = new ArrayList<Marker>();

}
项目:LBSTest    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mLocationClient = new LocationClient(getApplicationContext());
    mLocationClient.registerLocationListener(new MyLocationListener());
    SDKInitializer.initialize(getApplicationContext());
    setContentView(R.layout.activity_main);
    mapView = (MapView) findViewById(R.id.bmapView);
    baiduMap = mapView.getMap();
    baiduMap.setMyLocationEnabled(true);
    positionText = (TextView) findViewById(R.id.position_text_view);
    List<String> permissionList = new ArrayList<>();
    if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED){
        permissionList.add(Manifest.permission.ACCESS_FINE_LOCATION);
    }

    if (ContextCompat.checkSelfPermission(MainActivity.this,Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED){
        permissionList.add(Manifest.permission.READ_PHONE_STATE);
    }

    if (ContextCompat.checkSelfPermission(MainActivity.this,Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED){
        permissionList.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
    }

    if (!permissionList.isEmpty()){
        String [] permissions = permissionList.toArray(new String[permissionList.size()]);
        ActivityCompat.requestPermissions(MainActivity.this,permissions,1);
    }else {
        requestLocation();
    }
}
项目:AndroidTest    文件:activity_baidu.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // ��ʹ��SDK�����֮ǰ��ʼ��context��Ϣ������ApplicationContext
    // ע��÷���Ҫ��setContentView����֮ǰʵ��
    SDKInitializer.initialize(getApplicationContext());
    setContentView(R.layout.activity_baidu);
    // ��ȡ��ͼ�ؼ�����
    mMapView = (MapView) findViewById(R.id.bmapView);
}
项目:TAG    文件:BaiduMapActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    instance = this;
    // Gl app = (Gl)this.getApplication();
    if (mBMapManager == null) {
        initEngineManager(this.getApplicationContext());
    }
    setContentView(R.layout.activity_baidumap);
    mMapView = (MapView) findViewById(R.id.bmapView);
    mMapController = mMapView.getController();
    sendButton = (Button) findViewById(R.id.btn_location_send);
    initMapView();

    mMapView.getController().setZoom(17);
    mMapView.getController().enableClick(true);
    mMapView.setBuiltInZoomControls(true);
    Intent intent = getIntent();
    double latitude = intent.getDoubleExtra("latitude", 0);
    if (latitude == 0) {
        showMapWithLocationClient();
    } else {
        double longtitude = intent.getDoubleExtra("longitude", 0);
        String address = intent.getStringExtra("address");
        showMap(latitude, longtitude, address);
    }
}