com.baidu.mapapi.map.BitmapDescriptorFactory Java Examples

The following examples show how to use com.baidu.mapapi.map.BitmapDescriptorFactory. 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: 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 #2
Source File: LocationActivity.java    From imsdk-android with MIT License 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    PoiInfo info = (PoiInfo) adapter.getItem(position);
    if (info == null) {
        return;
    }
    name = info.name;
    address = info.address;
    latitude = info.location.latitude;
    longitude = info.location.longitude;
    LatLng point = new LatLng(latitude, longitude);
    OverlayOptions options = new MarkerOptions().draggable(false)
            .position(point)
            .icon(BitmapDescriptorFactory.fromResource(R.drawable.atom_ui_map_mark));
    if (overlay != null) {
        overlay.remove();
    }
    overlay = baiduMap.addOverlay(options);
    adapter.setCheckPosition(position);
    adapter.notifyDataSetChanged();
}
 
Example #3
Source File: PoiOverlay.java    From Mobike with Apache License 2.0 6 votes vote down vote up
@Override
public final List<OverlayOptions> getOverlayOptions() {
    if (mPoiResult == null || mPoiResult.getAllPoi() == null) {
        return null;
    }
    List<OverlayOptions> markerList = new ArrayList<OverlayOptions>();
    int markerSize = 0;
    for (int i = 0; i < mPoiResult.getAllPoi().size()
            && markerSize < MAX_POI_SIZE; i++) {
        if (mPoiResult.getAllPoi().get(i).location == null) {
            continue;
        }
        markerSize++;
        Bundle bundle = new Bundle();
        bundle.putInt("index", i);
        markerList.add(new MarkerOptions()
                .icon(BitmapDescriptorFactory.fromAssetWithDpi("Icon_mark"
                        + markerSize + ".png")).extraInfo(bundle)
                .position(mPoiResult.getAllPoi().get(i).location));
        
    }
    return markerList;
}
 
Example #4
Source File: IndoorPoiOverlay.java    From Mobike with Apache License 2.0 6 votes vote down vote up
@Override
public final List<OverlayOptions> getOverlayOptions() {
    if (mIndoorPoiResult == null || mIndoorPoiResult.getmArrayPoiInfo() == null) {
        return null;
    }
    List<OverlayOptions> markerList = new ArrayList<OverlayOptions>();
    int markerSize = 0;
    for (int i = 0; i < mIndoorPoiResult.getmArrayPoiInfo().size()
            && markerSize < MAX_POI_SIZE; i++) {
        if (mIndoorPoiResult.getmArrayPoiInfo().get(i).latLng == null) {
            continue;
        }
        markerSize++;
        Bundle bundle = new Bundle();
        bundle.putInt("index", i);
        markerList.add(new MarkerOptions()
                .icon(BitmapDescriptorFactory.fromAssetWithDpi("Icon_mark"
                        + markerSize + ".png")).extraInfo(bundle)
                .position(mIndoorPoiResult.getmArrayPoiInfo().get(i).latLng));

    }
    return markerList;
}
 
Example #5
Source File: MainActivity.java    From Mobike with Apache License 2.0 6 votes vote down vote up
private void initViews() {
    initKefuPopu();
    mTvPrices = (TextView) findViewById(R.id.tv_prices);
    mTvDistance = (TextView) findViewById(R.id.tv_distance);
    mMinute = (TextView) findViewById(R.id.minute);
    if (isNeedLogin) {
        mLogin.setVisibility(View.VISIBLE);
    } else {
        mLogin.setVisibility(View.GONE);
    }
    mScan_qrcode.setVisibility(View.VISIBLE);
    mBikeInfoBoard.setVisibility(View.GONE);
    mConfirm_cancle.setVisibility(View.GONE);
    mBikeOrderBoard.setVisibility(View.GONE);
    mBtLoginOrorder.setVisibility(View.GONE);
    mBikeInfoBoard.setVisibility(View.GONE);
    dragLocationIcon = BitmapDescriptorFactory.fromResource(R.mipmap.drag_location);
    bikeIcon = BitmapDescriptorFactory.fromResource(R.mipmap.bike_icon);
    setMyClickable(mTvAllmobike);
    baiduMap = mBaiduMap.getMap();
    baiduMap.setOnMapStatusChangeListener(changeListener);
}
 
