Java Code Examples for com.baidu.mapapi.map.BitmapDescriptorFactory#fromResource()
The following examples show how to use
com.baidu.mapapi.map.BitmapDescriptorFactory#fromResource() .
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: BaiduMapFragment.java From BmapLite with GNU General Public License v3.0 | 6 votes |
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 2
Source File: BaiduMapFragment.java From BmapLite with Apache License 2.0 | 6 votes |
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 |
@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: MainActivity.java From Mobike with Apache License 2.0 | 6 votes |
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 5
Source File: BaiduMapViewManager.java From BaiduMapKit with MIT License | 6 votes |
/** * 显示地理标记 * * @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 6
Source File: MainActivity.java From Mobike with Apache License 2.0 | 5 votes |
@Override public BitmapDescriptor getStartMarker() { // if (useDefaultIcon) { return BitmapDescriptorFactory.fromResource(R.mipmap.transparent_icon); // } // return null; }
Example 7
Source File: MainActivity.java From Mobike with Apache License 2.0 | 5 votes |
@Override public BitmapDescriptor getTerminalMarker() { // if (useDefaultIcon) { return BitmapDescriptorFactory.fromResource(R.mipmap.transparent_icon); // } // return null; }
Example 8
Source File: MapActivity.java From foodie-app with Apache License 2.0 | 5 votes |
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 9
Source File: MapFragment.java From MapForTour with MIT License | 5 votes |
@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 10
Source File: MapActivity.java From BaiduMap-TrafficAssistant with MIT License | 5 votes |
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 11
Source File: MapFragment.java From apollo-DuerOS with Apache License 2.0 | 4 votes |
private void initMap() { // set button which can change large or small mMapView.setMapCustomEnable(true); View child = mMapView.getChildAt(1); // remove logo if (child != null && (child instanceof ImageView || child instanceof ZoomControls)) { child.setVisibility(View.INVISIBLE); // ((ImageView)child).setImageDrawable(getResources().getDrawable(R.drawable.app)); } mMapView.showZoomControls(false); mMapView.showScaleControl(false); mBaiduMap = mMapView.getMap(); // enable location layer mBaiduMap.setMyLocationEnabled(true); // unable traffic picture mBaiduMap.setTrafficEnabled(false); mBaiduMap.setBaiduHeatMapEnabled(false); mBaiduMap.setIndoorEnable(false); mBaiduMap.setBuildingsEnabled(false); mCurrentMode = MyLocationConfiguration.LocationMode.FOLLOWING; mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration(mCurrentMode, true, mCurrentMarker)); // set custom icon、marker mCurrentMarker = BitmapDescriptorFactory .fromResource(R.drawable.car_point); mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration( mCurrentMode, true, mCurrentMarker, accuracyCircleFillColor, accuracyCircleStrokeColor)); mCurrentLat = MapSdkWrapper.getLatitudeBd09ll(); mCurrentLon = MapSdkWrapper.getLongitudeBd09ll(); // get direction info,clockwise 0-360 locData = new MyLocationData.Builder().accuracy((float) mCurrentAccracy) .direction((float) direction).latitude(mCurrentLat).longitude(mCurrentLon).build(); mBaiduMap.setMyLocationData(locData); LatLng ll = new LatLng(mCurrentLat, mCurrentLon); MapStatus.Builder builder = new MapStatus.Builder(); builder.target(ll); // you can customize the size. level=19,the default scale is 14--100 meter MapStatusUpdate u = MapStatusUpdateFactory.zoomTo(mBaiduMap.getMaxZoomLevel() - 5); mBaiduMap.animateMapStatus(u); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); mBaiduMap.setOnMapRenderCallbadk(onMapRenderCallback); LogUtil.i(TAG, "Map is init"); }
Example 12
Source File: MapFragment.java From apollo-DuerOS with Apache License 2.0 | 4 votes |
private void initMap() { // Set the enlargement and reduction button mMapView.setMapCustomEnable(true); View child = mMapView.getChildAt(1); // delete logo if (child != null && (child instanceof ImageView || child instanceof ZoomControls)) { child.setVisibility(View.INVISIBLE); // ((ImageView)child).setImageDrawable(getResources().getDrawable(R.drawable.app)); } mMapView.showZoomControls(false); mMapView.showScaleControl(false); mBaiduMap = mMapView.getMap(); // Open the location layer mBaiduMap.setMyLocationEnabled(true); // Close the traffic map mBaiduMap.setTrafficEnabled(false); mBaiduMap.setBaiduHeatMapEnabled(false); mBaiduMap.setIndoorEnable(false); mBaiduMap.setBuildingsEnabled(false); mCurrentMode = MyLocationConfiguration.LocationMode.FOLLOWING; mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration(mCurrentMode, true, mCurrentMarker)); // set custom logo // Modify it to custom marker mCurrentMarker = BitmapDescriptorFactory .fromResource(R.drawable.car_point); mBaiduMap.setMyLocationConfiguration(new MyLocationConfiguration( mCurrentMode, true, mCurrentMarker, accuracyCircleFillColor, accuracyCircleStrokeColor)); mCurrentLat = MapSdkWrapper.getLatitudeBd09ll(); mCurrentLon = MapSdkWrapper.getLongitudeBd09ll(); // set the direction information that developers get,clockwise:0-360 locData = new MyLocationData.Builder().accuracy(mCurrentAccracy) .direction((float) direction).latitude(mCurrentLat).longitude(mCurrentLon).build(); mBaiduMap.setMyLocationData(locData); LatLng ll = new LatLng(mCurrentLat, mCurrentLon); MapStatus.Builder builder = new MapStatus.Builder(); builder.target(ll); MapStatusUpdate u = MapStatusUpdateFactory.zoomTo(mBaiduMap.getMaxZoomLevel() - 5); mBaiduMap.animateMapStatus(u); mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); mBaiduMap.setOnMapRenderCallbadk(onMapRenderCallback); LogUtil.i(TAG, "Map is init"); }
Example 13
Source File: RouteService.java From Mobike with Apache License 2.0 | 4 votes |
private void initLocation() { mIconLocation = BitmapDescriptorFactory .fromResource(R.mipmap.location_marker); locationMode = MyLocationConfiguration.LocationMode.NORMAL; //定位服务的客户端。宿主程序在客户端声明此类,并调用,目前只支持在主线程中启动 mlocationClient = new LocationClient(this); mlistener = new MylocationListener(); // initMarkerClickEvent(); //注册监听器 mlocationClient.registerLocationListener(mlistener); //配置定位SDK各配置参数,比如定位模式、定位时间间隔、坐标系类型等 LocationClientOption mOption = new LocationClientOption(); //设置坐标类型 mOption.setCoorType("bd09ll"); //设置是否需要地址信息,默认为无地址 mOption.setIsNeedAddress(true); //设置是否打开gps进行定位 mOption.setOpenGps(true); //设置扫描间隔,单位是毫秒 当<1000(1s)时,定时定位无效 int span = 10000; mOption.setScanSpan(span); //设置 LocationClientOption mlocationClient.setLocOption(mOption); //初始化图标,BitmapDescriptorFactory是bitmap 描述信息工厂类. mIconLocation = BitmapDescriptorFactory .fromResource(R.mipmap.location_marker); myOrientationListener = new MyOrientationListener(this); //通过接口回调来实现实时方向的改变 myOrientationListener.setOnOrientationListener(new MyOrientationListener.OnOrientationListener() { @Override public void onOrientationChanged(float x) { } }); // mSearch = RoutePlanSearch.newInstance(); // mSearch.setOnGetRoutePlanResultListener(this); // //开启定位 // mBaiduMap.setMyLocationEnabled(true); if (!mlocationClient.isStarted()) { mlocationClient.start(); } myOrientationListener.start(); }
Example 14
Source File: RouteDetailActivity.java From Mobike with Apache License 2.0 | 4 votes |
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_route_detail); route_detail_mapview = (MapView) findViewById(R.id.route_detail_mapview); total_time = (TextView) findViewById(R.id.total_time); total_distance = (TextView) findViewById(R.id.total_distance); total_price = (TextView) findViewById(R.id.total_pricce); routeBaiduMap = route_detail_mapview.getMap(); route_detail_mapview.showZoomControls(false); startBmp = BitmapDescriptorFactory.fromResource(R.mipmap.route_start); endBmp = BitmapDescriptorFactory.fromResource(R.mipmap.route_end); initMap(); Intent intent = getIntent(); String time = intent.getStringExtra("totalTime"); String distance = intent.getStringExtra("totalDistance"); String price = intent.getStringExtra("totalPrice"); routePointsStr = intent.getStringExtra("routePoints"); routePoints = new Gson().fromJson(routePointsStr, new TypeToken<List<RoutePoint>>() { }.getType()); savaDatas(time,distance,price);//yiwen add List<LatLng> points = new ArrayList<LatLng>(); for (int i = 0; i < routePoints.size(); i++) { RoutePoint point = routePoints.get(i); LatLng latLng = new LatLng(point.getRouteLat(), point.getRouteLng()); Log.d("gaolei", "point.getRouteLat()----show-----" + point.getRouteLat()); Log.d("gaolei", "point.getRouteLng()----show-----" + point.getRouteLng()); points.add(latLng); } if (points.size() > 2) { OverlayOptions ooPolyline = new PolylineOptions().width(10) .color(0xFF36D19D).points(points); routeBaiduMap.addOverlay(ooPolyline); RoutePoint startPoint = routePoints.get(0); LatLng startPosition = new LatLng(startPoint.getRouteLat(), startPoint.getRouteLng()); MapStatus.Builder builder = new MapStatus.Builder(); builder.target(startPosition).zoom(18.0f); routeBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(builder.build())); RoutePoint endPoint = routePoints.get(routePoints.size() - 1); LatLng endPosition = new LatLng(endPoint.getRouteLat(), endPoint.getRouteLng()); addOverLayout(startPosition, endPosition); } total_time.setText("骑行时长:" + time + "分钟"); total_distance.setText("骑行距离:" + distance + "米"); total_price.setText("余额支付:" + price + "元"); }