I recently asked about applying an animation to a marker popup window (infowindow) and was explained why that wasn't possible:
Note: The info window that is drawn is not a live view. The view is rendered as an image (using
View.draw(Canvas)
) at the time it is returned. This means that any subsequent changes to the view will not be reflected by the info window on the map. To update the info window later (e.g., after an image has loaded), callshowInfoWindow()
. Furthermore, the info window will not respect any of the interactivity typical for a normal view such as touch or gesture events. However you can listen to a generic click event on the whole info window as described in the section below.
Researching some more, I found a project using V1 that manually creates the View on the marker's position. To do this, the other guy did something like this:
public void showPopup(View view, GeoPoint point, boolean centerPopup) {
removeAllViews();
MapView.LayoutParams lp = new MapView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
point,
Utils.dipsToPixels(0.0f, mContext),
Utils.dipsToPixels(-12.0f, mContext),
MapView.LayoutParams.BOTTOM_CENTER);
if (centerPopup) {
getController().animateTo(point);
mIgnoreNextChangeEvent = true;
}
View balloon = mInflater.inflate(R.layout.balloon, null);
balloon.setLayoutParams(lp);
((ViewGroup) balloon.findViewById(R.id.balloonBody)).addView(view);
balloon.startAnimation(AnimationUtils.loadAnimation(mContext, R.anim.bounce_in));
addView(balloon);
}
So he manually creates a balloon view and attaches it to the MapView.
I've been trying to emulate this same thing using V2 but I haven't been able and I don't even know if this is possible at all. For example, I use "GoogleMap" instead of "MapView" and I'm not sure if this has anything to do with some of the differences between V1 and V2.
I'm going to add what I have so far just as a reference. I tried to replicate the code from the other project and try to modify it so it will work in this one but I haven't been able to even compile it.
public boolean onMarkerClick(Marker marker) {
map.removeAllViews();
MapView.LayoutParams lp = new MapView.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT,
marker.getPosition(),
Tools.dipsToPixels(0.0f, this),
Tools.dipsToPixels(-12.0f, this),
MapView.LayoutParams.BOTTOM_CENTER);
if (centerPopup) {
getController().animateTo(point);
mIgnoreNextChangeEvent = true;
}
View balloon = mInflater.inflate(R.layout.balloon, null);
balloon.setLayoutParams(lp);
((ViewGroup) balloon.findViewById(R.id.balloonBody)).addView(view);
balloon.startAnimation(AnimationUtils.loadAnimation(mContext, R.anim.bounce_in));
addView(balloon);
return false;
}
You cannot synchronize scrolling map with any view that could be over it and even if you completed this kind of solution it would look laggy.
Have you tried this workaround: https://stackoverflow.com/a/16147630/2183804 ?