Example #6
Source File: BaiduMapFragment.java    From BmapLite with GNU General Public License v3.0 6 votes vote down vote up
public void getFavoriteList() {
    if (null != mFavMarkerList && !mFavMarkerList.isEmpty()) {
        for (Overlay o : mFavMarkerList) {
            o.remove();
        }
        mFavMarkerList.clear();
    }
    if (null != mFavoriteInteracter) {
        List<MyPoiModel> favoriteList = mFavoriteInteracter.getFavoriteList();
        if (null != favoriteList && !favoriteList.isEmpty()) {
            for (MyPoiModel poi : favoriteList) {
                //构建Marker图标
                BitmapDescriptor bitmap = BitmapDescriptorFactory.fromResource(R.drawable.ic_grade_point);
                //构建MarkerOption,用于在地图上添加Marker
                OverlayOptions option = new MarkerOptions().title(poi.getName()).position(new LatLng(poi.getLatitude(), poi.getLongitude())).icon(bitmap).animateType(MarkerOptions.MarkerAnimateType.none).anchor(0.5f, 0.5f);
                //在地图上添加Marker,并显示
                mFavMarkerList.add(mBaiduMap.addOverlay(option));
            }
        }
    }
}
 
Example #7
Source File: SetFavoriteMapActivity.java    From AssistantBySDK with Apache License 2.0 6 votes vote down vote up
/**
 * 定位接收到的地址
 **/
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));
}
 
Example #8
Source File: BaiduMapFragment.java    From BmapLite with Apache License 2.0 6 votes vote down vote up
public void getFavoriteList() {
    if (null != mFavMarkerList && !mFavMarkerList.isEmpty()) {
        for (Overlay o : mFavMarkerList) {
            o.remove();
        }
        mFavMarkerList.clear();
    }
    if (null != mFavoriteInteracter) {
        List<MyPoiModel> favoriteList = mFavoriteInteracter.getFavoriteList();
        if (null != favoriteList && !favoriteList.isEmpty()) {
            for (MyPoiModel poi : favoriteList) {
                //构建Marker图标
                BitmapDescriptor bitmap = BitmapDescriptorFactory.fromResource(R.drawable.ic_grade_point);
                //构建MarkerOption,用于在地图上添加Marker
                OverlayOptions option = new MarkerOptions().title(poi.getName()).position(new LatLng(poi.getLatitude(), poi.getLongitude())).icon(bitmap).animateType(MarkerOptions.MarkerAnimateType.none).anchor(0.5f, 0.5f);
                //在地图上添加Marker,并显示
                mFavMarkerList.add(mBaiduMap.addOverlay(option));
            }
        }
    }
}
 
Example #9
Source File: PoiOverlay.java    From react-native-baidu-map with MIT License 6 votes vote down vote up
@Override
public final List<OverlayOptions> getOverlayOptions() {
    if (mPoiResult == null || mPoiResult.getAllPoi() == null) {
        return null;
    }

    List<OverlayOptions> markerList = new ArrayList<>();
    int markerSize = 0;

    for (int i = 0; i < mPoiResult.getAllPoi().size() && markerSize < MAX_POI_SIZE; i++) {
        if (mPoiResult.getAllPoi().get(i).location == null) {
            continue;
        }

        markerSize++;
        Bundle bundle = new Bundle();
        bundle.putInt("index", i);
        markerList.add(new MarkerOptions()
            .icon(BitmapDescriptorFactory.fromAssetWithDpi("Icon_mark" + markerSize + ".png"))
            .extraInfo(bundle)
            .position(mPoiResult.getAllPoi().get(i).location));
        
    }

    return markerList;
}
 
