2015-11-01 84 views
0

我已經設置了我的地圖,以便在開始時縮放到用戶的當前位置(藍點事物)。我把它設置爲:如何在Android的Google地圖v2中爲用戶位置標記設置標題?

map.setMyLocationEnabled(true); 

但是,當我點擊這個標記沒有標題(iOS默認顯示「當前位置」)。如何設置藍色當前位置標記的標題?謝謝。

+1

這不是一個標記。如果你想添加一個信息窗口的標記,請看看這裏:http://stackoverflow.com/questions/30253123/blue-dot-and-circle-is-not-shown-on-mylocation-using-android -fused-location-api –

+0

好的,謝謝。 – JessThePest

回答

0

您可以隨時使用MarkerOptions類的功能.title()來顯示標記的標題。

如: -

MarkerOptions mOptions=new MarkerOptions(); 

mOptions.title('My_Marker_Title'); 

mOptions.position('My_Marker_Position'); // pass the current location here 
mOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.RED)); 
//default color is red here. You can change it. 

Marker myMarker = map.addMarker(mOptions); 

對於My_Marker_position: -

LatLng ltlng=new LatLng(currentLocation.getLatitude(),currentLocation.getLongitude()); 

,並使用mOptions.position(ltlng);

您可以使用許多功能與您的標記了。如添加片段,使其可拖動等

要顯示您的標記信息的使用: -

myMarker.showWindowInfo(); 

參見: - https://developers.google.com/android/reference/com/google/android/gms/maps/model/MarkerOptions

相關問題