2013-09-25 42 views
3

在设置好GoogleMap标记后,是否可以更改它?我使用的MarkerOptions设置本来像这样的标题和摘要:在Android中更改标记文本GoogleMaps

SupportMapFragment theMapFragment = (SupportMapFragment)getSupportFragmentManager().findFragmentById(R.id.map); 
GoogleMap theMap = theMapFragment.getMap(); 
MarkerOptions theMarker = new MarkerOptions(); 
theMarker.position(theLatLng); 
theMarker.title("My title"); 
theMarker.snippet("This is my snippet"); 
theMarker.visible(true); 
theMap.addMarker(theMarker); 

后来,当用户点击上的东西,我想执行反向地理代码查找和更改名称/代码段包含地址信息。

回答

3

是否可以在GoogleMap标记已经设置后更改其中的文本?

MarkersetTitle()setSnippet()方法。您需要一个代表该标记的Marker对象,可能是您从addMarker()调用中保留的对象。

+0

谢谢帮助! – Elliott

-1

试试这个:

@Override 
public boolean onMarkerClick(final Marker marker) { 

    if (marker.equals(myMarker)) 
    { 
     googleMap.addMarker(new MarkerOptions() 
       .position(marker.getPosition()) 
       .title("Onother title") 
       .snippet("snippet") 
       .icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_AZURE))); 
    } 
}