0
有沒有什麼好的示例代碼? (在地圖上顯示照片縮略圖)在地圖上顯示照片縮略圖
下面是我自己嘗試過的代碼,但它不起作用: 如果找到縮略圖路徑,請將其設置爲overlayitem的標記,否則使用默認標記。
問題是隻顯示帶有defaultMarker的項目。超過100多張照片,只有1張照片的縮略圖路徑被找到,似乎我檢索縮略圖的方式在某種程度上是不正確的。
如果你不介意,它是非常冗長的。謝謝!
Drawable drawable = this.getResources().getDrawable(R.drawable.androidmarker);
PhotoOverlay itemizedoverlay = new PhotoOverlay(drawable, this);
String selection = MediaStore.Images.ImageColumns.LATITUDE + " is not null";
Cursor c = this.managedQuery(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, null, selection, null, null);
while (c.moveToNext()){
int longitude = (int) (c.getDouble(c.getColumnIndex(MediaStore.Images.ImageColumns.LONGITUDE)) * 1e6);
int latitude = (int) (c.getDouble(c.getColumnIndex(MediaStore.Images.ImageColumns.LATITUDE))* 1e6);
String title = c.getString(c.getColumnIndex(MediaStore.Images.ImageColumns.TITLE));
String description = c.getString(c.getColumnIndex(MediaStore.Images.ImageColumns.DESCRIPTION));
long imgId = c.getLong(c.getColumnIndex(MediaStore.Images.ImageColumns._ID));
long thumbId = c.getLong(c.getColumnIndex(MediaStore.Images.ImageColumns.MINI_THUMB_MAGIC));
GeoPoint point = new GeoPoint(latitude, longitude);
OverlayItem overlayitem = new OverlayItem(point, title, description);
//Cursor ct = Thumbnails.queryMiniThumbnail(this.getContentResolver(), imgId, Thumbnails.MICRO_KIND, null);
String[] args = new String[]{String.valueOf(thumbId)};
Cursor ct = managedQuery(Thumbnails.EXTERNAL_CONTENT_URI, null, Thumbnails._ID + "= ?", args, null);
if(ct.moveToFirst()){
String path = ct.getString(ct.getColumnIndex(Thumbnails.DATA));
BitmapDrawable d = new BitmapDrawable(this.getResources(), path);
itemizedoverlay.addOverlay(overlayitem, d);
} else {
itemizedoverlay.addOverlay(overlayitem, null);
}
}
c.close();
overlays.add(itemizedoverlay);
PhotoOverlay.addItem()
public void addOverlay(OverlayItem i, Drawable marker){
if(marker != null){
i.setMarker(boundCenterBottom(marker));
}
mOverlays.add(i);
populate();
}
鏈接不工作!任何其他文件? – Sourabh86 2014-08-31 14:45:29