2014-03-27 39 views
1

的标记IDS我有TabHostGoogle Maps的应用程序。当我点击包含Map的标签时,我的确是map.clear()。但这只能清理7 markers。当我再次创建标记时,该ID不是从m0开始,而是从m8开始。的Android:谷歌地图

如何从0开始标记的ID?

谢谢

+0

为什么你需要控制它们? –

回答

0

您无法控制API将生成的ID。

你可以做的一件事是删除并重新创建整个MapFragmentMapView,但这是一个矫枉过正。

0
Actually there is a trick to solve this . 

//而绘制

int myId=0; 

MarkerOptions markerOptions = new MarkerOptions() 
      .position("YOUR LATLNG VARIABLE") 
      .snippet(""+myId) 
      .icon(BitmapDescriptorFactory.fromResource(R.drawable.orange_map01)); 

myId++; 

//then in the marker click listener function. 
gmap.setOnMarkerClickListener(new OnMarkerClickListener() { 
@Override 
public boolean onMarkerClick(final Marker arg0) { 
// TODO Auto-generated method stub 

System.out.println("The id you assigned will be available based on the  click "+arg0.getSnippet()); 

//Do what ever you want to do with the assigned id , id will be created newly everytime. 
Yourlist.get(arg0.getsnippet); 



} 
}