當前位置: 首頁>>代碼示例>>Java>>正文


Java BaiduMap類代碼示例

本文整理匯總了Java中com.baidu.mapapi.map.BaiduMap的典型用法代碼示例。如果您正苦於以下問題:Java BaiduMap類的具體用法?Java BaiduMap怎麽用?Java BaiduMap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BaiduMap類屬於com.baidu.mapapi.map包,在下文中一共展示了BaiduMap類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: locationReceiveAddress

import com.baidu.mapapi.map.BaiduMap; //導入依賴的package包/類
/**
 * 定位接收到的地址
 **/
private void locationReceiveAddress() {
    if (receiveAddress == null) {
        return;
    }
    LatLng p = new LatLng(receiveAddress.getLatitude(), receiveAddress.getLongitude());
    MarkerOptions markerOptions = new MarkerOptions();
    /* 設置覆蓋物圖標 */
    markerOptions.icon(BitmapDescriptorFactory.fromResource(R.drawable.icon_openmap_focuse_mark))
            .position(p)
            .visible(true);
    baiduMap.setOnMarkerClickListener(new BaiduMap.OnMarkerClickListener() {
        @Override
        public boolean onMarkerClick(Marker marker) {
            setSinglePoiDetail();
            return true;
        }
    });
    if (NetUtil.getInstance(SetFavoriteMapActivity.this).getCurrentNetType().equals(NetUtil.NetType.NETWORK_TYPE_NONE)) {
        // Snackbar.make(mAmosfPoiList,mAppConfig.getResources().getString(R.string.no_network), Snackbar.LENGTH_SHORT).show();
        return;
    }
    /* 添加覆蓋圖層 */
    baiduMap.addOverlay(markerOptions);
    baiduMap.setMapStatus(MapStatusUpdateFactory.newLatLngZoom(p, 17F));
}
 
開發者ID:LingjuAI,項目名稱:AssistantBySDK,代碼行數:29,代碼來源:SetFavoriteMapActivity.java

示例2: initMapSetting

import com.baidu.mapapi.map.BaiduMap; //導入依賴的package包/類
private void initMapSetting() {

        mMapView.showZoomControls(false);

        mBaiduMap = mMapView.getMap();
        // 開啟定位圖層
        mBaiduMap.setMyLocationEnabled(true);
        //設置指南針
//        UiSettings uiSettings = mBaiduMap.getUiSettings();
//        uiSettings.setCompassEnabled(true);

        mBaiduMap.setCompassPosition(new Point(660,60));

        //設置普通地圖
        mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
        //設置定位圖層配置信息,隻有先允許定位圖層後設置定位圖層配置信息才會生效
        mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration(
                MyLocationConfiguration.LocationMode.NORMAL, false, null));
        mBaiduMap.setBuildingsEnabled(false);

        //設置縮放級別
        MapStatusUpdate msu = MapStatusUpdateFactory.zoomTo(16.0f);
        mBaiduMap.setMapStatus(msu);

    }
 
開發者ID:funnyzhaov,項目名稱:Tribe,代碼行數:26,代碼來源:NearbyFragment.java

示例3: onMapStatusChange

import com.baidu.mapapi.map.BaiduMap; //導入依賴的package包/類
@Override
    public void onMapStatusChange(MapStatus mapStatus) {
        int currentClusterSize = mMarkerManager.getCollectionSize();
//        Log.d("----", "onMapStatusChange: 地圖狀態正在改變:"+currentClusterSize);
        //地圖的狀態不停的改變,當聚合物集合的大小發生改變的時候,需要將recyclerView的顯示給去掉
        if(currentClusterSize != mLastClusterSize){
            //取消recyclerView的顯示,需要數據源和adapter的對象
            mBaiduMap.hideInfoWindow();
        }

        if (mRenderer instanceof BaiduMap.OnMapStatusChangeListener) {
            ((BaiduMap.OnMapStatusChangeListener) mRenderer).onMapStatusChange(mapStatus);
        }

        // Don't re-compute clusters if the map has just been panned/tilted/rotated.
        MapStatus position = mMap.getMapStatus();
        if (mPreviousCameraPosition != null && mPreviousCameraPosition.zoom == position.zoom) {
            return;
        }
        mPreviousCameraPosition = mMap.getMapStatus();

        cluster();
    }
 
開發者ID:funnyzhaov,項目名稱:Tribe,代碼行數:24,代碼來源:ClusterManager.java

示例4: onCreate

import com.baidu.mapapi.map.BaiduMap; //導入依賴的package包/類
@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);
}
 