Example #10
Source File: IndoorPoiOverlay.java    From react-native-baidu-map with MIT License 6 votes vote down vote up
@Override
public final List<OverlayOptions> getOverlayOptions() {
    if (mIndoorPoiResult == null || mIndoorPoiResult.getmArrayPoiInfo() == null) {
        return null;
    }
    List<OverlayOptions> markerList = new ArrayList<OverlayOptions>();
    int markerSize = 0;
    for (int i = 0; i < mIndoorPoiResult.getmArrayPoiInfo().size()
            && markerSize < MAX_POI_SIZE; i++) {
        if (mIndoorPoiResult.getmArrayPoiInfo().get(i).latLng == null) {
            continue;
        }
        markerSize++;
        Bundle bundle = new Bundle();
        bundle.putInt("index", i);
        markerList.add(new MarkerOptions()
                .icon(BitmapDescriptorFactory.fromAssetWithDpi("Icon_mark"
                        + markerSize + ".png")).extraInfo(bundle)
                .position(mIndoorPoiResult.getmArrayPoiInfo().get(i).latLng));

    }
    return markerList;
}
 
Example #11
Source File: MapPickerActivity.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int position, long l) {
    // 通知是适配器第position个item被选择了
    mAdapter.setNotifyTip(position);
    mAdapter.notifyDataSetChanged();
    BitmapDescriptor mSelectIco = BitmapDescriptorFactory
            .fromResource(R.drawable.picker_map_geo_icon);
    mBaiduMap.clear();
    PoiInfo info = (PoiInfo) mAdapter.getItem(position);
    LatLng la = info.location;
    // 动画跳转
    MapStatusUpdate u = MapStatusUpdateFactory.newLatLng(la);
    mBaiduMap.animateMapStatus(u);
    // 添加覆盖物
    OverlayOptions ooA = new MarkerOptions().position(la)
            .icon(mSelectIco).anchor(0.5f, 0.5f);
    mBaiduMap.addOverlay(ooA);
    mLoactionLatLng = info.location;
    mAddress = info.address;
    mName = info.name;
    mCity = info.city;

    mLatitude = info.location.latitude;
    mLongitude = info.location.longitude;
    mStreet = info.name;//地图对应位置文字描述
}
 
Example #12
Source File: MapActivity.java    From BaiduMap-TrafficAssistant with MIT License 5 votes vote down vote up
private void initLocation() {

		mLocationMode = LocationMode.NORMAL;

		mLocationClient = new LocationClient(this);
		mLocationListener = new MyLocationListener();
		mLocationClient.registerLocationListener(mLocationListener);

		LocationClientOption option = new LocationClientOption();
		option.setCoorType("bd09ll");
		option.setIsNeedAddress(true);
		option.setOpenGps(true);
		option.setScanSpan(1000);// 设置定位一秒钟请求一次;

		mLocationClient.setLocOption(option);

		// 初始化图标
		mIconLocation = BitmapDescriptorFactory
				.fromResource(R.drawable.navi_map_gps_locked);

		myOrientationListener = new MyOrientationListener(context);

		myOrientationListener
				.setOnOrientationListener(new OnOrientationListener() {

					@Override
					public void onOrientationChanged(float x) {

						mCurrentX = x;
					}
				});

	}
 
