1

カスタム Infowindow を含むマップがあり、ユーザーがマーカーをクリックするたびに情報ウィンドウが完全に表示されるようにしたいのですが、どうすればよいですか?

クリックされたマーカーを中央に配置するのを防ぐためのコードが既にいくつかありますが、必要なことを行う方法がわかりません:

private void preventMarkerCenter(){
        map.setOnMarkerClickListener(new OnMarkerClickListener() {
        public boolean onMarkerClick(Marker marker) {
            // Check if there is an open info window
            if (lastOpenned != null) {
                // Close the info window
                lastOpenned.hideInfoWindow();

                // Is the marker the same marker that was already open
                if (lastOpenned.equals(marker)) {
                    // Nullify the lastOpenned object
                    lastOpenned = null;
                    // Return so that the info window isn't openned again
                    return true;
                } 
            }

            // Open the info window for the marker
            marker.showInfoWindow();
            // Re-assign the last openned such that we can close it later
            lastOpenned = marker;

            // Event was handled by our code do not launch default behaviour.
            return true;
        }
        });
    }
4

1 に答える 1

0

ドキュメントによると:http://developer.android.com/reference/com/google/android/gms/maps/GoogleMap.OnMarkerClickListener.html

戻ることでブロックしている「デフォルトの動作」はtrue、情報ウィンドウを表示してから、マップをマーカーの中央に配置することです。

を呼び出さずmarker.showInfoWindow()に返せfalseば、必要なものが得られると思います。

情報ウィンドウを表示するのに十分なだけマップをパンしたい場合は、それらの計算を自分で行い、 でマップをパンする必要がありますCameraUpdateFactoryCameraUpdateFactory.scrollBy()またはそのようなもの。

于 2014-01-27T22:20:34.373 に答える