目前我有一个自定义信息窗口。当我点击它时,它将打开一个新的活动。我想动画交易,为此我需要在屏幕上显示信息窗口的位置。由于infowindow是使用画布在屏幕上绘制的,因此我无法使用infowindow视图来获取其位置。是否有任何workarround存档这个?
由于
public View getInfoWindow(Marker marker) {
if (mCurrentMarker != null && !mCurrentMarker.isInfoWindowShown() && mCurrentMarkerView != null && marker.equals(mCurrentMarker))
return mCurrentMarkerView;
mCurrentMarker = marker;
mCurrentMarkerView = getActivity().getLayoutInflater().inflate(R.layout.listing_infowindow, null);
if (marker.getTitle() == null)
return null;
String[] data = marker.getTitle().split("@@@");
((TextView) mCurrentMarkerView.findViewById(R.id.infoText)).setText(data[0]);
mCurrentMarkerView.findViewById(R.id.infoText).setTag(data[1]);
((TextView) mCurrentMarkerView.findViewById(R.id.infoDescription)).setText(marker.getSnippet());
final ImageView img = (ImageView) mCurrentMarkerView.findViewById(R.id.infoIcon);
String image;
if (data.length < 3)
image = "";
else
image = data[2];
ImageLoader.getInstance().displayImage(image, img, new DisplayImageOptions.Builder()
.showImageOnLoading(R.drawable.nopic)
.showImageOnFail(R.drawable.nopic)
.cacheInMemory(false)
.cacheOnDisk(false)
.considerExifParams(true)
.build(), new SimpleImageLoadingListener() {
@Override
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
super.onLoadingComplete(imageUri, view, loadedImage);
if (mCurrentMarker != null && mCurrentMarker.isInfoWindowShown()) {
mCurrentMarker.hideInfoWindow();
mCurrentMarker.showInfoWindow();
}
}
});
return mCurrentMarkerView;
}
答案 0 :(得分:1)
Projection projection = map.getProjection();
LatLng markerLocation = marker.getPosition();
Point screenPosition = projection.toScreenLocation(markerLocation);