Answer the question
In order to leave comments, you need to log in
Google map marker database?
I have two map screens - the first screen is seen by the user and can put a marker with the icon he needs, the second screen is seen by a volunteer who can help him. How to create a database of markers with icons (or if there is another way)? I need to make sure that all those who need help appear on the volunteer screen with the icon that they have chosen.
pickupLocation = new LatLng(lastLocation.getLatitude(), lastLocation.getLongitude());
AlertDialog.Builder builder = new AlertDialog.Builder(PersonMapActivity.this);
builder.setTitle("Я нуждаюсь в ");
// add a list
String[] animals = {"Лекарства", "Продукты", "СИЗ", "Попутка", "Помощь(SOS)"};
final MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(pickupLocation);
builder.setItems(animals, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
switch (which) {
case 0:
mMap.clear();
markerOptions.title("Лекарства").icon(BitmapDescriptorFactory.fromResource(R.mipmap.medicine));
mPersonMarker = FirebaseDatabase.getInstance().getReference().child("Users").child("personRequest").child("Маркер");
mPersonMarker.child("personRequest").setValue(markerOptions);
mMap.addMarker(markerOptions);
break;
case 1:
mMap.clear();
markerOptions.title("Продукты").icon(BitmapDescriptorFactory.fromResource(R.mipmap.diet));
mPersonMarker = FirebaseDatabase.getInstance().getReference().child("Users").child("personRequest").child("Маркер");
mPersonMarker.child("personRequest").setValue(markerOptions);
mMap.addMarker(markerOptions);
break;
case 2:
mMap.clear();
markerOptions.title("СИЗ").icon(BitmapDescriptorFactory.fromResource(R.mipmap.oxygen));
mPersonMarker = FirebaseDatabase.getInstance().getReference().child("Users").child("personRequest").child("Маркер");
mPersonMarker.child("personRequest").setValue(markerOptions);
mMap.addMarker(markerOptions);
break;
case 3:
mMap.clear();
markerOptions.title("Попутка").icon(BitmapDescriptorFactory.fromResource(R.mipmap.car));
mPersonMarker = FirebaseDatabase.getInstance().getReference().child("Users").child("personRequest").child("Маркер");
mPersonMarker.child("personRequest").setValue(markerOptions);
mMap.addMarker(markerOptions);
break;
case 4:
mMap.clear();
markerOptions.title("Помощь(SOS)").icon(BitmapDescriptorFactory.fromResource(R.drawable.help));
mPersonMarker = FirebaseDatabase.getInstance().getReference().child("Users").child("personRequest").child("Маркер");
mPersonMarker.child("personRequest").setValue(markerOptions);
mMap.addMarker(markerOptions);
break;
}
}
});
// create and show the alert dialog
AlertDialog dialog = builder.create();
dialog.show();
}
});
}
Answer the question
In order to leave comments, you need to log in
Your case expressions are so monotonous.
The code tends to replace condition with polymorphism.
How to create a database of markers with icons (or if there is another way)?or do it yourself, or order freelance.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question