0
所有標記的參考如何/我在哪裏可以得到對象當前在地圖上,以檢查是這樣的:查找標記的標籤谷歌地圖API(安卓)
if (Markers.getTag().equals("something"))
通過在閱讀文檔標記它說:「這比存儲一個單獨的地圖更容易」,所以我不想使用HashMap,除非有人說我絕對必須這樣做。
謝謝,下面是一個僞僞代碼
// uid將被標記的標籤
// 1)好歹檢查標籤存在當前配置文件
// 2)如果存在,只需移動標記,只需設置此標記的新位置即可。
// 3)如果沒有,則創建一個新的標記,添加一個標記。
// 4)設置輪廓uid作爲標記的標籤,通過.setTag()
// 5)動畫移動相機的位置經緯度
3-5是好的,只需1-2
// 3) Create a new marker
// Marker to show on the map
Marker friendMarker;
// Add a marker when the image is loaded
friendMarker = googleMap.addMarker(new MarkerOptions()
.position(friendLatLng)
.icon(BitmapDescriptorFactory.fromBitmap(bitmap))
.title(friendProfile.getName()));
// Set the tag on this friend marker, so we can retrieve or update it later
friendMarker.setTag(friendProfile.getUid());
// 5) Animate the camera to that location
CameraPosition cameraPosition = new CameraPosition.Builder().target(friendLatLng).zoom(15).build();
googleMap.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
THX,我希望有一些辦法,我錯過了與setTag()和getTag()。如果列表和地圖是唯一的方法,那麼確定。我已經使用setTag()鍵實現了散列表,並且列表沒有多大區別。 –