[英]Android Google Maps OnInfoWindowClick keep icon from clicked marker
I want to use the icon from the markers I click in an AlertDialog. 我想使用我在AlertDialog中单击的标记中的图标。 For title its .getTitle() but is there a similar way to do this for icons?
对于标题,它的.getTitle()是这样,但是对于图标,有没有类似的方法呢? (I have another method with a bunch of if statements but it is sloppy work)
(我有一堆if语句的另一种方法,但这是草率的工作)
Here is a Marker I have 这是我的标记
final Marker d1 = mMap.addMarker(new MarkerOptions()
.position(Driver1)
.icon(BitmapDescriptorFactory.fromResource(R.drawable.driver1))
.title(DName1)
);
Here is the Click 这是点击
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();
Thanks 谢谢
Markers may define a custom image to show in place of the default icon. 标记可以定义一个自定义图像以代替默认图标显示。 Defining an icon involves setting a number of properties that affect the visual behavior of the marker.
定义图标涉及设置许多影响标记的视觉行为的属性。
You can replace the default marker image with a custom marker image, often called an icon. 您可以将默认标记图像替换为通常称为图标的自定义标记图像 。 Custom icons are always set as a BitmapDescriptor, and defined using one of four methods in the BitmapDescriptorFactory class.
自定义图标始终设置为BitmapDescriptor,并使用BitmapDescriptorFactory类中的四个方法之一进行定义。
The below snippet creates a marker with a custom icon. 下面的代码段创建了一个带有自定义图标的标记。
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)));
Here is a sample javascript code, I don't know if this is what you want. 这是一个示例javascript代码,我不知道这是否是您想要的。
I hope that it can help you. 希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.