開發者ID:zhangxx0,項目名稱:FirstCodeUtil,代碼行數:21,代碼來源:AtyLocationBaiduMap.java

示例5: getMapType

import com.baidu.mapapi.map.BaiduMap; //導入依賴的package包/類
public int getMapType(Context context) {
	final SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(context);
	String mapType = sharedPref.getString(PREF_MAP_TYPE, DEFAULT_MAP_TYPE);

	if (mapType.equalsIgnoreCase(MAP_TYPE_SATELLITE)) {
		return BaiduMap.MAP_TYPE_SATELLITE;
	}
	else if (mapType.equalsIgnoreCase(MAP_TYPE_NORMAL)) {
		return BaiduMap.MAP_TYPE_NORMAL;
	}
	else if (mapType.equalsIgnoreCase(MAP_TYPE_NONE)) {
		return BaiduMap.MAP_TYPE_NONE;
	}
	else {
		return BaiduMap.MAP_TYPE_SATELLITE;
	}
}
 
開發者ID:mxiao6,項目名稱:Tower-develop,代碼行數:18,代碼來源:BaiduMapPrefFragment.java

示例6: updateBDMapStatus

import com.baidu.mapapi.map.BaiduMap; //導入依賴的package包/類
private void updateBDMapStatus(BDLocation location) {
    final BaiduMap map = getBaiduMap();
    final BaiduMapPrefFragment provider = (BaiduMapPrefFragment)(getProvider().getMapProviderPreferences());
    final Context context = getActivity().getApplicationContext();

    int mapType = provider.getMapType(context);
    map.setMapType(mapType);

    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(location.getRadius())
            .latitude(location.getLatitude())
            .longitude(location.getLongitude()).build();
    map.setMyLocationData(locData);

    LatLng ll = new LatLng(location.getLatitude(), location.getLongitude());
    MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(ll);
    map.animateMapStatus(u);
}
 
開發者ID:mxiao6,項目名稱:Tower-develop,代碼行數:19,代碼來源:BaiduMapFragment.java

示例7: updatePolygonsPaths

import com.baidu.mapapi.map.BaiduMap; //導入依賴的package包/類
@Override
  public void updatePolygonsPaths(List<List<LatLong>> paths) {
      final BaiduMap map = getBaiduMap();
if (map == null) return;

      for (Polygon poly : mPolygonsPaths) {
          poly.remove();
      }

      for (List<LatLong> contour : paths) {
          PolygonOptions pathOptions = new PolygonOptions();
          pathOptions.fillColor(POLYGONS_PATH_DEFAULT_COLOR);
	final List<LatLng> pathPoints = new ArrayList<LatLng>(contour.size());
          for (LatLong coord : contour) {
              pathPoints.add(MapUtils.coordToBaiduLatLng(coord));
          }
          pathOptions.points(pathPoints);
          mPolygonsPaths.add((Polygon)map.addOverlay(pathOptions));
      }

  }
 
開發者ID:mxiao6,項目名稱:Tower-develop,代碼行數:22,代碼來源:BaiduMapFragment.java

示例8: addCameraFootprint

import com.baidu.mapapi.map.BaiduMap; //導入依賴的package包/類
@Override
  public void addCameraFootprint(FootPrint footprintToBeDraw) {
      final BaiduMap map = getBaiduMap();
if (map == null) return;

      PolygonOptions pathOptions = new PolygonOptions();
pathOptions.stroke(mFootprintStroke);
      pathOptions.fillColor(FOOTPRINT_FILL_COLOR);

      final List<LatLng> pathPoints = new ArrayList<LatLng>(footprintToBeDraw.getVertexInGlobalFrame().size());
      for (LatLong coord : footprintToBeDraw.getVertexInGlobalFrame()) {
          pathPoints.add(MapUtils.coordToBaiduLatLng(coord));
      }
      pathOptions.points(pathPoints);

      map.addOverlay(pathOptions);

  }
 
開發者ID:mxiao6,項目名稱:Tower-develop,代碼行數:19,代碼來源:BaiduMapFragment.java

示例9: loadCameraPosition

import com.baidu.mapapi.map.BaiduMap; //導入依賴的package包/類
@Override
  public void loadCameraPosition() {
      final BaiduMap map = getBaiduMap();
if (map == null) return;

final SharedPreferences settings = mAppPrefs.prefs;
final MapStatus.Builder camera = new MapStatus.Builder();

camera.rotate(settings.getFloat(PREF_BEA, DEFAULT_BEARING));
camera.overlook(settings.getFloat(PREF_TILT, DEFAULT_TILT));
camera.zoom(settings.getFloat(PREF_ZOOM, DEFAULT_ZOOM_LEVEL));
camera.target(new LatLng(settings.getFloat(PREF_LAT, DEFAULT_LATITUDE),
              settings.getFloat(PREF_LNG, DEFAULT_LONGITUDE)));

map.setMapStatus(MapStatusUpdateFactory.newMapStatus(camera.build()));
  }
 
