[英]Android Google Maps OnInfoWindowClick keep icon from clicked marker
我想使用我在AlertDialog中單擊的標記中的圖標。 對於標題,它的.getTitle()是這樣,但是對於圖標,有沒有類似的方法呢? (我有一堆if語句的另一種方法,但這是草率的工作)
這是我的標記
final Marker d1 = mMap.addMarker(new MarkerOptions()
.position(Driver1)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.driver1))
.title(DName1)
);
這是點擊
mMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
public void onInfoWindowClick(Marker marker) {
//shit for dialog goes here i think
new AlertDialog.Builder(ibMap.this)
.setTitle(marker.getTitle())
.setMessage("This Message isnt important")
.setCancelable(true)
.setIcon(R.drawable.driver1)
.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
}
)
.setPositiveButton("Continue", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
startActivity(new Intent(ibMap.this, checkout.class));
}
}
).create().show();
謝謝
標記可以定義一個自定義圖像以代替默認圖標顯示。 定義圖標涉及設置許多影響標記的視覺行為的屬性。
您可以將默認標記圖像替換為通常稱為圖標的自定義標記圖像 。 自定義圖標始終設置為BitmapDescriptor,並使用BitmapDescriptorFactory類中的四個方法之一進行定義。
下面的代碼段創建了一個帶有自定義圖標的標記。
private static final LatLng MELBOURNE = new LatLng(-37.813, 144.962);
private Marker melbourne = mMap.addMarker(new MarkerOptions()
.position(MELBOURNE)
.title("Melbourne")
.snippet("Population: 4,137,400")
.icon(BitmapDescriptorFactory.fromResource(R.drawable.arrow)));
這是一個示例javascript代碼,我不知道這是否是您想要的。
希望對您有所幫助。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.