/** * 初始化百度地图 */ private void initBaiduMap() { // 设置是否显示缩放控件 mMapView.showZoomControls(false); mBaiduMap = mMapView.getMap(); // 设定地图中心点坐标:宁波天翔货柜有限公司(云台山路) LatLng point = new LatLng(29.882673, 121.894326); // 以动画方式更新地图状态,动画耗时默认 300 ms ,地图支持的最大最小级别分别为[3-21] mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newLatLngZoom(point, 18)); // 定义Maker坐标点:宁波天翔货柜有限公司(云台山路) ArrayList<BitmapDescriptor> giflist = new ArrayList<>(); giflist.add(BitmapDescriptorFactory.fromResource(R.mipmap.ic_marker)); giflist.add(BitmapDescriptorFactory.fromResource(R.mipmap.ic_marker_light)); // 通过marker的icons设置一组图片,再通过period设置多少帧刷新一次图片资源 MarkerOptions mo = new MarkerOptions().position(point).icons(giflist).zIndex(0).period(20); // 设置生长动画/掉下动画 // mo.animateType(MarkerOptions.MarkerAnimateType.drop); // 在地图上添加Marker,并显示 mBaiduMap.addOverlay(mo); }
private void addMarker() { if (stLatLng != null) { BitmapDescriptor bitmap = BitmapDescriptorFactory.fromResource(R.drawable.ct_map_location_32); OverlayOptions option = new MarkerOptions().position(stLatLng).icon(bitmap); mBaiduMap.addOverlay(option); } if (msUpdate != null) { mBaiduMap.setMapStatus(msUpdate); } if (polyline != null) { mBaiduMap.addOverlay(polyline); } if (overlay != null) { mBaiduMap.addOverlay(overlay); } }
private void initMaker() { for (FootInfo info : mFootList) { if (info.geo != null) { Double lat = Double.valueOf(info.geo.latitude); Double lon = Double.valueOf(info.geo.longitude); // 定义Maker坐标点 LatLng point = new LatLng(lat,lon); // 构建Marker图标 BitmapDescriptor bitmap = BitmapDescriptorFactory .fromResource(R.drawable.icon_gcoding); // 构建MarkerOption,用于在地图上添加Marker OverlayOptions option = new MarkerOptions().position(point) .icon(bitmap).zIndex(19); marker = (Marker)baiduMap.addOverlay(option); } } mMapView.invalidate(); }
/** * 显示地理标记 * * @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); } } }
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; } }
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; } }
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; }
@Override public BitmapDescriptor getStartMarker() { // if (useDefaultIcon) { return BitmapDescriptorFactory.fromResource(R.mipmap.transparent_icon); // } // return null; }
@Override public BitmapDescriptor getTerminalMarker() { // if (useDefaultIcon) { return BitmapDescriptorFactory.fromResource(R.mipmap.transparent_icon); // } // return null; }
@Override public BitmapDescriptor getBitmapDescriptor() { View headerView = LayoutInflater.from(mContext).inflate(R.layout.img_header,null); mUserAvatar = headerView.findViewById(R.id.avator); if(!mUserPic.equals("/d/file")){ String url = ApiService.BASEURLPIC + mUserPic; OvLoad ovLoad = new OvLoad(); ovLoad.loadAvatorPicture(mContext,url,mUserAvatar); // ovLoad.loadPicture(mActivity,url,mUserAvatar); } BitmapDescriptor bitmap = BitmapDescriptorFactory.fromView(headerView); return bitmap; }
/** * 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()); Bitmap bitmap = mIconGenerator.makeIcon(getClusterText()); descriptor = BitmapDescriptorFactory.fromBitmap(bitmap); mIcons.put(bucket, descriptor); } // TODO: consider adding anchor(.5, .5) (Individual markers will overlap more often) markerOptions.icon(descriptor); }
@Override public BitmapDescriptor getStartMarker() { if (useDefaultIcon) { return BitmapDescriptorFactory.fromResource(R.drawable.icon_st); } return null; }
@Override public BitmapDescriptor getTerminalMarker() { if (useDefaultIcon) { return BitmapDescriptorFactory.fromResource(R.drawable.icon_en); } return null; }
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; } }
private void showMap(double latitude, double longtitude) { LatLng point = new LatLng(latitude, longtitude); BitmapDescriptor bitmap = null; bitmap = BitmapDescriptorFactory.fromResource(R.mipmap.lock); OverlayOptions option = new MarkerOptions().position(point).icon(bitmap); // 在地图上添加Marker,并显示 mBaiduMap.addOverlay(option); mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLng(point)); //设置缩放级别为500米 mBaiduMap.setMapStatus(MapStatusUpdateFactory.newMapStatus(new MapStatus.Builder().zoom(15).build())); }