私はマップにいくつかのマーカーを持っています。それらのそれぞれに、私はカスタムinfoWindowを膨らませたい。マーカーにinfoWindowの異なるレイアウトを追加します
私が抱えている問題は、infoWindowがそれぞれ同じであるということです。私はいくつかのスタックスレッドを読んだが、私はそれを修正する方法を考え出していない。
public void loadInfoWindow(final String url, final CharSequence title) {
mMap.setInfoWindowAdapter(new GoogleMap.InfoWindowAdapter() {
@Override
public View getInfoWindow(Marker arg0) {
arg0.getId();
View v = getActivity().getLayoutInflater().inflate(R.layout.layout_info_window, null);
Button info = (Button) v.findViewById(R.id.infoButton);
info.setText(title);
BitmapLayout back = (BitmapLayout) v.findViewById(R.id.bitmapBackground);
Picasso.with(getContext()).load(url).into(back);
return v;
}
@Override
public View getInfoContents(Marker arg0) {
return null;
}
});
}
私はそのためセッターであること何かについてsetInfoWindowAdapter
を読み、情報ウィンドウ私はカスタムを膨らませる
for (int i = 0; i<cityObjects.size(); i++){
CityObject cObject = cityObjects.get(i);
Coordinates loc = cObject.getCoordinates();
LatLng pos = new LatLng(loc.getLatitude(), loc.getLongitude());
mMap.addMarker(new MarkerOptions().position(pos).title(cObject.getName()));
loadInfoWindow(cObject.getImgs().get(0), cObject.getName());
builder.include(pos);
}
メソッドマップにマーカーを追加
スニペットは、情報ウィンドウを上書きしますforループが反復するたびに誰かがマーカを認識するための良い解決策を持っていますので、私は別のレイアウトを膨らませることができますか?
あなたはマーカーごとに長い緯度を持っていますので、マーカーをクリックするとマーカーの緯度を長く比較してレイアウトを生成できます。 –
@chetanprajapat偉大な、それは動作します!ビッグ感謝 – Viktor
いつも歓迎... –