com.baidu.mapapi.map.BitmapDescriptor Java Examples

The following examples show how to use com.baidu.mapapi.map.BitmapDescriptor. 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: 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 #3
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 #4
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 #5
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 #6
Source File: BitmapUtil.java    From react-native-baidu-map with MIT License 5 votes vote down vote up
public static BitmapDescriptor createBitmapDescriptor(View view, int width, int height) {
    if (width > 0 && height > 0) {
        view.layout(0, 0, width, height);
    } else if (view.getMeasuredWidth() == 0 || view.getMeasuredHeight() == 0) {
        view.layout(0, 0, view.getMeasuredWidth() > 0 ? view.getMeasuredWidth() : 50, view.getMeasuredHeight() > 0 ? view.getMeasuredHeight() : 100);
    }
    view.buildDrawingCache();
    BitmapDescriptor bitmapDescriptor = BitmapDescriptorFactory.fromBitmap(view.getDrawingCache());
    view.destroyDrawingCache();
    return bitmapDescriptor;
}
 
Example #7
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 #8
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 #9
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 #10
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 #11
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 #12
Source File: BusLineOverlay.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
public BitmapDescriptor getStationMarker() {
    if (type == PoiInfo.POITYPE.SUBWAY_LINE){
        return BitmapDescriptorFactory.fromAssetWithDpi("icon_subway_station.png");
    }else {
        return BitmapDescriptorFactory.fromAssetWithDpi("icon_bus_station.png");
    }
}
 
Example #13
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 #14
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 #15
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;
    }
}
 
Example #16
Source File: BaiduMapFragment.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
private void makeRangingMarker(MyPoiModel poi) {
    //构建Marker图标
    ImageView imageView = new ImageView(getActivity());
    imageView.setImageResource(R.drawable.shape_point);
    BitmapDescriptor bitmap = BitmapDescriptorFactory.fromView(imageView);
    //构建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,并显示

    Overlay marker = mBaiduMap.addOverlay(option);

    mOverlayList.add(marker);
}
 
Example #17
Source File: DrivingRouteOverlay.java    From BmapLite 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 #18
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 #19
Source File: TransitRouteOverlay.java    From BmapLite with GNU General Public License v3.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;
    }
}
 
Example #20
Source File: MassTransitRouteOverlay.java    From BmapLite with GNU General Public License v3.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 #21
Source File: DrivingRouteOverlay.java    From BmapLite with GNU General Public License v3.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 #22
Source File: BaiduMapFragment.java    From BmapLite with GNU General Public License v3.0 5 votes vote down vote up
private void makeRangingMarker(MyPoiModel poi) {
    //构建Marker图标
    ImageView imageView = new ImageView(getActivity());
    imageView.setImageResource(R.drawable.shape_point);
    BitmapDescriptor bitmap = BitmapDescriptorFactory.fromView(imageView);
    //构建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,并显示

    Overlay marker = mBaiduMap.addOverlay(option);

    mOverlayList.add(marker);
}
 
Example #23
Source File: BusLineOverlay.java    From BmapLite with Apache License 2.0 5 votes vote down vote up
public BitmapDescriptor getStationMarker() {
    if (type == PoiInfo.POITYPE.SUBWAY_LINE){
        return BitmapDescriptorFactory.fromAssetWithDpi("icon_subway_station.png");
    }else {
        return BitmapDescriptorFactory.fromAssetWithDpi("icon_bus_station.png");
    }
}
 
Example #24
Source File: MassTransitRouteOverlay.java    From BmapLite 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 #25
Source File: TransitRouteOverlay.java    From BmapLite 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;
    }
}
 
Example #26
Source File: BikingRouteOverlay.java    From BmapLite with Apache License 2.0 4 votes vote down vote up
public List<BitmapDescriptor> getCustomTextureList() {
    ArrayList<BitmapDescriptor> list = new ArrayList<BitmapDescriptor>();
    list.add(BitmapDescriptorFactory.fromAsset("Icon_road_blue_arrow.png"));
    return list;
}
 
Example #27
Source File: BitmapUtil.java    From react-native-baidu-map with MIT License 4 votes vote down vote up
public static BitmapDescriptor createBitmapDescriptor(View view) {
    return createBitmapDescriptor(view,  0, 0);
}
 
Example #28
Source File: BikingRouteOverlay.java    From BmapLite with GNU General Public License v3.0 4 votes vote down vote up
public List<BitmapDescriptor> getCustomTextureList() {
    ArrayList<BitmapDescriptor> list = new ArrayList<BitmapDescriptor>();
    list.add(BitmapDescriptorFactory.fromAsset("Icon_road_blue_arrow.png"));
    return list;
}
 
Example #29
Source File: TransitRouteOverlay.java    From react-native-baidu-map with MIT License 2 votes vote down vote up
/**
 * 覆写此方法以改变默认终点图标
 * 
 * @return 终点图标
 */
public BitmapDescriptor getTerminalMarker() {
    return null;
}
 
Example #30
Source File: WalkingRouteOverlay.java    From react-native-baidu-map with MIT License 2 votes vote down vote up
/**
 * 覆写此方法以改变默认终点图标
 * 
 * @return 终点图标
 */
public BitmapDescriptor getTerminalMarker() {
    return null;
}