经过长时间的努力才能做到这一点,我终于认为我几乎就在那里。在我的应用程序中,用户可以点击地图上的任何点,然后拍照并返回标记。当点击标记以显示完整图像时,它仅显示最新拍摄的图像。所以在搜索了一周之后解决这个问题后,我被告知使用HashMap将该图像存储到该点,然后使用CustomInfoWindo显示该图像。所以我不得不将我的代码更改为此。所以现在我处于这样的地步,直到用户从相机意图返回,然后我得到这个错误:
12-16 16:38:02.058: E/AndroidRuntime(15998): FATAL EXCEPTION: main
12-16 16:38:02.058: E/AndroidRuntime(15998): Process: com.test.testguide, PID: 15998
12-16 16:38:02.058: E/AndroidRuntime(15998): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=0, result=-1, data=null} to activity {com.test.testguide/com.test.testguide.Test}: java.lang.IllegalArgumentException: no position in marker options
但是位置在那里:
Marker marker = googleMap.addMarker(new MarkerOptions());
marker.setTitle("title");
marker.setSnippet("snippet");
**marker.setPosition(point);**
hash.put(marker, R.drawable.ic_launcher);
为什么会给我这个错误?
修改
这是InfoWindow代码:
@Override
public View getInfoContents(Marker marker) {
TextView title = (TextView) myContentsView.findViewById(R.id.title);
TextView snippet = (TextView) myContentsView.findViewById(R.id.snippet);
ImageView image = ((ImageView)myContentsView.findViewById(R.id.imageView1));
title.setText(marker.getTitle());
snippet.setText(marker.getSnippet());
if(hash.get(marker) != null)
image.setImageDrawable(getResources().getDrawable(hash.get(marker)));
return myContentsView;
}
编辑2
我的相机意图:
Intent getCameraImage = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
getApplicationContext().getDir(
getResources().getString(R.string.app_name), MODE_PRIVATE);
fileUri = Uri.fromFile(new File((Environment.getExternalStorageDirectory() +
"/" +getResources().getString(R.string.app_name)),new Date().getTime() + ".jpg"));
getCameraImage.putExtra(MediaStore.EXTRA_OUTPUT, fileUri);
startActivityForResult(getCameraImage, TAKE_PICTURE);
}
我的onActivityResult
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == TAKE_PICTURE && resultCode == RESULT_OK) {
try {
GetImageThumbnail getImageThumbnail = new GetImageThumbnail();
bitmap = getImageThumbnail.getThumbnail(fileUri, this);
} catch (FileNotFoundException e1) {
e1.printStackTrace();
} catch (IOException e1) {
e1.printStackTrace();
}
{
Marker marker = googleMap.addMarker(new MarkerOptions()
.title("title")
.snippet("snippet")
.position(point));
hash.put(marker, R.drawable.ic_launcher);
答案 0 :(得分:0)
您必须在MarkerOptions上设置值,而不是在返回的Marker上设置值。
Marker marker = googleMap.addMarker(new MarkerOptions().title("title")
.snippet("snippet")
.position(point));
hash.put(marker, R.drawable.ic_launcher);