【发布时间】:2015-01-23 17:27:24
【问题描述】:
我已经使用 SQLite 数据库在我的应用程序中保存了标记 ID 和图像文件路径。我目前遇到的问题是,当再次加载地图时,标记会显示在用户添加它们的位置,但是通过相机意图(图像路径)为该标记拍摄的图像不会随标记一起加载。
所以解释一下,我的标记有一个CustomInfoWindow,它显示一个标题和sn-p(标记的位置)然后有一个ImageView,它在放置标记后最初会显示图像。但是在重新加载应用程序时,图像消失了,但显示了标题和片段。
所以在保存图像文件路径和我使用的标记 ID 时:
contentValues.put(LocationsDB.FIELD_IMAGE, markerId);
contentValues.put(LocationsDB.FIELD_FILEPATH, image.getAbsolutePath());
它保存的数据是这样的:
m15 --> Marker ID
/storage/emulated/0/My Folder/MyImage_123.jpg --> File Path
然后在应用启动后加载标记时:
String filep = null;
String id = null;
id = arg1.getString(arg1.getColumnIndex(LocationsDB.FIELD_IMAGE));
filep = arg1.getString(arg1.getColumnIndex(LocationsDB.FIELD_FILEPATH));
drawMarker(thePoint, title, snippet, id, filep);
那么在我的drawMarker 方法中:
private void drawMarker(LatLng point, String title, String snippet, String id, String filep) {
Marker marker = googleMap.addMarker(new MarkerOptions()
.title(title)
.snippet(snippet)
.position(thePoint)
.icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_BLUE)));
markerId = marker.getId();
以及在显示初始图片时,title和sn-p:
@Override
public View getInfoContents(Marker marker)
{
View v = getLayoutInflater().inflate(R.layout.infowindow_layout, null);
ImageView markerIcon = (ImageView) v.findViewById(R.id.marker_icon);
TextView titleText = (TextView) v.findViewById(R.id.TitleId);
titleText.setText(marker.getTitle());
TextView snippetText = (TextView) v.findViewById(R.id.SnippetId);
snippetText.setText(marker.getSnippet());
Bitmap bitmap = myMarkersHash.get(marker.getId());
markerIcon.setImageBitmap(bitmap);
return v;
所以我知道我需要以某种方式(在 drawMarker 方法中)实现 filep 和 id 以便我可以显示该标记的图像。但我不确定该怎么做。我不想用图标代替图像,而是希望在 imageview 中使用带有图像的默认标记。
我已经为此苦苦挣扎了几个星期。所以现在我希望有人能够提供帮助。
【问题讨论】:
标签: android sqlite google-maps