Example #13
Source File: EaseBaiduMapActivity.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
@Override
public void onReceiveLocation(BDLocation location) {
	if (location == null) {
		return;
	}
	Log.d("map", "On location change received:" + location);
	Log.d("map", "addr:" + location.getAddrStr());
	sendButton.setEnabled(true);
	if (progressDialog != null) {
		progressDialog.dismiss();
	}

	if (lastLocation != null) {
		if (lastLocation.getLatitude() == location.getLatitude() && lastLocation.getLongitude() == location.getLongitude()) {
			Log.d("map", "same location, skip refresh");
			// mMapView.refresh(); //need this refresh?
			return;
		}
	}
	lastLocation = location;
	mBaiduMap.clear();
	LatLng llA = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude());
	CoordinateConverter converter= new CoordinateConverter();
	converter.coord(llA);
	converter.from(CoordinateConverter.CoordType.COMMON);
	LatLng convertLatLng = converter.convert();
	OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory
			.fromResource(R.drawable.ease_icon_marka))
			.zIndex(4).draggable(true);
	mBaiduMap.addOverlay(ooA);
	MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f);
	mBaiduMap.animateMapStatus(u);
}
 
Example #14
Source File: BaiduMapActivity.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onReceiveLocation(BDLocation location) {
	if (location == null) {
		return;
	}
	Log.d("map", "On location change received:" + location);
	Log.d("map", "addr:" + location.getAddrStr());
	sendButton.setEnabled(true);
	if (progressDialog != null) {
		progressDialog.dismiss();
	}

	if (lastLocation != null) {
		if (lastLocation.getLatitude() == location.getLatitude() && lastLocation.getLongitude() == location.getLongitude()) {
			Log.d("map", "same location, skip refresh");
			// mMapView.refresh(); //need this refresh?
			return;
		}
	}
	lastLocation = location;
	mBaiduMap.clear();
	LatLng llA = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude());
	CoordinateConverter converter= new CoordinateConverter();
	converter.coord(llA);
	converter.from(CoordinateConverter.CoordType.COMMON);
	LatLng convertLatLng = converter.convert();
	OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory
			.fromResource(R.drawable.icon_marka))
			.zIndex(4).draggable(true);
	mBaiduMap.addOverlay(ooA);
	MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f);
	mBaiduMap.animateMapStatus(u);
}
 
Example #15
Source File: BaiduMapActivity.java    From FanXin-based-HuanXin with GNU General Public License v2.0 5 votes vote down vote up
private void showMap(double latitude, double longtitude, String address) {
	sendButton.setVisibility(View.GONE);
	LatLng llA = new LatLng(latitude, longtitude);
	CoordinateConverter converter= new CoordinateConverter();
	converter.coord(llA);
	converter.from(CoordinateConverter.CoordType.COMMON);
	LatLng convertLatLng = converter.convert();
	OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory
			.fromResource(R.drawable.icon_marka))
			.zIndex(4).draggable(true);
	mBaiduMap.addOverlay(ooA);
	MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f);
	mBaiduMap.animateMapStatus(u);
}
 
Example #16
Source File: DefaultClusterRenderer.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
/**
 * Called before the marker for a Cluster is added to the map.
 * The default implementation draws a circle with a rough count of the number of items.
 */
protected void onBeforeClusterRendered(Cluster<T> cluster, MarkerOptions markerOptions) {
    int bucket = getBucket(cluster);
    BitmapDescriptor descriptor = mIcons.get(bucket);
    if (descriptor == null) {
        mColoredCircleBackground.getPaint().setColor(getColor(bucket));
        descriptor = BitmapDescriptorFactory.fromBitmap(mIconGenerator.makeIcon(getClusterText(bucket)));
        mIcons.put(bucket, descriptor);
    }
    // TODO: consider adding anchor(.5, .5) (Individual markers will overlap more often)
    markerOptions.icon(descriptor);
}
 
Example #17
Source File: DrivingRouteOverlay.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
public List<BitmapDescriptor> getCustomTextureList() {
    ArrayList<BitmapDescriptor> list = new ArrayList<BitmapDescriptor>();
    list.add(BitmapDescriptorFactory.fromAsset("Icon_road_blue_arrow.png"));
    list.add(BitmapDescriptorFactory.fromAsset("Icon_road_green_arrow.png"));
    list.add(BitmapDescriptorFactory.fromAsset("Icon_road_yellow_arrow.png"));
    list.add(BitmapDescriptorFactory.fromAsset("Icon_road_red_arrow.png"));
    list.add(BitmapDescriptorFactory.fromAsset("Icon_road_nofocus.png"));
    return list;
}
 
