Я хочу назначить два уникальных ключа, которые необходимы другому действию для успешной работы, но я не знаю, как назначить два уникальных ключа, когда речь идет о infowindowclick в маркерах. Есть ли способ, которым я могу правильно передать данные вместо добавления этих ключей во фрагмент? Пожалуйста, посмотрите на мой код ниже.
// I am getting the values of the store here including the storeID
LatLngBounds.Builder builder = new LatLngBounds.Builder();
builder.include(latLng);
for (DocumentSnapshot storeDS: queryDocumentSnapshots){
StoreDetailsModel detailsModel = storeDS.toObject(StoreDetailsModel.class);
GeoPoint storeAddress = detailsModel.getStoreLocation();
double LatitudeData = storeAddress.getLatitude();
double LongitudeData = storeAddress.getLongitude();
final LatLng SlatLng = new LatLng(LatitudeData, LongitudeData);
if (SphericalUtil.computeDistanceBetween(latLng, SlatLng) < 35000){
String storeID = detailsModel.getStoreID();
String storeName = detailsModel.getStoreName();
String storeClass = detailsModel.getStoreClassification();
HashMap storeImg = detailsModel.getStoreImage();
String image = storeImg.get("profile").toString();
addCustomMarkerFromURL(SlatLng, image, storeName, storeClass, mMap, storeID, uid);
builder.include(SlatLng);
}
}
LatLngBounds bounds = builder.build();
CameraUpdate cameraUpdate = CameraUpdateFactory.newLatLngBounds(bounds, 200);
mMap.moveCamera(cameraUpdate);
mMap.animateCamera(CameraUpdateFactory.zoomTo(10), 2000, null);
mMap.setOnInfoWindowClickListener(MapFragment.this);
...
//Then here is the method for infoWindowClick Listener
@Override
public void onInfoWindowClick(Marker marker) {
Intent intent = new Intent(this, StoreDetailsActivity.class)
//Here I have a trouble finding a way to pass the data for the storeID and buyerID
//intent.putExtra("storeID", storeID);
//intent.putExtra("buyerID", buyerID);
startActivity(intent);
}
addCustomMarkerFromURL () Метод:
private void addCustomMarkerFromURL(final LatLng slatLng, String image, final String storeName, final String storeClass, final GoogleMap mMap, final String storeID, final String uid) {
if (mMap == null) {
return;
}
Glide.with(getActivity())
.asBitmap()
.load(image).fitCenter()
.into(new SimpleTarget<Bitmap>() {
@Override
public void onResourceReady(@NonNull Bitmap resource, @androidx.annotation.Nullable Transition<? super Bitmap> transition) {
// mMap.setInfoWindowAdapter(new GoogleInfoWindowAdapter(getActivity(), storeID, uid));
mMap.addMarker(new MarkerOptions()
.position(slatLng)
.icon(BitmapDescriptorFactory.fromBitmap(getMarkerBitmapFromView(getActivity(), resource, storeName))).title(storeClass));
}
});
}
getMarkerBitmapFromView () Метод
private Bitmap getMarkerBitmapFromView(FragmentActivity activity, Bitmap resource, String storeName) {
View view = ((LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).inflate(R.layout.bitmap_google_marker_layout_item, null);
TextView txt_name = (TextView) view.findViewById(R.id.name);
txt_name.setText(storeName);
de.hdodenhof.circleimageview.CircleImageView image = (de.hdodenhof.circleimageview.CircleImageView) view.findViewById(R.id.store_profile_image);
image.setImageBitmap(resource);
view.measure(View.MeasureSpec.UNSPECIFIED, View.MeasureSpec.UNSPECIFIED);
view.layout(0, 0, view.getMeasuredWidth(), view.getMeasuredHeight());
view.buildDrawingCache();
Bitmap returnedBitmap = Bitmap.createBitmap(view.getMeasuredWidth(), view.getMeasuredHeight(),
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(returnedBitmap);
canvas.drawColor(Color.WHITE, PorterDuff.Mode.SRC_IN);
Drawable drawable = view.getBackground();
if (drawable != null)
drawable.draw(canvas);
view.draw(canvas);
return returnedBitmap;
}