本文整理汇总了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));
}
示例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);
}
示例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();
}
示例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);
}
示例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;
}
}
示例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);
}
示例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));
}
}
示例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);
}
示例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()));
}
示例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;
}
}
示例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;
}
}
示例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));
}
});
}
示例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);
}
示例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);
}
示例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>();
}
}