Example #18
Source File: MassTransitRouteOverlay.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
private BitmapDescriptor getIconForStep(MassTransitRouteLine.TransitStep step) {
    switch (step.getVehileType()) {
        case ESTEP_WALK:
            return BitmapDescriptorFactory.fromAssetWithDpi("Icon_walk_route.png");
        case ESTEP_TRAIN:
            return BitmapDescriptorFactory.fromAssetWithDpi("Icon_subway_station.png");
        case ESTEP_DRIVING:
        case ESTEP_COACH:
        case ESTEP_PLANE:
        case ESTEP_BUS:
            return BitmapDescriptorFactory.fromAssetWithDpi("Icon_bus_station.png");
        default:
            return null;
    }
}
 
Example #19
Source File: MapFragment.java    From MapForTour with MIT License 5 votes vote down vote up
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    application = (DeviceMessageApplication) getActivity().getApplication();
    //地图覆盖物初始化
    bitmapDescriptorMan = BitmapDescriptorFactory.fromResource(R.mipmap.map_portrait_mark_man_circle);
    bitmapDescriptorWoman = BitmapDescriptorFactory.fromResource(R.mipmap.map_portrait_mark_woman_circle);
    bmStart = BitmapDescriptorFactory.fromResource(R.mipmap.icon_start);
    bmEnd = BitmapDescriptorFactory.fromResource(R.mipmap.icon_end);
    option = new MarkerOptions();
    geoCoder = GeoCoder.newInstance();
    geoCoder.setOnGetGeoCodeResultListener(this);
    reverseGeoCodeOption = new ReverseGeoCodeOption();

    //管理员权限用户信息弹窗初始化
    viewOverlayItem = View.inflate(getContext(), R.layout.item_map_addoverlay_radarnearby_admin, null);
    tvAddOverlayItemUserID = (TextView) viewOverlayItem.findViewById(R.id.tvAddOverlayItemUserID);
    imageViewAddOverlayItem = (ImageView) viewOverlayItem.findViewById(R.id.imageViewAddOverlayItem);
    tvAddOverlayGeoCoder = (TextView) viewOverlayItem.findViewById(R.id.tvAddOverlayGeoCoder);
    tvAddOverlayItemDistance = (TextView) viewOverlayItem.findViewById(R.id.tvAddOverlayItemDistance);
    tvAddOverlayItemLatlng = (TextView) viewOverlayItem.findViewById(R.id.tvAddOverlayItemLatlng);
    layoutAddOverlayRadarNearbyItem = (LinearLayout) viewOverlayItem.findViewById(R.id.layoutAddOverlayRadarNearbyItem);
    btnAddOverlayItemTrackQuery = (Button) viewOverlayItem.findViewById(R.id.btnAddOverlayItemTrackQuery);
    btnAddOverlayItemGeoFencePlace = (Button) viewOverlayItem.findViewById(R.id.btnAddOverlayItemGeoFencePlace);
    btnAddOverlayItemTrackQuery.setOnClickListener(this);
    btnAddOverlayItemGeoFencePlace.setOnClickListener(this);


}
 
Example #20
Source File: EaseBaiduMapActivity.java    From Study_Android_Demo with Apache License 2.0 5 votes vote down vote up
private void showMap(double latitude, double longtitude, String address) {
	sendButton.setVisibility(View.GONE);
	LatLng llA = new LatLng(latitude, longtitude);
	CoordinateConverter converter= new CoordinateConverter();
	converter.coord(llA);
	converter.from(CoordinateConverter.CoordType.COMMON);
	LatLng convertLatLng = converter.convert();
	OverlayOptions ooA = new MarkerOptions().position(convertLatLng).icon(BitmapDescriptorFactory
			.fromResource(R.drawable.ease_icon_marka))
			.zIndex(4).draggable(true);
	mBaiduMap.addOverlay(ooA);
	MapStatusUpdate u = MapStatusUpdateFactory.newLatLngZoom(convertLatLng, 17.0f);
	mBaiduMap.animateMapStatus(u);
}
 
