S
S
sarascript2020-08-10 08:59:13
Java
sarascript, 2020-08-10 08:59:13

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();
            }
        });
    }


From the side of the volunteer, the code is large, I can only say that you need to somehow add markers to the .icon that the volunteer sees.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
mayton2019, 2020-08-10
@mayton2019

Your case expressions are so monotonous.
The code tends to replace condition with polymorphism.

X
xmoonlight, 2020-08-10
@xmoonlight

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 question

Ask a Question

731 491 924 answers to any question