I want to use the icon from the markers I click in an AlertDialog. For title its .getTitle() but is there a similar way to do this for icons? (I have another method with a bunch of if statements but it is sloppy work)
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.
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.
I hope that it can help you.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.