Example #21
Source File: MassTransitRouteOverlay.java    From Mobike with Apache License 2.0 5 votes vote down vote up
private BitmapDescriptor getIconForStep(MassTransitRouteLine.TransitStep step) {
    switch (step.getVehileType()) {
        case ESTEP_WALK:
            return BitmapDescriptorFactory.fromAssetWithDpi("Icon_walk_route.png");
        case ESTEP_TRAIN:
            return BitmapDescriptorFactory.fromAssetWithDpi("Icon_subway_station.png");
        case ESTEP_DRIVING:
        case ESTEP_COACH:
        case ESTEP_PLANE:
        case ESTEP_BUS:
            return BitmapDescriptorFactory.fromAssetWithDpi("Icon_bus_station.png");
        default:
            return null;
    }
}
 
Example #22
Source File: TransitRouteOverlay.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
private BitmapDescriptor getIconForStep(TransitRouteLine.TransitStep step) {
    switch (step.getStepType()) {
        case BUSLINE:
            return BitmapDescriptorFactory.fromAssetWithDpi("Icon_bus_station.png");
        case SUBWAY:
            return BitmapDescriptorFactory.fromAssetWithDpi("Icon_subway_station.png");
        case WAKLING:
            return BitmapDescriptorFactory.fromAssetWithDpi("Icon_walk_route.png");
        default:
            return null;
    }
}
 
Example #23
Source File: FreightTrackMapWithWebViewFragment.java    From ESeal with Apache License 2.0 5 votes vote down vote up
@Override
public void showBaiduMap(LocationDetail locationDetail) {
    if (locationDetail == null || locationDetail.isInvalid()) {
        return;
    }
    LatLng lng = locationDetail.getLatLng();

    OverlayOptions markerOptions = new MarkerOptions().flat(true).icon(BitmapDescriptorFactory
            .fromResource(R.drawable.ic_location_on_white_48dp)).position(lng);
    mMoveMarker = (Marker) mBaiduMap.addOverlay(markerOptions);

    //设置中心点
    mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLngZoom(lng, 16));
}
 
Example #24
Source File: FreightTrackBaiduMapFragment.java    From ESeal with Apache License 2.0 5 votes vote down vote up
private void showBaiduMap(LocationDetail locationDetail) {
    if (locationDetail == null || locationDetail.isInvalid()) {
        return;
    }
    LatLng lng = locationDetail.getLatLng();

    OverlayOptions markerOptions = new MarkerOptions().flat(true).icon(BitmapDescriptorFactory
            .fromResource(R.drawable.ic_location_on_white_48dp)).position(lng);
    mMoveMarker = (Marker) mBaiduMap.addOverlay(markerOptions);

    //设置中心点
    mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLngZoom(lng, 16));
}
 
