2013-07-03 35 views
0

經過一段時間的搜索,我找不到我需要的東西,我看到一些庫看起來這樣做,但我已經實現了使用androids默認方法的系統。安卓地圖註釋按鈕

我設置像這樣的標記:

theMap.addMarker(new MarkerOptions() 
       .position(new LatLng(lat, lon)) 
       .title(title) 
       .icon(BitmapDescriptorFactory.fromResource(R.drawable.pin_map32)) 
       .snippet(strap)); 

不過,我需要像在iOS(轉換應用的iOS從到Android)一個「詳細披露按鈕」,我似乎無法一個按鈕添加到標記 - 是否有可能使用androids系統?

+0

你的意思就像點擊地圖上的一個標記? – tyczj

+0

@tyczj不太好,所以你點擊一個標記並彈出一個註釋就好了 - 我需要在註釋的右側添加一個按鈕,這會打開Web瀏覽器並加載一個新的活動。 –

回答

1

這是不能做到的。

docs

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), call showInfoWindow(). 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.

換句話說,你不能把一個按鈕,在信息窗口,並能夠使用它。如果您想要做類似的事情,您需要使用對話框

+0

Bahhh真的嗎?多麼令人沮喪。我不認爲有任何工作可以在視圖中添加一個按鈕? –

+0

目前沒有,你需要使用像我說的對話框,或者只是使用整個視圖作爲按鈕,就像它在文檔中說的那樣,並顯示你想要什麼 – tyczj

+0

啊好的,那可以。是否有可能在每個引腳上設置一個「隱藏」字段,就像標題,片段等一樣 - 是否有可能擁有一個「url」屬性,然後當您檢測到點擊操作時,執行'theMap.getURL()'並讓自定義屬性進入logcat? –

0

您只能跟蹤標記上的點擊次數。如果你想在標記上點擊按鈕 - 點擊標記&顯示帶按鈕的對話框。

1

總有一些方法。

一個不錯的黑客可以在這裏找到:https://stackoverflow.com/a/15040761/2183804

我還沒有測試它自己,但是從那裏的意見(和upvotes量),我們可以推斷出它工作得很好。