[英]Google maps marker show only icon
我想在Google地圖上顯示標記(Android)
我使用了以下代碼(例如在android開發人員的示例中):
位置,名稱和說明有效(我通過調試模式檢查了它們)
它向我顯示了所需位置的圖標,但是沒有標記或說明和代碼片段。 下一行
mMap.addMarker(MarkerOptions().position(location)
.title(poi.getName()).snippet(poi.getDescription())
.icon(BitmapDescriptorFactory.fromBitmap(image_item));
僅顯示圖標,沒有標題或摘要。
非常感謝
您是否遵循文檔中的示例? 另外, 示例代碼是否與Google Play服務SDK捆綁在一起?
編輯 :您可以通過在目標標記上調用showInfoWindow()
來以編程方式顯示信息窗口:
Marker marker = mMap.addMarker(new MarkerOptions()
.position(location)
.title(poi.getName())
.snippet(poi.getDescription())
.icon(BitmapDescriptorFactory.fromBitmap(image_item));
marker.showInfoWindow();
但是,請記住,一次只能顯示一個信息窗口。 如果用戶單擊另一個標記,則當前窗口將被隱藏,並且將顯示新的信息窗口。
試試這個代碼。 此代碼適用於使用API V2的Google地圖。添加google的內置方法。
public void onMapLongClick(LatLng point){
// Getting the Latitude and Longitude of the touched location
latLng = point;
// Clears the previously touched position
myMap.clear();
// Animating to the touched position
myMap.animateCamera(CameraUpdateFactory.newLatLng(latLng));
// Creating a marker
markerOptions = new MarkerOptions();
// Setting the position for the marker
markerOptions.position(latLng);
// Adding Marker on the touched location with address
new ReverseGeocodingTask(getBaseContext()).execute(latLng);
tmpLatLng = latLng;
drawCircle(point);
btLocInfo.setEnabled(true);
}
這不是一個罕見的問題,修復它的唯一方法是重新安裝它唯一能夠修復它的方法。
顯示沒有標題或摘要的圖標。 使用以下代碼
LatLng newYork = new LatLng(40.7142, 74.0064);
Marker melbourne = map.addMarker(new MarkerOptions()
.position(newYork));
編輯:
map.addMarker(new MarkerOptions().position(new LatLng(lat, lon))
.title(string).snippet(string2).icon(BitmapDescriptorFactory.fromBitmap(image_item));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.