Example #25
Source File: MapActivity.java    From foodie-app with Apache License 2.0 5 votes vote down vote up
private void startLocationOverlap() {
    //开启定位图层
    mBaiduMap.setMyLocationEnabled(true);
    //构造定位数据
    MyLocationData locData = new MyLocationData.Builder()
            .accuracy(mLocation.getRadius())
            // 此处设置开发者获取到的方向信息,顺时针0-360
            .direction(100).latitude(mLocation.getLatitude())
            .longitude(mLocation.getLongitude()).build();
    // 设置定位数据
    mBaiduMap.setMyLocationData(locData);
    // 设置定位图层的配置(定位模式,是否允许方向信息,用户自定义定位图标)
    //构建Marker图标
    BitmapDescriptor bitmap = BitmapDescriptorFactory
            .fromResource(R.drawable.my_location);
    //bitmap.
    MyLocationConfiguration config = new MyLocationConfiguration(MyLocationConfiguration.LocationMode.NORMAL, true, bitmap);
    mBaiduMap.setMyLocationConfigeration(config);
    //中心点为我的位置
    LatLng cenpt = new LatLng(locData.latitude, locData.longitude);
    //定义地图状态
    MapStatus mMapStatus = new MapStatus.Builder()
            .target(cenpt)
            .zoom(mCurrentLevel)
            .build();
    //定义MapStatusUpdate对象,以便描述地图状态将要发生的变化
    MapStatusUpdate mMapStatusUpdate = MapStatusUpdateFactory.newMapStatus(mMapStatus);
    //改变地图状态
    mBaiduMap.setMapStatus(mMapStatusUpdate);
    // 当不需要定位图层时关闭定位图层
    //mBaiduMap.setMyLocationEnabled(false);
}
 
Example #26
Source File: MainActivity.java    From Mobike with Apache License 2.0 5 votes vote down vote up
private void initNearestBike(final BikeInfo bikeInfo, LatLng latLng) {
    ImageView nearestIcon = new ImageView(getApplicationContext());
    nearestIcon.setImageResource(R.mipmap.nearest_icon);
    InfoWindow.OnInfoWindowClickListener listener = null;
    listener = new InfoWindow.OnInfoWindowClickListener() {
        public void onInfoWindowClick() {
            updateBikeInfo(bikeInfo);
            baiduMap.hideInfoWindow();
        }
    };
    InfoWindow mInfoWindow = new InfoWindow(BitmapDescriptorFactory.fromView(nearestIcon), latLng, -108, listener);
    baiduMap.showInfoWindow(mInfoWindow);
}
 
Example #27
Source File: MainActivity.java    From Mobike with Apache License 2.0 5 votes vote down vote up
@Override
public BitmapDescriptor getTerminalMarker() {
    //            if (useDefaultIcon) {
    return BitmapDescriptorFactory.fromResource(R.mipmap.transparent_icon);
    //            }
    //            return null;
}
 
Example #28
Source File: MainActivity.java    From Mobike with Apache License 2.0 5 votes vote down vote up
@Override
public BitmapDescriptor getStartMarker() {
    //            if (useDefaultIcon) {
    return BitmapDescriptorFactory.fromResource(R.mipmap.transparent_icon);
    //            }
    //            return null;
}
 
Example #29
Source File: DrivingRouteOverlay.java    From Mobike with Apache License 2.0 5 votes vote down vote up
public List<BitmapDescriptor> getCustomTextureList() {
    ArrayList<BitmapDescriptor> list = new ArrayList<BitmapDescriptor>();
    list.add(BitmapDescriptorFactory.fromAsset("Icon_road_blue_arrow.png"));
    list.add(BitmapDescriptorFactory.fromAsset("Icon_road_green_arrow.png"));
    list.add(BitmapDescriptorFactory.fromAsset("Icon_road_yellow_arrow.png"));
    list.add(BitmapDescriptorFactory.fromAsset("Icon_road_red_arrow.png"));
    list.add(BitmapDescriptorFactory.fromAsset("Icon_road_nofocus.png"));
    return list;
}
 
Example #30
Source File: TransitRouteOverlay.java    From Mobike with Apache License 2.0 5 votes vote down vote up
private BitmapDescriptor getIconForStep(TransitRouteLine.TransitStep step) {
    switch (step.getStepType()) {
        case BUSLINE:
            return BitmapDescriptorFactory.fromAssetWithDpi("Icon_bus_station.png");
        case SUBWAY:
            return BitmapDescriptorFactory.fromAssetWithDpi("Icon_subway_station.png");
        case WAKLING:
            return BitmapDescriptorFactory.fromAssetWithDpi("Icon_walk_route.png");
        default:
            return null;
    }
}