How to add markers with Long Click on the map?

Hi

I’m looking to create a GoogleMaps map and when i long click anywhere on the map, it will show a modal to add some text to the modal and add a marker at that location and save it in database.
I can’t seem to find the function for long clicking on the map or the event to show modal.
Can someone please help me ?

MurtPoiss

Hello, did you find a solution for this? I am also looking for this exact functionality.

Hi … I went with my own code and its pretty easy …

Something like this:
First i make the marker draggable:

mapa.addMarker(new MarkerOptions()  ...     
      .setDraggable(true);

After you can make a listener setOnMarkerDragListener like this:

mapa.setOnMarkerDragListener(new OnMarkerDragListener() {

            @Override
            public void onMarkerDragStart(Marker marker) {
                // TODO Auto-generated method stub
                //Here your code
            }

            @Override
            public void onMarkerDragEnd(Marker marker) {
                // TODO Auto-generated method stub

            }

            @Override
            public void onMarkerDrag(Marker marker) {
                // TODO Auto-generated method stub

            }
        });

And then you can override that you want (normally onMarkerDragStart to simulate a long click)

Hope it helps

Thank you. Where did you add this code? javascript block?

This topic was automatically closed after 70 days. New replies are no longer allowed.