How to toggle setContextMenu content in google map : I am working on google-map api. 
I have problem with google map setcontextmenu. 

When the user right-clicks the map, the context menu will appear. I tried to change the content of context menu option from "measure distance" to "stop measure distance".

Below is the code when the user right-clicks, it displays two menus : "measure distance" and "stop measuring". I want it to be toggle.
How can i do this?
Any help would be appreciated so much.


I tried to put flag variable inside the contextmenu but it just didn't work.

    map_2.setContextMenu({
     control: 'map',
     options: [
      {
       title: 'Measure Distance',
       name: 'measure_distance',
       action: function(e) {
        // some codes here
       }
      },
      {
       title: 'Stop Measuring',
       name: 'stop_measure_distance',
       action: function(e) {
        // some codes here
       }
      }
     ]
    });

When the user clicks "measure distance" menu, i want the "measure distance" menu disappear and "stop measuring" menu appears.