2015-01-07 43 views
0

1:實施例enter image description here谷歌地圖羣集定製(將文本添加到集羣的項目)

此圖表示一組簇(即具有在中間的文本的那些)以及集羣的項目,這是隻有一個項目的特定類型。

我想要實現的是在羣集項目上,我想添加一些文本,例如「1」,它表示只是一個羣集項目,因此只有一個項目。

我設法讓文本工作在羣組上,但不在羣集項上。

該做的伎倆在我的情況是這樣一個代碼:

String place = item.getPlaceName(); 
      if (place.length() > 12) 
       place = place.substring(0, 10) + ".."; 
      placeAddressAndLocation.setText(place); 

現在我不知道我應該把確切的代碼爲集羣項目。

在該示例中對谷歌dev的發現(這是一個我還以下),存在用於這些

protected void onBeforeClusterItemRendered 

protected void onClusterItemRendered 

嘗試添加代碼上這兩種方法兩個方法,但它沒有做任何事情。有什麼建議麼?謝謝!

回答

0

如果你想使用onBeforeClusterItemRendered,你可以嘗試this answer

所以在onBeforeClusterItemRendered方法中,可以設置markerOptions的屬性。

您可能想要嘗試設置markerOptions的標題,片段或圖標,您可以閱讀the documentation of the markerOptions

+0

謝謝,但我不想顯示一個infoWindow,基本上我試圖設置一些文本到一個項目的羣集。我通過 – funkycookie

+0

得到了一個包含多個項目的羣集的工作方式您能否包含更多關於如何讓多個項目的羣集工作的代碼?另外你當前屏幕的屏幕截圖會很好。 – ztan

+0

它已修復! 集羣聲明瞭兩次,如下所示: private View checkinView = getActivity()。getLayoutInflater()。inflate(R.layout.frame_checkincluster,null); private view clusterView = getActivity()。getLayoutInflater()。inflate(R.layout.frame_checkincluster,null); 其中一個聲明是用於羣集,而另一個用於羣集項目:) – funkycookie