開發者ID:mxiao6,項目名稱:Tower-develop,代碼行數:17,代碼來源:BaiduMapFragment.java

示例10: setMapMode

import com.baidu.mapapi.map.BaiduMap; //導入依賴的package包/類
/**
 * 設置底圖顯示模式
 *
 * @param view
 */
public void setMapMode(View view) {
    boolean checked = ((RadioButton) view).isChecked();
    switch (view.getId()) {
        case R.id.normal:
            if (checked) {
                mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);
            }
            break;
        case R.id.statellite:
            if (checked) {
                mBaiduMap.setMapType(BaiduMap.MAP_TYPE_SATELLITE);
            }
            break;
        default:
            break;
    }
}
 
開發者ID:CrazyRunning,項目名稱:MyStudyHelper,代碼行數:23,代碼來源:MapActivity.java

示例11: onClick

import com.baidu.mapapi.map.BaiduMap; //導入依賴的package包/類
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.btn1:
            mBaiduMap.setMapType(BaiduMap.MAP_TYPE_NORMAL);//普通地圖
            break;
        case R.id.btn2:
            mBaiduMap.setMapType(BaiduMap.MAP_TYPE_SATELLITE);//衛星地圖
            break;
        case R.id.btn3:
            mBaiduMap.setTrafficEnabled(true);//交通
            break;
        case R.id.btn4:
            mBaiduMap.setBaiduHeatMapEnabled(true);//熱力
            break;
    }
}
 
開發者ID:ByteJump,項目名稱:MyApp,代碼行數:18,代碼來源:fragment1.java

示例12: initView

import com.baidu.mapapi.map.BaiduMap; //導入依賴的package包/類
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));
        }
    });
}
 
開發者ID:PengZhiPeng,項目名稱:Mooc-map,代碼行數:25,代碼來源:MainActivity.java

示例13: initViews

import com.baidu.mapapi.map.BaiduMap; //導入依賴的package包/類
@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);
}
 
開發者ID:mjd507,項目名稱:zsyy,代碼行數:27,代碼來源:HospitalPeripheryNavigationActivity.java

示例14: getExtendedBounds

import com.baidu.mapapi.map.BaiduMap; //導入依賴的package包/類
public static MBound getExtendedBounds(BaiduMap map, MBound bound, Integer gridSize) {
	// Log.d("getExtendBounds", "size:"+gridSize);
	MBound tbounds = cutBoundsInRange(bound);
	System.out.println("getExtendedBounds---" + tbounds.getRightTop() + tbounds.getLeftBottom());

	Projection projection = map.getProjection();
	Point pixelNE = new Point();
	Point pixelSW = new Point();

	pixelNE = projection.toScreenLocation(tbounds.getRightTop());
	pixelSW = projection.toScreenLocation(tbounds.getLeftBottom());
	System.out.println("前pixelNE:" + pixelNE + "pixelSW:" + pixelSW);

	pixelNE.x += gridSize;
	pixelNE.y += gridSize;
	pixelSW.x -= gridSize;
	pixelSW.y -= gridSize;
	System.out.println("後pixelNE:" + pixelNE + "pixelSW:" + pixelSW);
	LatLng rightTop = projection.fromScreenLocation(pixelNE);
	LatLng leftBottom = projection.fromScreenLocation(pixelSW);
	System.out.println("getExtendedBounds---" + "rightTop:" + rightTop + "leftBottom:" + leftBottom);

	return new MBound(rightTop, leftBottom);
}
 
開發者ID:poomoo,項目名稱:eDao,代碼行數:25,代碼來源:Utity.java

示例15: OverlayManager

import com.baidu.mapapi.map.BaiduMap; //導入依賴的package包/類
/**
 * 通過一個BaiduMap 對象構造
 * 
 * @param baiduMap
 */
public OverlayManager(BaiduMap baiduMap) {
    mBaiduMap = baiduMap;
    // mBaiduMap.setOnMarkerClickListener(this);
    if (mOverlayOptionList == null) {
        mOverlayOptionList = new ArrayList<OverlayOptions>();
    }
    if (mOverlayList == null) {
        mOverlayList = new ArrayList<Overlay>();
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:16,代碼來源:OverlayManager.java


注:本文中的com.baidu.mapapi.map.BaiduMap類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。