【发布时间】:2019-08-23 14:49:14
【问题描述】:
我使用 osmdroid 和 first 方法在地图上显示了一张照片。 现在我想从设备内存中读取一张 jpeg 格式的图片,并将其显示为地图上的位图。该代码没有给出错误。但是照片没有显示。请指导我。以下是第一种和第二种方法代码。
/// first method
GroundOverlay myGroundOverlay = new GroundOverlay();
myGroundOverlay.setPosition(overlayCenterPoint);
Drawable d = ResourcesCompat.getDrawable(getResources(), R.mipmap.ic_imageonmap_test2, null);
myGroundOverlay.setImage(d.mutate());
//myGroundOverlay.setImageBitmap(bitmap);
myGroundOverlay.setDimensions(2000000.0f);
myGroundOverlay.setTransparency(0.25f);
myGroundOverlay.setBearing(0);
mMapView.getOverlays().add(myGroundOverlay);
mMapView.invalidate();
////// second method
Bitmap src = BitmapFactory.decodeFile("/sdcard/osmdroid/20190722033213_1440103389.jpg");
Bitmap bitmap2 = src.copy(Bitmap.Config.ARGB_8888, true);
GroundOverlay myGroundOverlay2 = new GroundOverlay();
myGroundOverlay2.setPosition(overlayCenterPoint);
//myGroundOverlay2.setImageBitmap(src);
myGroundOverlay2.setImageBitmap(bitmap2);
//myGroundOverlay2.setDimensions(2000.0f);
//myGroundOverlay2.setTransparency(0.25f);
myGroundOverlay2.setBearing(0);
mMapView.getOverlays().add(myGroundOverlay2);
mMapView.invalidate();
【问题讨论】:
标签: android bitmap overlay osmdroid